|
|
@ -233,17 +233,17 @@ func (g *NotificationSender) groupMemberDB2PB(member *model.GroupMember, appMang
|
|
|
|
return result, nil
|
|
|
|
return result, nil
|
|
|
|
} */
|
|
|
|
} */
|
|
|
|
|
|
|
|
|
|
|
|
func (g *NotificationSender) fillOpUser(ctx context.Context, opUser **sdkws.GroupMemberFullInfo, groupID string) (err error) {
|
|
|
|
func (g *NotificationSender) fillOpUser(ctx context.Context, targetUser **sdkws.GroupMemberFullInfo, groupID string) (err error) {
|
|
|
|
return g.fillOpUserByUserID(ctx, mcontext.GetOpUserID(ctx), opUser, groupID)
|
|
|
|
return g.fillUserByUserID(ctx, mcontext.GetOpUserID(ctx), targetUser, groupID)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (g *NotificationSender) fillOpUserByUserID(ctx context.Context, userID string, opUser **sdkws.GroupMemberFullInfo, groupID string) error {
|
|
|
|
func (g *NotificationSender) fillUserByUserID(ctx context.Context, userID string, targetUser **sdkws.GroupMemberFullInfo, groupID string) error {
|
|
|
|
if opUser == nil {
|
|
|
|
if targetUser == nil {
|
|
|
|
return errs.ErrInternalServer.WrapMsg("**sdkws.GroupMemberFullInfo is nil")
|
|
|
|
return errs.ErrInternalServer.WrapMsg("**sdkws.GroupMemberFullInfo is nil")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if groupID != "" {
|
|
|
|
if groupID != "" {
|
|
|
|
if authverify.IsManagerUserID(userID, g.config.Share.IMAdminUserID) {
|
|
|
|
if authverify.IsManagerUserID(userID, g.config.Share.IMAdminUserID) {
|
|
|
|
*opUser = &sdkws.GroupMemberFullInfo{
|
|
|
|
*targetUser = &sdkws.GroupMemberFullInfo{
|
|
|
|
GroupID: groupID,
|
|
|
|
GroupID: groupID,
|
|
|
|
UserID: userID,
|
|
|
|
UserID: userID,
|
|
|
|
RoleLevel: constant.GroupAdmin,
|
|
|
|
RoleLevel: constant.GroupAdmin,
|
|
|
@ -252,7 +252,7 @@ func (g *NotificationSender) fillOpUserByUserID(ctx context.Context, userID stri
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
member, err := g.db.TakeGroupMember(ctx, groupID, userID)
|
|
|
|
member, err := g.db.TakeGroupMember(ctx, groupID, userID)
|
|
|
|
if err == nil {
|
|
|
|
if err == nil {
|
|
|
|
*opUser = g.groupMemberDB2PB(member, 0)
|
|
|
|
*targetUser = g.groupMemberDB2PB(member, 0)
|
|
|
|
} else if !(errors.Is(err, mongo.ErrNoDocuments) || errs.ErrRecordNotFound.Is(err)) {
|
|
|
|
} else if !(errors.Is(err, mongo.ErrNoDocuments) || errs.ErrRecordNotFound.Is(err)) {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -262,8 +262,8 @@ func (g *NotificationSender) fillOpUserByUserID(ctx context.Context, userID stri
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if *opUser == nil {
|
|
|
|
if *targetUser == nil {
|
|
|
|
*opUser = &sdkws.GroupMemberFullInfo{
|
|
|
|
*targetUser = &sdkws.GroupMemberFullInfo{
|
|
|
|
GroupID: groupID,
|
|
|
|
GroupID: groupID,
|
|
|
|
UserID: userID,
|
|
|
|
UserID: userID,
|
|
|
|
Nickname: user.Nickname,
|
|
|
|
Nickname: user.Nickname,
|
|
|
@ -271,11 +271,11 @@ func (g *NotificationSender) fillOpUserByUserID(ctx context.Context, userID stri
|
|
|
|
OperatorUserID: userID,
|
|
|
|
OperatorUserID: userID,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (*opUser).Nickname == "" {
|
|
|
|
if (*targetUser).Nickname == "" {
|
|
|
|
(*opUser).Nickname = user.Nickname
|
|
|
|
(*targetUser).Nickname = user.Nickname
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (*opUser).FaceURL == "" {
|
|
|
|
if (*targetUser).FaceURL == "" {
|
|
|
|
(*opUser).FaceURL = user.FaceURL
|
|
|
|
(*targetUser).FaceURL = user.FaceURL
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
@ -556,15 +556,13 @@ func (g *NotificationSender) GroupApplicationAgreeMemberEnterNotification(ctx co
|
|
|
|
InvitedUserList: users,
|
|
|
|
InvitedUserList: users,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
opUserID := mcontext.GetOpUserID(ctx)
|
|
|
|
opUserID := mcontext.GetOpUserID(ctx)
|
|
|
|
if err = g.fillOpUserByUserID(ctx, opUserID, &tips.OpUser, tips.Group.GroupID); err != nil {
|
|
|
|
if err = g.fillUserByUserID(ctx, opUserID, &tips.OpUser, tips.Group.GroupID); err != nil {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch {
|
|
|
|
if invitedOpUserID == opUserID {
|
|
|
|
case invitedOpUserID == "":
|
|
|
|
|
|
|
|
case invitedOpUserID == opUserID:
|
|
|
|
|
|
|
|
tips.InviterUser = tips.OpUser
|
|
|
|
tips.InviterUser = tips.OpUser
|
|
|
|
default:
|
|
|
|
} else {
|
|
|
|
if err = g.fillOpUserByUserID(ctx, invitedOpUserID, &tips.InviterUser, tips.Group.GroupID); err != nil {
|
|
|
|
if err = g.fillUserByUserID(ctx, invitedOpUserID, &tips.InviterUser, tips.Group.GroupID); err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|