diff --git a/internal/logic/api/logic_ext.go b/internal/logic/api/logic_ext.go index 865c5c1..d51eb83 100644 --- a/internal/logic/api/logic_ext.go +++ b/internal/logic/api/logic_ext.go @@ -255,7 +255,11 @@ func (s *LogicExtServer) AddGroupMembers(ctx context.Context, in *pb.AddGroupMem // UpdateGroupMember 更新群组成员信息 func (*LogicExtServer) UpdateGroupMember(ctx context.Context, in *pb.UpdateGroupMemberReq) (*pb.Empty, error) { - return &pb.Empty{}, app.GroupApp.UpdateMember(ctx, in) + userId, _, err := grpclib.GetCtxData(ctx) + if err != nil { + return nil, err + } + return &pb.Empty{}, app.GroupApp.UpdateMember(ctx, in, userId) } // DeleteGroupMember 删除群组成员 diff --git a/internal/logic/app/group_app.go b/internal/logic/app/group_app.go index f78ed2b..f47aa8f 100644 --- a/internal/logic/app/group_app.go +++ b/internal/logic/app/group_app.go @@ -99,7 +99,7 @@ func (*groupApp) AddMembers(ctx context.Context, userId, groupId int64, userIds } // UpdateMember 更新群组用户 -func (*groupApp) UpdateMember(ctx context.Context, in *pb.UpdateGroupMemberReq) error { +func (*groupApp) UpdateMember(ctx context.Context, in *pb.UpdateGroupMemberReq, optId int64) error { group, err := repo.GroupRepo.Get(in.GroupId) if err != nil { return err @@ -112,6 +112,11 @@ func (*groupApp) UpdateMember(ctx context.Context, in *pb.UpdateGroupMemberReq) if err != nil { return err } + + err = group.PushUpdateMember(ctx, optId, in.UserId, int32(in.MemberType)) + if err != nil { + return err + } return nil } diff --git a/internal/logic/domain/group/model/group.go b/internal/logic/domain/group/model/group.go index e19f46a..2076abd 100644 --- a/internal/logic/domain/group/model/group.go +++ b/internal/logic/domain/group/model/group.go @@ -421,7 +421,11 @@ func (g *Group) PushAddMember(ctx context.Context, optUserId int64, addedIds []i }) } + // optUser := usersResp.Users[optUserId] + if optUserId == -1 { + optUser.Nickname = "后台操作" + } err = g.PushMessage(ctx, pb.PushCode_PC_ADD_GROUP_MEMBERS, &pb.AddGroupMembersPush{ OptId: optUser.UserId, OptName: optUser.Nickname, @@ -468,11 +472,40 @@ func (g *Group) DeleteMember(ctx context.Context, userId int64) error { return nil } +func (g *Group) PushUpdateMember(ctx context.Context, optId, userId int64, memberType int32) error { + userResp, err := rpc.GetBusinessIntClient().GetUser(ctx, &pb.GetUserReq{UserId: optId}) + if err != nil { + return err + } + if optId == -1 { + userResp.User.Nickname = "后台操作" + } + updateUserResp, err := rpc.GetBusinessIntClient().GetUser(ctx, &pb.GetUserReq{UserId: userId}) + if err != nil { + return err + } + err = g.PushMessage(ctx, pb.PushCode_PC_UPDATE_GROUP_MEMBER, &pb.UpdateMemberPush{ + OptId: optId, + OptName: userResp.User.Nickname, + UpdateUserId: userId, + UpdateUserName: updateUserResp.User.Nickname, + UpdateUserMemberType: memberType, + }, true) + if err != nil { + return err + } + return nil +} + func (g *Group) PushDeleteMember(ctx context.Context, optId, userId int64) error { userResp, err := rpc.GetBusinessIntClient().GetUser(ctx, &pb.GetUserReq{UserId: optId}) if err != nil { return err } + if optId == -1 { + userResp.User.Nickname = "后台操作" + } + deleteUserResp, err := rpc.GetBusinessIntClient().GetUser(ctx, &pb.GetUserReq{UserId: userId}) if err != nil { return err @@ -494,6 +527,10 @@ func (g *Group) PushGroupMemberBanned(ctx context.Context, optId, userId int64, if err != nil { return err } + if optId == -1 { + userResp.User.Nickname = "后台操作" + } + if !isAllMemberBanned && userId > 0 { bannedUserResp, err := rpc.GetBusinessIntClient().GetUser(ctx, &pb.GetUserReq{UserId: userId}) if err != nil { @@ -540,6 +577,10 @@ func (g *Group) PushGroupMemberRemoveBanned(ctx context.Context, optId, userId i if err != nil { return err } + if optId == -1 { + userResp.User.Nickname = "后台操作" + } + removeBannedUserResp, err := rpc.GetBusinessIntClient().GetUser(ctx, &pb.GetUserReq{UserId: userId}) if err != nil { return err diff --git a/pkg/pb/push.ext.pb.go b/pkg/pb/push.ext.pb.go index da0b4c6..b833831 100644 --- a/pkg/pb/push.ext.pb.go +++ b/pkg/pb/push.ext.pb.go @@ -31,6 +31,7 @@ const ( PushCode_PC_REMOVE_GROUP_MEMBER PushCode = 121 // 移除群组成员 PushCode_PC_BANNED_GROUP_MEMBER PushCode = 122 // 禁言群组成员 PushCode_PC_REMOVE_BANNED_GROUP_MEMBER PushCode = 123 // 取消禁言群组成员 + PushCode_PC_UPDATE_GROUP_MEMBER PushCode = 124 // 更新群组成员信息 ) // Enum value maps for PushCode. @@ -44,6 +45,7 @@ var ( 121: "PC_REMOVE_GROUP_MEMBER", 122: "PC_BANNED_GROUP_MEMBER", 123: "PC_REMOVE_BANNED_GROUP_MEMBER", + 124: "PC_UPDATE_GROUP_MEMBER", } PushCode_value = map[string]int32{ "PC_ADD_DEFAULT": 0, @@ -54,6 +56,7 @@ var ( "PC_REMOVE_GROUP_MEMBER": 121, "PC_BANNED_GROUP_MEMBER": 122, "PC_REMOVE_BANNED_GROUP_MEMBER": 123, + "PC_UPDATE_GROUP_MEMBER": 124, } ) @@ -596,6 +599,86 @@ func (x *RemoveBannedGroupMemberPush) GetRemoveBannedUserName() string { return "" } +// 修改群组成员身份 PC_UPDATE_GROUP_MEMBER = 124 +type UpdateMemberPush struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + OptId int64 `protobuf:"varint,1,opt,name=opt_id,json=optId,proto3" json:"opt_id,omitempty"` // 操作人用户id + OptName string `protobuf:"bytes,2,opt,name=opt_name,json=optName,proto3" json:"opt_name,omitempty"` // 操作人昵称 + UpdateUserId int64 `protobuf:"varint,3,opt,name=update_user_id,json=updateUserId,proto3" json:"update_user_id,omitempty"` // 被修改的成员id + UpdateUserName string `protobuf:"bytes,4,opt,name=update_user_name,json=updateUserName,proto3" json:"update_user_name,omitempty"` // 被修改的成员昵称 + UpdateUserMemberType int32 `protobuf:"varint,5,opt,name=update_user_member_type,json=updateUserMemberType,proto3" json:"update_user_member_type,omitempty"` // 被修改的成员身份类型 +} + +func (x *UpdateMemberPush) Reset() { + *x = UpdateMemberPush{} + if protoimpl.UnsafeEnabled { + mi := &file_push_ext_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateMemberPush) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateMemberPush) ProtoMessage() {} + +func (x *UpdateMemberPush) ProtoReflect() protoreflect.Message { + mi := &file_push_ext_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateMemberPush.ProtoReflect.Descriptor instead. +func (*UpdateMemberPush) Descriptor() ([]byte, []int) { + return file_push_ext_proto_rawDescGZIP(), []int{7} +} + +func (x *UpdateMemberPush) GetOptId() int64 { + if x != nil { + return x.OptId + } + return 0 +} + +func (x *UpdateMemberPush) GetOptName() string { + if x != nil { + return x.OptName + } + return "" +} + +func (x *UpdateMemberPush) GetUpdateUserId() int64 { + if x != nil { + return x.UpdateUserId + } + return 0 +} + +func (x *UpdateMemberPush) GetUpdateUserName() string { + if x != nil { + return x.UpdateUserName + } + return "" +} + +func (x *UpdateMemberPush) GetUpdateUserMemberType() int32 { + if x != nil { + return x.UpdateUserMemberType + } + return 0 +} + var File_push_ext_proto protoreflect.FileDescriptor var file_push_ext_proto_rawDesc = []byte{ @@ -670,21 +753,36 @@ var file_push_ext_proto_rawDesc = []byte{ 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x5f, 0x62, 0x61, 0x6e, 0x6e, 0x65, 0x64, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x42, 0x61, 0x6e, 0x6e, 0x65, 0x64, 0x55, 0x73, 0x65, 0x72, 0x4e, 0x61, - 0x6d, 0x65, 0x2a, 0xd4, 0x01, 0x0a, 0x08, 0x50, 0x75, 0x73, 0x68, 0x43, 0x6f, 0x64, 0x65, 0x12, - 0x12, 0x0a, 0x0e, 0x50, 0x43, 0x5f, 0x41, 0x44, 0x44, 0x5f, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, - 0x54, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x50, 0x43, 0x5f, 0x41, 0x44, 0x44, 0x5f, 0x46, 0x52, - 0x49, 0x45, 0x4e, 0x44, 0x10, 0x64, 0x12, 0x17, 0x0a, 0x13, 0x50, 0x43, 0x5f, 0x41, 0x47, 0x52, - 0x45, 0x45, 0x5f, 0x41, 0x44, 0x44, 0x5f, 0x46, 0x52, 0x49, 0x45, 0x4e, 0x44, 0x10, 0x65, 0x12, - 0x13, 0x0a, 0x0f, 0x50, 0x43, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x47, 0x52, 0x4f, - 0x55, 0x50, 0x10, 0x6e, 0x12, 0x18, 0x0a, 0x14, 0x50, 0x43, 0x5f, 0x41, 0x44, 0x44, 0x5f, 0x47, - 0x52, 0x4f, 0x55, 0x50, 0x5f, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x53, 0x10, 0x78, 0x12, 0x1a, - 0x0a, 0x16, 0x50, 0x43, 0x5f, 0x52, 0x45, 0x4d, 0x4f, 0x56, 0x45, 0x5f, 0x47, 0x52, 0x4f, 0x55, - 0x50, 0x5f, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x10, 0x79, 0x12, 0x1a, 0x0a, 0x16, 0x50, 0x43, - 0x5f, 0x42, 0x41, 0x4e, 0x4e, 0x45, 0x44, 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50, 0x5f, 0x4d, 0x45, - 0x4d, 0x42, 0x45, 0x52, 0x10, 0x7a, 0x12, 0x21, 0x0a, 0x1d, 0x50, 0x43, 0x5f, 0x52, 0x45, 0x4d, - 0x4f, 0x56, 0x45, 0x5f, 0x42, 0x41, 0x4e, 0x4e, 0x45, 0x44, 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50, - 0x5f, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x10, 0x7b, 0x42, 0x0d, 0x5a, 0x0b, 0x67, 0x69, 0x6d, - 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6d, 0x65, 0x22, 0xcb, 0x01, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6d, + 0x62, 0x65, 0x72, 0x50, 0x75, 0x73, 0x68, 0x12, 0x15, 0x0a, 0x06, 0x6f, 0x70, 0x74, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x6f, 0x70, 0x74, 0x49, 0x64, 0x12, 0x19, + 0x0a, 0x08, 0x6f, 0x70, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x07, 0x6f, 0x70, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x75, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, + 0x28, 0x0a, 0x10, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x75, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x55, 0x73, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x35, 0x0a, 0x17, 0x75, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x5f, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x14, 0x75, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, + 0x2a, 0xf0, 0x01, 0x0a, 0x08, 0x50, 0x75, 0x73, 0x68, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, + 0x0e, 0x50, 0x43, 0x5f, 0x41, 0x44, 0x44, 0x5f, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x10, + 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x50, 0x43, 0x5f, 0x41, 0x44, 0x44, 0x5f, 0x46, 0x52, 0x49, 0x45, + 0x4e, 0x44, 0x10, 0x64, 0x12, 0x17, 0x0a, 0x13, 0x50, 0x43, 0x5f, 0x41, 0x47, 0x52, 0x45, 0x45, + 0x5f, 0x41, 0x44, 0x44, 0x5f, 0x46, 0x52, 0x49, 0x45, 0x4e, 0x44, 0x10, 0x65, 0x12, 0x13, 0x0a, + 0x0f, 0x50, 0x43, 0x5f, 0x55, 0x50, 0x44, 0x41, 0x54, 0x45, 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50, + 0x10, 0x6e, 0x12, 0x18, 0x0a, 0x14, 0x50, 0x43, 0x5f, 0x41, 0x44, 0x44, 0x5f, 0x47, 0x52, 0x4f, + 0x55, 0x50, 0x5f, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x53, 0x10, 0x78, 0x12, 0x1a, 0x0a, 0x16, + 0x50, 0x43, 0x5f, 0x52, 0x45, 0x4d, 0x4f, 0x56, 0x45, 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50, 0x5f, + 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x10, 0x79, 0x12, 0x1a, 0x0a, 0x16, 0x50, 0x43, 0x5f, 0x42, + 0x41, 0x4e, 0x4e, 0x45, 0x44, 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50, 0x5f, 0x4d, 0x45, 0x4d, 0x42, + 0x45, 0x52, 0x10, 0x7a, 0x12, 0x21, 0x0a, 0x1d, 0x50, 0x43, 0x5f, 0x52, 0x45, 0x4d, 0x4f, 0x56, + 0x45, 0x5f, 0x42, 0x41, 0x4e, 0x4e, 0x45, 0x44, 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50, 0x5f, 0x4d, + 0x45, 0x4d, 0x42, 0x45, 0x52, 0x10, 0x7b, 0x12, 0x1a, 0x0a, 0x16, 0x50, 0x43, 0x5f, 0x55, 0x50, + 0x44, 0x41, 0x54, 0x45, 0x5f, 0x47, 0x52, 0x4f, 0x55, 0x50, 0x5f, 0x4d, 0x45, 0x4d, 0x42, 0x45, + 0x52, 0x10, 0x7c, 0x42, 0x0d, 0x5a, 0x0b, 0x67, 0x69, 0x6d, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, + 0x62, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -700,7 +798,7 @@ func file_push_ext_proto_rawDescGZIP() []byte { } var file_push_ext_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_push_ext_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_push_ext_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_push_ext_proto_goTypes = []interface{}{ (PushCode)(0), // 0: pb.PushCode (*AddFriendPush)(nil), // 1: pb.AddFriendPush @@ -710,10 +808,11 @@ var file_push_ext_proto_goTypes = []interface{}{ (*RemoveGroupMemberPush)(nil), // 5: pb.RemoveGroupMemberPush (*BannedGroupMemberPush)(nil), // 6: pb.BannedGroupMemberPush (*RemoveBannedGroupMemberPush)(nil), // 7: pb.RemoveBannedGroupMemberPush - (*GroupMember)(nil), // 8: pb.GroupMember + (*UpdateMemberPush)(nil), // 8: pb.UpdateMemberPush + (*GroupMember)(nil), // 9: pb.GroupMember } var file_push_ext_proto_depIdxs = []int32{ - 8, // 0: pb.AddGroupMembersPush.members:type_name -> pb.GroupMember + 9, // 0: pb.AddGroupMembersPush.members:type_name -> pb.GroupMember 1, // [1:1] is the sub-list for method output_type 1, // [1:1] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name @@ -812,6 +911,18 @@ func file_push_ext_proto_init() { return nil } } + file_push_ext_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateMemberPush); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -819,7 +930,7 @@ func file_push_ext_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_push_ext_proto_rawDesc, NumEnums: 1, - NumMessages: 7, + NumMessages: 8, NumExtensions: 0, NumServices: 0, }, diff --git a/pkg/proto/push.ext.proto b/pkg/proto/push.ext.proto index c1aa539..6e7ee30 100644 --- a/pkg/proto/push.ext.proto +++ b/pkg/proto/push.ext.proto @@ -19,6 +19,8 @@ enum PushCode { PC_REMOVE_BANNED_GROUP_MEMBER = 123; // 取消禁言群组成员 + PC_UPDATE_GROUP_MEMBER = 124; // 更新群组成员信息 + } // 推送码 PC_ADD_FRIEND = 100 @@ -79,3 +81,12 @@ message RemoveBannedGroupMemberPush { string remove_banned_user_name = 4; // 被解禁言的成员昵称 } +// 修改群组成员身份 PC_UPDATE_GROUP_MEMBER = 124 +message UpdateMemberPush { + int64 opt_id = 1; // 操作人用户id + string opt_name = 2; // 操作人昵称 + int64 update_user_id = 3; // 被修改的成员id + string update_user_name = 4; // 被修改的成员昵称 + int32 update_user_member_type = 5; // 被修改的成员身份类型 +} + diff --git a/pkg/urlwhitelist/urlwhitelist.go b/pkg/urlwhitelist/urlwhitelist.go index 9c2a13a..0d4e0e8 100644 --- a/pkg/urlwhitelist/urlwhitelist.go +++ b/pkg/urlwhitelist/urlwhitelist.go @@ -13,4 +13,8 @@ var Logic = map[string]int{ "/pb.LogicExt/GetGroupBannedMembers": 2, "/pb.LogicExt/SetGroupBannedMembers": 3, "/pb.LogicExt/SendMessage": 4, + "/pb.LogicExt/UpdateGroupMember": 5, + "/pb.LogicExt/AddGroupMembers": 6, + "/pb.LogicExt/DeleteGroupMember": 7, + "/pb.LogicExt/UpdateGroup": 8, } diff --git a/test/tcp_conn/main.go b/test/tcp_conn/main.go index eb4e446..ff5b157 100644 --- a/test/tcp_conn/main.go +++ b/test/tcp_conn/main.go @@ -88,7 +88,7 @@ func (c *TcpClient) SignIn() { signIn := pb.SignInInput{ UserId: c.UserId, DeviceId: c.DeviceId, - Token: "TMKECCOZBCSAHCTVXKQOCCPILNSMRFMXYXKLSHPF", + Token: "AZPQSSIJMISCDPAZQFIFVLVPSZBXDQFEYHBTUAOO", } c.Output(pb.PackageType_PT_SIGN_IN, time.Now().UnixNano(), &signIn) }