mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
group notification
This commit is contained in:
parent
b8e469fb2e
commit
661871dd8d
@ -225,9 +225,6 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
||||
break
|
||||
}
|
||||
}
|
||||
if tips.OpUser == nil {
|
||||
tips.OpUser = &sdkws.GroupMemberFullInfo{UserID: opUserID, AppMangerLevel: userMap[opUserID].AppMangerLevel}
|
||||
}
|
||||
s.Notification.GroupCreatedNotification(ctx, tips)
|
||||
}
|
||||
return resp, nil
|
||||
@ -476,6 +473,21 @@ func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbGroup.GetGr
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) TakeGroupMember(ctx context.Context, groupID string, userID string) (*relationTb.GroupMemberModel, error) {
|
||||
member, err := s.GroupDatabase.TakeGroupMember(ctx, groupID, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if member.Nickname == "" {
|
||||
user, err := s.User.GetPublicUserInfo(ctx, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
member.Nickname = user.Nickname
|
||||
}
|
||||
return member, nil
|
||||
}
|
||||
|
||||
func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGroupMemberReq) (*pbGroup.KickGroupMemberResp, error) {
|
||||
resp := &pbGroup.KickGroupMemberResp{}
|
||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||
@ -534,7 +546,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
}
|
||||
}
|
||||
}
|
||||
userIDs, err := s.GroupDatabase.FindGroupMemberUserID(ctx, req.GroupID)
|
||||
num, err := s.GroupDatabase.FindGroupMemberNum(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -554,7 +566,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
FaceURL: group.FaceURL,
|
||||
//OwnerUserID: owner[0].UserID,
|
||||
CreateTime: group.CreateTime.UnixMilli(),
|
||||
MemberCount: uint32(len(userIDs)),
|
||||
MemberCount: num,
|
||||
Ex: group.Ex,
|
||||
Status: group.Status,
|
||||
CreatorUserID: group.CreatorUserID,
|
||||
@ -572,11 +584,6 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
|
||||
}
|
||||
if opMember, ok := memberMap[opUserID]; ok {
|
||||
tips.OpUser = convert.Db2PbGroupMember(opMember)
|
||||
} else {
|
||||
tips.OpUser = &sdkws.GroupMemberFullInfo{
|
||||
GroupID: group.GroupID,
|
||||
UserID: opUserID,
|
||||
}
|
||||
}
|
||||
for _, userID := range req.KickedUserIDs {
|
||||
tips.KickedUserList = append(tips.KickedUserList, convert.Db2PbGroupMember(memberMap[userID]))
|
||||
@ -841,7 +848,7 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
|
||||
}
|
||||
s.Notification.SuperGroupNotification(ctx, mcontext.GetOpUserID(ctx), mcontext.GetOpUserID(ctx))
|
||||
} else {
|
||||
info, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, mcontext.GetOpUserID(ctx))
|
||||
info, err := s.TakeGroupMember(ctx, req.GroupID, mcontext.GetOpUserID(ctx))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -880,7 +887,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
||||
var opMember *relationTb.GroupMemberModel
|
||||
if !tokenverify.IsAppManagerUid(ctx) {
|
||||
var err error
|
||||
opMember, err = s.GroupDatabase.TakeGroupMember(ctx, req.GroupInfoForSet.GroupID, mcontext.GetOpUserID(ctx))
|
||||
opMember, err = s.TakeGroupMember(ctx, req.GroupInfoForSet.GroupID, mcontext.GetOpUserID(ctx))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -896,7 +903,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
||||
return nil, utils.Wrap(errs.ErrDismissedAlready, "")
|
||||
}
|
||||
resp := &pbGroup.SetGroupInfoResp{}
|
||||
userIDs, err := s.GroupDatabase.FindGroupMemberUserID(ctx, group.GroupID)
|
||||
count, err := s.GroupDatabase.FindGroupMemberNum(ctx, group.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -916,13 +923,11 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
||||
return nil, err
|
||||
}
|
||||
tips := &sdkws.GroupInfoSetTips{
|
||||
Group: s.groupDB2PB(group, owner.UserID, uint32(len(userIDs))),
|
||||
Group: s.groupDB2PB(group, owner.UserID, count),
|
||||
MuteTime: 0,
|
||||
OpUser: &sdkws.GroupMemberFullInfo{},
|
||||
}
|
||||
if opMember == nil {
|
||||
tips.OpUser = &sdkws.GroupMemberFullInfo{UserID: mcontext.GetOpUserID(ctx)}
|
||||
} else {
|
||||
if opMember != nil {
|
||||
tips.OpUser = s.groupMemberDB2PB(opMember, 0)
|
||||
}
|
||||
var num int
|
||||
@ -1141,19 +1146,17 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
|
||||
}
|
||||
} else {
|
||||
if !req.DeleteMember {
|
||||
userIDs, err := s.GroupDatabase.FindGroupMemberUserID(ctx, req.GroupID)
|
||||
num, err := s.GroupDatabase.FindGroupMemberNum(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//s.Notification.GroupDismissedNotification(ctx, req)
|
||||
tips := &sdkws.GroupDismissedTips{
|
||||
Group: s.groupDB2PB(group, owner.UserID, uint32(len(userIDs))),
|
||||
Group: s.groupDB2PB(group, owner.UserID, num),
|
||||
OpUser: &sdkws.GroupMemberFullInfo{},
|
||||
}
|
||||
if mcontext.GetOpUserID(ctx) == owner.UserID {
|
||||
tips.OpUser = s.groupMemberDB2PB(owner, 0)
|
||||
} else {
|
||||
tips.OpUser = &sdkws.GroupMemberFullInfo{UserID: mcontext.GetOpUserID(ctx)}
|
||||
}
|
||||
s.Notification.GroupDismissedNotification(ctx, tips)
|
||||
}
|
||||
@ -1166,12 +1169,12 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGrou
|
||||
//if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
member, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.UserID)
|
||||
member, err := s.TakeGroupMember(ctx, req.GroupID, req.UserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !tokenverify.IsAppManagerUid(ctx) {
|
||||
opMember, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, mcontext.GetOpUserID(ctx))
|
||||
opMember, err := s.TakeGroupMember(ctx, req.GroupID, mcontext.GetOpUserID(ctx))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -1214,12 +1217,12 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.Ca
|
||||
//if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
member, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.UserID)
|
||||
member, err := s.TakeGroupMember(ctx, req.GroupID, req.UserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !tokenverify.IsAppManagerUid(ctx) {
|
||||
opMember, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, mcontext.GetOpUserID(ctx))
|
||||
opMember, err := s.TakeGroupMember(ctx, req.GroupID, mcontext.GetOpUserID(ctx))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ type GroupDatabase interface {
|
||||
TakeGroupOwner(ctx context.Context, groupID string) (*relationTb.GroupMemberModel, error)
|
||||
FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relationTb.GroupMemberModel, error)
|
||||
FindGroupMemberUserID(ctx context.Context, groupID string) ([]string, error)
|
||||
FindGroupMemberNum(ctx context.Context, groupID string) (uint32, error)
|
||||
FindUserManagedGroupID(ctx context.Context, userID string) (groupIDs []string, err error)
|
||||
PageGroupRequest(ctx context.Context, groupIDs []string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupRequestModel, error)
|
||||
//PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error)
|
||||
@ -112,6 +113,14 @@ func (g *groupDatabase) FindGroupMemberUserID(ctx context.Context, groupID strin
|
||||
return g.cache.GetGroupMemberIDs(ctx, groupID)
|
||||
}
|
||||
|
||||
func (g *groupDatabase) FindGroupMemberNum(ctx context.Context, groupID string) (uint32, error) {
|
||||
num, err := g.cache.GetGroupMemberNum(ctx, groupID)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return uint32(num), nil
|
||||
}
|
||||
|
||||
func (g *groupDatabase) CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error {
|
||||
var cache = g.cache.NewCache()
|
||||
if err := g.tx.Transaction(func(tx any) error {
|
||||
|
@ -52,26 +52,23 @@ func (g *GroupNotificationSender) getGroupInfo(ctx context.Context, groupID stri
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
userIDs, err := g.db.FindGroupMemberUserID(ctx, groupID)
|
||||
num, err := g.db.FindGroupMemberNum(ctx, groupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
owner, err := g.db.FindGroupMember(ctx, []string{groupID}, nil, []int32{constant.GroupOwner})
|
||||
owner, err := g.db.TakeGroupOwner(ctx, groupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(owner) == 0 {
|
||||
return nil, errs.ErrInternalServer.Wrap(fmt.Sprintf("group %s owner not found", groupID))
|
||||
}
|
||||
return &sdkws.GroupInfo{
|
||||
GroupID: gm.GroupID,
|
||||
GroupName: gm.GroupName,
|
||||
Notification: gm.Notification,
|
||||
Introduction: gm.Introduction,
|
||||
FaceURL: gm.FaceURL,
|
||||
OwnerUserID: owner[0].UserID,
|
||||
OwnerUserID: owner.UserID,
|
||||
CreateTime: gm.CreateTime.UnixMilli(),
|
||||
MemberCount: uint32(len(userIDs)),
|
||||
MemberCount: num,
|
||||
Ex: gm.Ex,
|
||||
Status: gm.Status,
|
||||
CreatorUserID: gm.CreatorUserID,
|
||||
@ -85,7 +82,6 @@ func (g *GroupNotificationSender) getGroupInfo(ctx context.Context, groupID stri
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) getGroupMembers(ctx context.Context, groupID string, userIDs []string) ([]*sdkws.GroupMemberFullInfo, error) {
|
||||
//members, err := g.db.FindGroupMember(ctx, []string{groupID}, userIDs, []int32{constant.GroupOwner})
|
||||
members, err := g.db.FindGroupMember(ctx, []string{groupID}, userIDs, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -96,30 +92,27 @@ func (g *GroupNotificationSender) getGroupMembers(ctx context.Context, groupID s
|
||||
}
|
||||
res := make([]*sdkws.GroupMemberFullInfo, 0, len(members))
|
||||
for _, member := range members {
|
||||
var appMangerLevel int32
|
||||
if user := users[member.UserID]; user != nil {
|
||||
appMangerLevel = user.AppMangerLevel
|
||||
if member.Nickname == "" {
|
||||
member.Nickname = user.Nickname
|
||||
}
|
||||
if member.FaceURL == "" {
|
||||
member.FaceURL = user.FaceURL
|
||||
}
|
||||
user, ok := users[member.UserID]
|
||||
if !ok {
|
||||
return nil, errs.ErrUserIDNotFound.Wrap(fmt.Sprintf("group %s member %s not in user", member.GroupID, member.UserID))
|
||||
}
|
||||
res = append(res, g.groupMemberDB2PB(member, appMangerLevel))
|
||||
if member.Nickname == "" {
|
||||
member.Nickname = user.Nickname
|
||||
}
|
||||
res = append(res, g.groupMemberDB2PB(member, user.AppMangerLevel))
|
||||
delete(users, member.UserID)
|
||||
}
|
||||
for userID, info := range users {
|
||||
if info.AppMangerLevel == constant.AppAdmin {
|
||||
res = append(res, &sdkws.GroupMemberFullInfo{
|
||||
GroupID: groupID,
|
||||
UserID: userID,
|
||||
Nickname: info.Nickname,
|
||||
FaceURL: info.FaceURL,
|
||||
AppMangerLevel: info.AppMangerLevel,
|
||||
})
|
||||
}
|
||||
}
|
||||
//for userID, info := range users {
|
||||
// if info.AppMangerLevel == constant.AppAdmin {
|
||||
// res = append(res, &sdkws.GroupMemberFullInfo{
|
||||
// GroupID: groupID,
|
||||
// UserID: userID,
|
||||
// Nickname: info.Nickname,
|
||||
// FaceURL: info.FaceURL,
|
||||
// AppMangerLevel: info.AppMangerLevel,
|
||||
// })
|
||||
// }
|
||||
//}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@ -206,102 +199,70 @@ func (g *GroupNotificationSender) getUsersInfoMap(ctx context.Context, userIDs [
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) getFromToUserNickname(ctx context.Context, fromUserID, toUserID string) (string, string, error) {
|
||||
users, err := g.getUsersInfoMap(ctx, []string{fromUserID, toUserID})
|
||||
func (g *GroupNotificationSender) fillOpUser(ctx context.Context, opUser **sdkws.GroupMemberFullInfo, groupID string) error {
|
||||
if opUser == nil {
|
||||
return errs.ErrInternalServer.Wrap("**sdkws.GroupMemberFullInfo is nil")
|
||||
}
|
||||
if *opUser != nil {
|
||||
return nil
|
||||
}
|
||||
userID := mcontext.GetOpUserID(ctx)
|
||||
if groupID != "" {
|
||||
member, err := g.db.TakeGroupMember(ctx, groupID, userID)
|
||||
if err == nil {
|
||||
*opUser = g.groupMemberDB2PB(member, 0)
|
||||
} else if !errs.ErrRecordNotFound.Is(err) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
user, err := g.getUser(ctx, userID)
|
||||
if err != nil {
|
||||
return "", "", nil
|
||||
return err
|
||||
}
|
||||
return users[fromUserID].Nickname, users[toUserID].Nickname, nil
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) mergeGroupFull(ctx context.Context, groupID string, group *relation.GroupModel, ms *[]*relation.GroupMemberModel, users *map[string]*sdkws.UserInfo) (groupInfo *sdkws.GroupCreatedTips, err error) {
|
||||
defer log.ZDebug(ctx, "return")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
log.ZError(ctx, utils.GetFuncName(1)+" failed", err)
|
||||
}
|
||||
}()
|
||||
if group == nil {
|
||||
group, err = g.db.TakeGroup(ctx, groupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if ms == nil {
|
||||
var temp []*relation.GroupMemberModel
|
||||
ms = &temp
|
||||
}
|
||||
if users == nil {
|
||||
temp := make(map[string]*sdkws.UserInfo)
|
||||
users = &temp
|
||||
}
|
||||
var members []*relation.GroupMemberModel
|
||||
if len(*ms) == 0 {
|
||||
members, err = g.db.FindGroupMember(ctx, []string{groupID}, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
*ms = members
|
||||
} else {
|
||||
members = *ms
|
||||
}
|
||||
opUserID := mcontext.GetOpUserID(ctx)
|
||||
var userMap map[string]*sdkws.UserInfo
|
||||
if users == nil || len(*users) == 0 {
|
||||
userIDs := utils.Slice(members, func(e *relation.GroupMemberModel) string { return e.UserID })
|
||||
userIDs = append(userIDs, opUserID)
|
||||
userMap, err = g.getUsersInfoMap(ctx, userIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if users != nil {
|
||||
*users = userMap
|
||||
if *opUser == nil {
|
||||
*opUser = &sdkws.GroupMemberFullInfo{
|
||||
GroupID: groupID,
|
||||
UserID: userID,
|
||||
Nickname: user.Nickname,
|
||||
FaceURL: user.FaceURL,
|
||||
OperatorUserID: userID,
|
||||
}
|
||||
} else {
|
||||
userMap = *users
|
||||
}
|
||||
var (
|
||||
opUserMember *sdkws.GroupMemberFullInfo
|
||||
groupOwnerMember *sdkws.GroupMemberFullInfo
|
||||
)
|
||||
for _, member := range members {
|
||||
if member.UserID == opUserID {
|
||||
opUserMember = g.groupMemberDB2PB(member, userMap[member.UserID].AppMangerLevel)
|
||||
if (*opUser).Nickname == "" {
|
||||
(*opUser).Nickname = user.Nickname
|
||||
}
|
||||
if member.RoleLevel == constant.GroupOwner {
|
||||
groupOwnerMember = g.groupMemberDB2PB(member, userMap[member.UserID].AppMangerLevel)
|
||||
}
|
||||
if opUserMember != nil && groupOwnerMember != nil {
|
||||
break
|
||||
if (*opUser).FaceURL == "" {
|
||||
(*opUser).FaceURL = user.FaceURL
|
||||
}
|
||||
}
|
||||
if opUser := userMap[opUserID]; opUser != nil && opUserMember == nil {
|
||||
opUserMember = &sdkws.GroupMemberFullInfo{
|
||||
GroupID: group.GroupID,
|
||||
UserID: opUser.UserID,
|
||||
Nickname: opUser.Nickname,
|
||||
FaceURL: opUser.FaceURL,
|
||||
AppMangerLevel: opUser.AppMangerLevel,
|
||||
}
|
||||
}
|
||||
groupInfo = &sdkws.GroupCreatedTips{Group: g.groupDB2PB(group, groupOwnerMember.UserID, uint32(len(members))),
|
||||
OpUser: opUserMember, GroupOwnerUser: groupOwnerMember}
|
||||
return groupInfo, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupCreatedNotification(ctx context.Context, tips *sdkws.GroupCreatedTips) (err error) {
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupCreatedNotification, tips)
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupInfoSetNotification(ctx context.Context, tips *sdkws.GroupInfoSetTips) (err error) {
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetNotification, tips)
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupInfoSetNameNotification(ctx context.Context, tips *sdkws.GroupInfoSetNameTips) (err error) {
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetNameNotification, tips)
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupInfoSetAnnouncementNotification(ctx context.Context, tips *sdkws.GroupInfoSetAnnouncementTips) (err error) {
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetAnnouncementNotification, tips)
|
||||
}
|
||||
|
||||
@ -365,15 +326,14 @@ func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx conte
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
user, err := g.getGroupMember(ctx, req.GroupID, mcontext.GetOpUserID(ctx))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
userIDs, err := g.getGroupOwnerAndAdminUserID(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tips := &sdkws.GroupApplicationAcceptedTips{Group: group, OpUser: user, HandleMsg: req.HandledMsg, ReceiverAs: 1}
|
||||
tips := &sdkws.GroupApplicationAcceptedTips{Group: group, HandleMsg: req.HandledMsg, ReceiverAs: 1}
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, userID := range append(userIDs, mcontext.GetOpUserID(ctx)) {
|
||||
err = g.Notification(ctx, mcontext.GetOpUserID(ctx), userID, constant.GroupApplicationAcceptedNotification, tips)
|
||||
if err != nil {
|
||||
@ -384,25 +344,18 @@ func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx conte
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (err error) {
|
||||
defer log.ZDebug(ctx, "return")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
log.ZError(ctx, utils.GetFuncName(1)+" failed", err)
|
||||
}
|
||||
}()
|
||||
group, err := g.getGroupInfo(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
user, err := g.getGroupMember(ctx, req.GroupID, mcontext.GetOpUserID(ctx))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
userIDs, err := g.getGroupOwnerAndAdminUserID(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tips := &sdkws.GroupApplicationRejectedTips{Group: group, OpUser: user, HandleMsg: req.HandledMsg}
|
||||
tips := &sdkws.GroupApplicationRejectedTips{Group: group, HandleMsg: req.HandledMsg}
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, userID := range append(userIDs, mcontext.GetOpUserID(ctx)) {
|
||||
err = g.Notification(ctx, mcontext.GetOpUserID(ctx), userID, constant.GroupApplicationRejectedNotification, tips)
|
||||
if err != nil {
|
||||
@ -413,12 +366,6 @@ func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx conte
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupOwnerTransferredNotification(ctx context.Context, req *pbGroup.TransferGroupOwnerReq) (err error) {
|
||||
defer log.ZDebug(ctx, "return")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
log.ZError(ctx, utils.GetFuncName(1)+" failed", err)
|
||||
}
|
||||
}()
|
||||
group, err := g.getGroupInfo(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -429,47 +376,24 @@ func (g *GroupNotificationSender) GroupOwnerTransferredNotification(ctx context.
|
||||
return err
|
||||
}
|
||||
tips := &sdkws.GroupOwnerTransferredTips{Group: group, OpUser: member[opUserID], NewGroupOwner: member[req.NewOwnerUserID]}
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupOwnerTransferredNotification, tips)
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) MemberKickedNotification(ctx context.Context, tips *sdkws.MemberKickedTips) (err error) {
|
||||
//defer log.ZDebug(ctx, "return")
|
||||
//defer func() {
|
||||
// if err != nil {
|
||||
// log.ZError(ctx, utils.GetFuncName(1)+" failed", err)
|
||||
// }
|
||||
//}()
|
||||
//group, err := g.getGroupInfo(ctx, tips.GroupID)
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
//user, err := g.getGroupMember(ctx, tips.GroupID, mcontext.GetOpUserID(ctx))
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
//tips := &sdkws.MemberKickedTips{Group: group, OpUser: user}
|
||||
//for _, v := range kickedUserIDList {
|
||||
// var groupMemberInfo sdkws.GroupMemberFullInfo
|
||||
// if err := c.setGroupMemberInfo(ctx, tips.GroupID, v, &groupMemberInfo); err != nil {
|
||||
// continue
|
||||
// }
|
||||
// MemberKickedTips.KickedUserList = append(MemberKickedTips.KickedUserList, &groupMemberInfo)
|
||||
//}
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.MemberKickedNotification, tips)
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) MemberInvitedNotification(ctx context.Context, groupID, reason string, invitedUserIDList []string) (err error) {
|
||||
defer log.ZDebug(ctx, "return")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
log.ZError(ctx, utils.GetFuncName(1)+" failed", err)
|
||||
}
|
||||
}()
|
||||
group, err := g.getGroupInfo(ctx, groupID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opUser, err := g.getGroupMember(ctx, groupID, mcontext.GetOpUserID(ctx))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -477,17 +401,14 @@ func (g *GroupNotificationSender) MemberInvitedNotification(ctx context.Context,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tips := &sdkws.MemberInvitedTips{Group: group, OpUser: opUser, InvitedUserList: users}
|
||||
tips := &sdkws.MemberInvitedTips{Group: group, InvitedUserList: users}
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.MemberInvitedNotification, tips)
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) MemberEnterNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (err error) {
|
||||
defer log.ZDebug(ctx, "return")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
log.ZError(ctx, utils.GetFuncName(1)+" failed", err)
|
||||
}
|
||||
}()
|
||||
group, err := g.getGroupInfo(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -501,40 +422,13 @@ func (g *GroupNotificationSender) MemberEnterNotification(ctx context.Context, r
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupDismissedNotification(ctx context.Context, tips *sdkws.GroupDismissedTips) (err error) {
|
||||
//defer log.ZDebug(ctx, "return")
|
||||
//defer func() {
|
||||
// if err != nil {
|
||||
// log.ZError(ctx, utils.GetFuncName(1)+" failed", err)
|
||||
// }
|
||||
//}()
|
||||
//group, err := g.getGroupInfo(ctx, req.GroupID)
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
//users, err := g.getGroupMembers(ctx, req.GroupID, []string{mcontext.GetOpUserID(ctx)})
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
//tips := &sdkws.GroupDismissedTips{Group: group}
|
||||
//if len(users) > 0 {
|
||||
// tips.OpUser = users[0]
|
||||
//} else {
|
||||
// tips.OpUser = &sdkws.GroupMemberFullInfo{
|
||||
// GroupID: group.GroupID,
|
||||
// UserID: mcontext.GetOpUserID(ctx),
|
||||
// }
|
||||
//}
|
||||
//return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupDismissedNotification, tips)
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupDismissedNotification, tips)
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupMemberMutedNotification(ctx context.Context, groupID, groupMemberUserID string, mutedSeconds uint32) (err error) {
|
||||
defer log.ZDebug(ctx, "return")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
log.ZError(ctx, utils.GetFuncName(1)+" failed", err)
|
||||
}
|
||||
}()
|
||||
group, err := g.getGroupInfo(ctx, groupID)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -545,16 +439,13 @@ func (g *GroupNotificationSender) GroupMemberMutedNotification(ctx context.Conte
|
||||
}
|
||||
tips := &sdkws.GroupMemberMutedTips{Group: group, MutedSeconds: mutedSeconds,
|
||||
OpUser: user[mcontext.GetOpUserID(ctx)], MutedUser: user[groupMemberUserID]}
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberMutedNotification, tips)
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupMemberCancelMutedNotification(ctx context.Context, groupID, groupMemberUserID string) (err error) {
|
||||
defer log.ZDebug(ctx, "return")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
log.ZError(ctx, utils.GetFuncName(1)+" failed", err)
|
||||
}
|
||||
}()
|
||||
group, err := g.getGroupInfo(ctx, groupID)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -564,16 +455,13 @@ func (g *GroupNotificationSender) GroupMemberCancelMutedNotification(ctx context
|
||||
return err
|
||||
}
|
||||
tips := &sdkws.GroupMemberCancelMutedTips{Group: group, OpUser: user[mcontext.GetOpUserID(ctx)], MutedUser: user[groupMemberUserID]}
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberCancelMutedNotification, tips)
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupMutedNotification(ctx context.Context, groupID string) (err error) {
|
||||
defer log.ZDebug(ctx, "return")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
log.ZError(ctx, utils.GetFuncName(1)+" failed", err)
|
||||
}
|
||||
}()
|
||||
group, err := g.getGroupInfo(ctx, groupID)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -585,19 +473,14 @@ func (g *GroupNotificationSender) GroupMutedNotification(ctx context.Context, gr
|
||||
tips := &sdkws.GroupMutedTips{Group: group}
|
||||
if len(users) > 0 {
|
||||
tips.OpUser = users[0]
|
||||
} else {
|
||||
tips.OpUser = &sdkws.GroupMemberFullInfo{UserID: mcontext.GetOpUserID(ctx), GroupID: groupID}
|
||||
}
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMutedNotification, tips)
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupCancelMutedNotification(ctx context.Context, groupID string) (err error) {
|
||||
defer log.ZDebug(ctx, "return")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
log.ZError(ctx, utils.GetFuncName(1)+" failed", err)
|
||||
}
|
||||
}()
|
||||
group, err := g.getGroupInfo(ctx, groupID)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -609,19 +492,14 @@ func (g *GroupNotificationSender) GroupCancelMutedNotification(ctx context.Conte
|
||||
tips := &sdkws.GroupCancelMutedTips{Group: group}
|
||||
if len(users) > 0 {
|
||||
tips.OpUser = users[0]
|
||||
} else {
|
||||
tips.OpUser = &sdkws.GroupMemberFullInfo{UserID: mcontext.GetOpUserID(ctx), GroupID: groupID}
|
||||
}
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupCancelMutedNotification, tips)
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupMemberInfoSetNotification(ctx context.Context, groupID, groupMemberUserID string) (err error) {
|
||||
defer log.ZDebug(ctx, "return")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
log.ZError(ctx, utils.GetFuncName(1)+" failed", err)
|
||||
}
|
||||
}()
|
||||
group, err := g.getGroupInfo(ctx, groupID)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -631,16 +509,13 @@ func (g *GroupNotificationSender) GroupMemberInfoSetNotification(ctx context.Con
|
||||
return err
|
||||
}
|
||||
tips := &sdkws.GroupMemberInfoSetTips{Group: group, OpUser: user[mcontext.GetOpUserID(ctx)], ChangedUser: user[groupMemberUserID]}
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberInfoSetNotification, tips)
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupMemberSetToAdminNotification(ctx context.Context, groupID, groupMemberUserID string) (err error) {
|
||||
defer log.ZDebug(ctx, "return")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
log.ZError(ctx, utils.GetFuncName(1)+" failed", err)
|
||||
}
|
||||
}()
|
||||
group, err := g.getGroupInfo(ctx, groupID)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -650,16 +525,13 @@ func (g *GroupNotificationSender) GroupMemberSetToAdminNotification(ctx context.
|
||||
return err
|
||||
}
|
||||
tips := &sdkws.GroupMemberInfoSetTips{Group: group, OpUser: user[mcontext.GetOpUserID(ctx)], ChangedUser: user[groupMemberUserID]}
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberSetToAdminNotification, tips)
|
||||
}
|
||||
|
||||
func (g *GroupNotificationSender) GroupMemberSetToOrdinaryUserNotification(ctx context.Context, groupID, groupMemberUserID string) (err error) {
|
||||
defer log.ZDebug(ctx, "return")
|
||||
defer func() {
|
||||
if err != nil {
|
||||
log.ZError(ctx, utils.GetFuncName(1)+" failed", err)
|
||||
}
|
||||
}()
|
||||
group, err := g.getGroupInfo(ctx, groupID)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -669,6 +541,9 @@ func (g *GroupNotificationSender) GroupMemberSetToOrdinaryUserNotification(ctx c
|
||||
return err
|
||||
}
|
||||
tips := &sdkws.GroupMemberInfoSetTips{Group: group, OpUser: user[mcontext.GetOpUserID(ctx)], ChangedUser: user[groupMemberUserID]}
|
||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||
return err
|
||||
}
|
||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberSetToOrdinaryUserNotification, tips)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user