fix: reset branch. (#1277)

* fix: to start im or chat, ZooKeeper must be started first.

* fix: msg gateway start output err info

Signed-off-by: Gordon <1432970085@qq.com>

* fix: msg gateway start output err info

Signed-off-by: Gordon <1432970085@qq.com>

* chore: package path changes

Signed-off-by: withchao <993506633@qq.com>

* fix: go mod update

Signed-off-by: Gordon <1432970085@qq.com>

* fix: token update

Signed-off-by: Gordon <1432970085@qq.com>

* chore: package path changes

Signed-off-by: withchao <993506633@qq.com>

* chore: package path changes

Signed-off-by: withchao <993506633@qq.com>

* fix: token update

Signed-off-by: Gordon <1432970085@qq.com>

* fix: token update

Signed-off-by: Gordon <1432970085@qq.com>

* fix: token update

Signed-off-by: Gordon <1432970085@qq.com>

* fix: token update

Signed-off-by: Gordon <1432970085@qq.com>

* fix: token update

Signed-off-by: Gordon <1432970085@qq.com>

* fix: token update

Signed-off-by: Gordon <1432970085@qq.com>

* fix: get all userID

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: msggateway add online status call

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* refactor: log change

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* refactor: log change

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* chore: network mode change

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* cicd: robot automated Change

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* cicd: robot automated Change

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* cicd: robot automated Change

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* feat: add api of get server time

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* feat: remove go work sum

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* cicd: robot automated Change

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix: pull message add isRead field

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: check msg-transfer script

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix:  script update

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: start don't kill old process

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* cicd: robot automated Change

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix: check component

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: pull message set isRead only message come from single.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* cicd: robot automated Change

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix: multiple gateway kick user each other.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: multiple gateway kick user each other.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: multiple gateway kick user each other.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: multiple gateway kick user each other.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: multiple gateway kick user each other.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: multiple gateway kick user each other.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* cicd: robot automated Change

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fix: multiple gateway kick user each other.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: add ex field to update group info.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* cicd: robot automated Change

* cicd: robot automated Change

* refactor: change project module name.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* refactor: change project module name.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* refactor: change project module name.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* cicd: robot automated Change

* test: for pressure test.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* test: for pressure test.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* test: for pressure test.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* test: message log.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* cicd: robot automated Change

* fxi: component check output valid info.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fxi: component check output valid info.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* test: send message test log.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* cicd: robot automated Change

* cicd: robot automated Change

* test: remove info log.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* feat: api of send message add sendTime field.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>

* fix: add callback for update user's info.

* cicd: robot automated Change

* fix: change callback command name.

* cicd: robot automated Change

* fix: single chat unread status change.

* fix: single chat unread status change.

* fix: single chat unread status change.

* fix: user status change.

* cicd: robot automated Change

* fix: user status change.

* fix: user status change.

* fix: user status change.

* cicd: robot automated Change

* fix: ws close when user logout.

* fix: remove repeat platform on online status.

* cicd: robot automated Change

* fix: api send messages for notification conversation .

* fix: api send messages for notification conversation .

* fix: api send messages for notification conversation .

* fix: api send messages for notification conversation .

* fix: api send messages for notification conversation .

* fix: api send messages for notification conversation.

* fix: api send messages for notification conversation.

* fix: api send messages for notification conversation.

* fix: api send messages for notification conversation.

* fix: api send messages for notification conversation.

* fix: api send messages for notification conversation.

* re: remove router of unsubscribeStatus.

* re: remove router of unsubscribeStatus.

* re: remove router of unsubscribeStatus.

* re: remove router of unsubscribeStatus.

* fix: reset branch

* fix: not support redis cluster. CROSSSLOT Keys in request don't hash to the same slot

* fix: update user.FaceURL do not trigger GroupMemberInfoSetNotification

* cicd: robot automated Change

* fix: api send messages for notification conversation.

* fix: api send messages for notification conversation.

---------

Signed-off-by: Gordon <1432970085@qq.com>
Signed-off-by: withchao <993506633@qq.com>
Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: withchao <993506633@qq.com>
Co-authored-by: Xinwei Xiong <3293172751NSS@gmail.com>
Co-authored-by: FGadvancer <FGadvancer@users.noreply.github.com>
Co-authored-by: withchao <withchao@users.noreply.github.com>
This commit is contained in:
Gordon
2023-10-24 20:28:22 +08:00
committed by GitHub
parent 8a13017665
commit cb0394392b
91 changed files with 781 additions and 1444 deletions
-1
View File
@@ -31,7 +31,6 @@ func NewAuth(discov discoveryregistry.SvcDiscoveryRegistry) *Auth {
panic(err)
}
client := auth.NewAuthClient(conn)
return &Auth{discov: discov, conn: conn, Client: client}
}
+1 -9
View File
@@ -60,8 +60,7 @@ func (c *ConversationRpcClient) GetSingleConversationRecvMsgOpt(ctx context.Cont
}
func (c *ConversationRpcClient) SingleChatFirstCreateConversation(ctx context.Context, recvID, sendID,
conversationID string, conversationType int32,
) error {
conversationID string, conversationType int32) error {
_, err := c.Client.CreateSingleChatConversations(ctx,
&pbconversation.CreateSingleChatConversationsReq{
RecvID: recvID, SendID: sendID, ConversationID: conversationID,
@@ -72,19 +71,16 @@ func (c *ConversationRpcClient) SingleChatFirstCreateConversation(ctx context.Co
func (c *ConversationRpcClient) GroupChatFirstCreateConversation(ctx context.Context, groupID string, userIDs []string) error {
_, err := c.Client.CreateGroupChatConversations(ctx, &pbconversation.CreateGroupChatConversationsReq{UserIDs: userIDs, GroupID: groupID})
return err
}
func (c *ConversationRpcClient) SetConversationMaxSeq(ctx context.Context, ownerUserIDs []string, conversationID string, maxSeq int64) error {
_, err := c.Client.SetConversationMaxSeq(ctx, &pbconversation.SetConversationMaxSeqReq{OwnerUserID: ownerUserIDs, ConversationID: conversationID, MaxSeq: maxSeq})
return err
}
func (c *ConversationRpcClient) SetConversations(ctx context.Context, userIDs []string, conversation *pbconversation.ConversationReq) error {
_, err := c.Client.SetConversations(ctx, &pbconversation.SetConversationsReq{UserIDs: userIDs, Conversation: conversation})
return err
}
@@ -93,7 +89,6 @@ func (c *ConversationRpcClient) GetConversationIDs(ctx context.Context, ownerUse
if err != nil {
return nil, err
}
return resp.ConversationIDs, nil
}
@@ -102,7 +97,6 @@ func (c *ConversationRpcClient) GetConversation(ctx context.Context, ownerUserID
if err != nil {
return nil, err
}
return resp.Conversation, nil
}
@@ -117,7 +111,6 @@ func (c *ConversationRpcClient) GetConversationsByConversationID(ctx context.Con
if len(resp.Conversations) == 0 {
return nil, errs.ErrRecordNotFound.Wrap(fmt.Sprintf("conversationIDs: %v not found", conversationIDs))
}
return resp.Conversations, nil
}
@@ -136,6 +129,5 @@ func (c *ConversationRpcClient) GetConversations(
if err != nil {
return nil, err
}
return resp.Conversations, nil
}
-5
View File
@@ -38,7 +38,6 @@ func NewFriend(discov discoveryregistry.SvcDiscoveryRegistry) *Friend {
panic(err)
}
client := friend.NewFriendClient(conn)
return &Friend{discov: discov, conn: conn, Client: client}
}
@@ -60,7 +59,6 @@ func (f *FriendRpcClient) GetFriendsInfo(
return nil, err
}
resp = r.FriendsInfo[0]
return
}
@@ -70,7 +68,6 @@ func (f *FriendRpcClient) IsFriend(ctx context.Context, possibleFriendUserID, us
if err != nil {
return false, err
}
return resp.InUser1Friends, nil
}
@@ -80,7 +77,6 @@ func (f *FriendRpcClient) GetFriendIDs(ctx context.Context, ownerUserID string)
if err != nil {
return nil, err
}
return resp.FriendIDs, nil
}
@@ -89,6 +85,5 @@ func (b *FriendRpcClient) IsBlocked(ctx context.Context, possibleBlackUserID, us
if err != nil {
return false, err
}
return r.InUser2Blacks, nil
}
-14
View File
@@ -42,7 +42,6 @@ func NewGroup(discov discoveryregistry.SvcDiscoveryRegistry) *Group {
panic(err)
}
client := group.NewGroupClient(conn)
return &Group{discov: discov, conn: conn, Client: client}
}
@@ -70,7 +69,6 @@ func (g *GroupRpcClient) GetGroupInfos(
return nil, errs.ErrGroupIDNotFound.Wrap(strings.Join(ids, ","))
}
}
return resp.GroupInfos, nil
}
@@ -79,7 +77,6 @@ func (g *GroupRpcClient) GetGroupInfo(ctx context.Context, groupID string) (*sdk
if err != nil {
return nil, err
}
return groups[0], nil
}
@@ -92,7 +89,6 @@ func (g *GroupRpcClient) GetGroupInfoMap(
if err != nil {
return nil, err
}
return utils.SliceToMap(groups, func(e *sdkws.GroupInfo) string {
return e.GroupID
}), nil
@@ -118,7 +114,6 @@ func (g *GroupRpcClient) GetGroupMemberInfos(
return nil, errs.ErrNotInGroupYet.Wrap(strings.Join(ids, ","))
}
}
return resp.Members, nil
}
@@ -131,7 +126,6 @@ func (g *GroupRpcClient) GetGroupMemberInfo(
if err != nil {
return nil, err
}
return members[0], nil
}
@@ -145,7 +139,6 @@ func (g *GroupRpcClient) GetGroupMemberInfoMap(
if err != nil {
return nil, err
}
return utils.SliceToMap(members, func(e *sdkws.GroupMemberFullInfo) string {
return e.UserID
}), nil
@@ -162,7 +155,6 @@ func (g *GroupRpcClient) GetOwnerAndAdminInfos(
if err != nil {
return nil, err
}
return resp.Members, nil
}
@@ -171,7 +163,6 @@ func (g *GroupRpcClient) GetOwnerInfo(ctx context.Context, groupID string) (*sdk
GroupID: groupID,
RoleLevels: []int32{constant.GroupOwner},
})
return resp.Members[0], err
}
@@ -182,7 +173,6 @@ func (g *GroupRpcClient) GetGroupMemberIDs(ctx context.Context, groupID string)
if err != nil {
return nil, err
}
return resp.UserIDs, nil
}
@@ -193,7 +183,6 @@ func (g *GroupRpcClient) GetGroupInfoCache(ctx context.Context, groupID string)
if err != nil {
return nil, err
}
return resp.GroupInfo, nil
}
@@ -209,7 +198,6 @@ func (g *GroupRpcClient) GetGroupMemberCache(
if err != nil {
return nil, err
}
return resp.Member, nil
}
@@ -218,7 +206,6 @@ func (g *GroupRpcClient) DismissGroup(ctx context.Context, groupID string) error
GroupID: groupID,
DeleteMember: true,
})
return err
}
@@ -226,6 +213,5 @@ func (g *GroupRpcClient) NotificationUserInfoUpdate(ctx context.Context, userID
_, err := g.Client.NotificationUserInfoUpdate(ctx, &group.NotificationUserInfoUpdateReq{
UserID: userID,
})
return err
}
+2 -11
View File
@@ -136,7 +136,6 @@ func NewMessage(discov discoveryregistry.SvcDiscoveryRegistry) *Message {
panic(err)
}
client := msg.NewMsgClient(conn)
return &Message{discov: discov, conn: conn, Client: client}
}
@@ -148,19 +147,16 @@ func NewMessageRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) MessageR
func (m *MessageRpcClient) SendMsg(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error) {
resp, err := m.Client.SendMsg(ctx, req)
return resp, err
}
func (m *MessageRpcClient) GetMaxSeq(ctx context.Context, req *sdkws.GetMaxSeqReq) (*sdkws.GetMaxSeqResp, error) {
resp, err := m.Client.GetMaxSeq(ctx, req)
return resp, err
}
func (m *MessageRpcClient) PullMessageBySeqList(ctx context.Context, req *sdkws.PullMessageBySeqsReq) (*sdkws.PullMessageBySeqsResp, error) {
resp, err := m.Client.PullMessageBySeqs(ctx, req)
return resp, err
}
@@ -169,7 +165,6 @@ func (m *MessageRpcClient) GetConversationMaxSeq(ctx context.Context, conversati
if err != nil {
return 0, err
}
return resp.MaxSeq, nil
}
@@ -205,7 +200,6 @@ func NewNotificationSender(opts ...NotificationSenderOptions) *NotificationSende
for _, opt := range opts {
opt(notificationSender)
}
return notificationSender
}
@@ -221,13 +215,11 @@ func WithRpcGetUserName() NotificationOptions {
}
}
func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, sendID, recvID string,
contentType, sesstionType int32, m proto.Message, opts ...NotificationOptions) (err error) {
func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, sendID, recvID string, contentType, sesstionType int32, m proto.Message, opts ...NotificationOptions) (err error) {
n := sdkws.NotificationElem{Detail: utils.StructToJsonString(m)}
content, err := json.Marshal(&n)
if err != nil {
log.ZError(ctx, "MsgClient Notification json.Marshal failed", err, "sendID",
sendID, "recvID", recvID, "contentType", contentType, "msg", m)
log.ZError(ctx, "MsgClient Notification json.Marshal failed", err, "sendID", sendID, "recvID", recvID, "contentType", contentType, "msg", m)
return err
}
notificationOpt := &notificationOpt{}
@@ -276,7 +268,6 @@ func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, s
} else {
log.ZError(ctx, "MsgClient Notification SendMsg failed", err, "req", &req)
}
return err
}
+13 -20
View File
@@ -57,7 +57,6 @@ func WithDBFunc(
for _, user := range users {
result = append(result, user)
}
return result, nil
}
s.getUsersInfo = f
@@ -76,7 +75,6 @@ func WithRpcFunc(
for _, user := range users {
result = append(result, user)
}
return result, err
}
s.getUsersInfo = f
@@ -93,7 +91,6 @@ func NewFriendNotificationSender(
for _, opt := range opts {
opt(f)
}
return f
}
@@ -109,13 +106,22 @@ func (f *FriendNotificationSender) getUsersInfoMap(
for _, user := range users {
result[user.GetUserID()] = user.(*sdkws.UserInfo)
}
return result, nil
}
func (f *FriendNotificationSender) getFromToUserNickname(
ctx context.Context,
fromUserID, toUserID string,
) (string, string, error) {
users, err := f.getUsersInfoMap(ctx, []string{fromUserID, toUserID})
if err != nil {
return "", "", nil
}
return users[fromUserID].Nickname, users[toUserID].Nickname, nil
}
func (f *FriendNotificationSender) UserInfoUpdatedNotification(ctx context.Context, changedUserID string) error {
tips := sdkws.UserInfoUpdatedTips{UserID: changedUserID}
return f.Notification(ctx, mcontext.GetOpUserID(ctx), changedUserID, constant.UserInfoUpdatedNotification, &tips)
}
@@ -127,7 +133,6 @@ func (f *FriendNotificationSender) FriendApplicationAddNotification(
FromUserID: req.FromUserID,
ToUserID: req.ToUserID,
}}
return f.Notification(ctx, req.FromUserID, req.ToUserID, constant.FriendApplicationNotification, &tips)
}
@@ -139,7 +144,6 @@ func (f *FriendNotificationSender) FriendApplicationAgreedNotification(
FromUserID: req.FromUserID,
ToUserID: req.ToUserID,
}, HandleMsg: req.HandleMsg}
return f.Notification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationApprovedNotification, &tips)
}
@@ -151,7 +155,6 @@ func (f *FriendNotificationSender) FriendApplicationRefusedNotification(
FromUserID: req.FromUserID,
ToUserID: req.ToUserID,
}, HandleMsg: req.HandleMsg}
return f.Notification(ctx, req.ToUserID, req.FromUserID, constant.FriendApplicationRejectedNotification, &tips)
}
@@ -176,7 +179,6 @@ func (f *FriendNotificationSender) FriendAddedNotification(
if err != nil {
return err
}
return f.Notification(ctx, fromUserID, toUserID, constant.FriendAddedNotification, &tips)
}
@@ -185,7 +187,6 @@ func (f *FriendNotificationSender) FriendDeletedNotification(ctx context.Context
FromUserID: req.OwnerUserID,
ToUserID: req.FriendUserID,
}}
return f.Notification(ctx, req.OwnerUserID, req.FriendUserID, constant.FriendDeletedNotification, &tips)
}
@@ -193,7 +194,6 @@ func (f *FriendNotificationSender) FriendRemarkSetNotification(ctx context.Conte
tips := sdkws.FriendInfoChangedTips{FromToUserID: &sdkws.FromToUserID{}}
tips.FromToUserID.FromUserID = fromUserID
tips.FromToUserID.ToUserID = toUserID
return f.Notification(ctx, fromUserID, toUserID, constant.FriendRemarkSetNotification, &tips)
}
@@ -201,7 +201,6 @@ func (f *FriendNotificationSender) BlackAddedNotification(ctx context.Context, r
tips := sdkws.BlackAddedTips{FromToUserID: &sdkws.FromToUserID{}}
tips.FromToUserID.FromUserID = req.OwnerUserID
tips.FromToUserID.ToUserID = req.BlackUserID
return f.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackAddedNotification, &tips)
}
@@ -210,10 +209,7 @@ func (f *FriendNotificationSender) BlackDeletedNotification(ctx context.Context,
FromUserID: req.OwnerUserID,
ToUserID: req.BlackUserID,
}}
err := f.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips)
if err != nil {
panic(err)
}
f.Notification(ctx, req.OwnerUserID, req.BlackUserID, constant.BlackDeletedNotification, &blackDeletedTips)
}
func (f *FriendNotificationSender) FriendInfoUpdatedNotification(
@@ -222,8 +218,5 @@ func (f *FriendNotificationSender) FriendInfoUpdatedNotification(
needNotifiedUserID string,
) {
tips := sdkws.UserInfoUpdatedTips{UserID: changedUserID}
err := f.Notification(ctx, mcontext.GetOpUserID(ctx), needNotifiedUserID, constant.FriendInfoUpdatedNotification, &tips)
if err != nil {
panic(err)
}
f.Notification(ctx, mcontext.GetOpUserID(ctx), needNotifiedUserID, constant.FriendInfoUpdatedNotification, &tips)
}
+50 -68
View File
@@ -60,7 +60,6 @@ func (g *GroupNotificationSender) getUser(ctx context.Context, userID string) (*
if len(users) == 0 {
return nil, errs.ErrUserIDNotFound.Wrap(fmt.Sprintf("user %s not found", userID))
}
return &sdkws.PublicUserInfo{
UserID: users[0].GetUserID(),
Nickname: users[0].GetNickname(),
@@ -69,23 +68,6 @@ func (g *GroupNotificationSender) getUser(ctx context.Context, userID string) (*
}, nil
}
func (g *GroupNotificationSender) groupMemberDB2PB(member *relation.GroupMemberModel, appMangerLevel int32) *sdkws.GroupMemberFullInfo {
return &sdkws.GroupMemberFullInfo{
GroupID: member.GroupID,
UserID: member.UserID,
RoleLevel: member.RoleLevel,
JoinTime: member.JoinTime.UnixMilli(),
Nickname: member.Nickname,
FaceURL: member.FaceURL,
AppMangerLevel: appMangerLevel,
JoinSource: member.JoinSource,
OperatorUserID: member.OperatorUserID,
Ex: member.Ex,
MuteEndTime: member.MuteEndTime.UnixMilli(),
InviterUserID: member.InviterUserID,
}
}
func (g *GroupNotificationSender) getGroupInfo(ctx context.Context, groupID string) (*sdkws.GroupInfo, error) {
gm, err := g.db.TakeGroup(ctx, groupID)
if err != nil {
@@ -99,7 +81,6 @@ func (g *GroupNotificationSender) getGroupInfo(ctx context.Context, groupID stri
if err != nil {
return nil, err
}
return &sdkws.GroupInfo{
GroupID: gm.GroupID,
GroupName: gm.GroupName,
@@ -167,7 +148,6 @@ func (g *GroupNotificationSender) getGroupMemberMap(ctx context.Context, groupID
for i, member := range members {
m[member.UserID] = members[i]
}
return m, nil
}
@@ -179,7 +159,6 @@ func (g *GroupNotificationSender) getGroupMember(ctx context.Context, groupID st
if len(members) == 0 {
return nil, errs.ErrInternalServer.Wrap(fmt.Sprintf("group %s member %s not found", groupID, userID))
}
return members[0], nil
}
@@ -189,10 +168,48 @@ func (g *GroupNotificationSender) getGroupOwnerAndAdminUserID(ctx context.Contex
return nil, err
}
fn := func(e *relation.GroupMemberModel) string { return e.UserID }
return utils.Slice(members, fn), nil
}
func (g *GroupNotificationSender) groupDB2PB(group *relation.GroupModel, ownerUserID string, memberCount uint32) *sdkws.GroupInfo {
return &sdkws.GroupInfo{
GroupID: group.GroupID,
GroupName: group.GroupName,
Notification: group.Notification,
Introduction: group.Introduction,
FaceURL: group.FaceURL,
OwnerUserID: ownerUserID,
CreateTime: group.CreateTime.UnixMilli(),
MemberCount: memberCount,
Ex: group.Ex,
Status: group.Status,
CreatorUserID: group.CreatorUserID,
GroupType: group.GroupType,
NeedVerification: group.NeedVerification,
LookMemberInfo: group.LookMemberInfo,
ApplyMemberFriend: group.ApplyMemberFriend,
NotificationUpdateTime: group.NotificationUpdateTime.UnixMilli(),
NotificationUserID: group.NotificationUserID,
}
}
func (g *GroupNotificationSender) groupMemberDB2PB(member *relation.GroupMemberModel, appMangerLevel int32) *sdkws.GroupMemberFullInfo {
return &sdkws.GroupMemberFullInfo{
GroupID: member.GroupID,
UserID: member.UserID,
RoleLevel: member.RoleLevel,
JoinTime: member.JoinTime.UnixMilli(),
Nickname: member.Nickname,
FaceURL: member.FaceURL,
AppMangerLevel: appMangerLevel,
JoinSource: member.JoinSource,
OperatorUserID: member.OperatorUserID,
Ex: member.Ex,
MuteEndTime: member.MuteEndTime.UnixMilli(),
InviterUserID: member.InviterUserID,
}
}
func (g *GroupNotificationSender) getUsersInfoMap(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error) {
users, err := g.getUsersInfo(ctx, userIDs)
if err != nil {
@@ -202,7 +219,6 @@ func (g *GroupNotificationSender) getUsersInfoMap(ctx context.Context, userIDs [
for _, user := range users {
result[user.GetUserID()] = user.(*sdkws.UserInfo)
}
return result, nil
}
@@ -220,31 +236,21 @@ func (g *GroupNotificationSender) fillOpUser(ctx context.Context, opUser **sdkws
return nil
}
userID := mcontext.GetOpUserID(ctx)
getOpUser := func(g *GroupNotificationSender, groupID, userID string) (opUser *sdkws.GroupMemberFullInfo, err error) {
if groupID != "" {
if authverify.IsManagerUserID(userID) {
opUser = &sdkws.GroupMemberFullInfo{
*opUser = &sdkws.GroupMemberFullInfo{
GroupID: groupID,
UserID: userID,
RoleLevel: constant.GroupAdmin,
AppMangerLevel: constant.AppAdmin,
}
return opUser, nil
}
var member *relation.GroupMemberModel
member, err = g.db.TakeGroupMember(ctx, groupID, userID)
if err == nil {
opUser = g.groupMemberDB2PB(member, 0)
} else if !errs.ErrRecordNotFound.Is(err) {
return nil, err
}
return opUser, nil
}
if groupID != "" {
*opUser, err = getOpUser(g, groupID, userID)
if err != nil {
return err
} else {
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)
@@ -267,7 +273,6 @@ func (g *GroupNotificationSender) fillOpUser(ctx context.Context, opUser **sdkws
(*opUser).FaceURL = user.FaceURL
}
}
return nil
}
@@ -281,7 +286,6 @@ func (g *GroupNotificationSender) GroupCreatedNotification(ctx context.Context,
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)
}
@@ -295,7 +299,6 @@ func (g *GroupNotificationSender) GroupInfoSetNotification(ctx context.Context,
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, rpcclient.WithRpcGetUserName())
}
@@ -309,7 +312,6 @@ func (g *GroupNotificationSender) GroupInfoSetNameNotification(ctx context.Conte
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)
}
@@ -323,7 +325,6 @@ func (g *GroupNotificationSender) GroupInfoSetAnnouncementNotification(ctx conte
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, rpcclient.WithRpcGetUserName())
}
@@ -354,7 +355,6 @@ func (g *GroupNotificationSender) JoinGroupApplicationNotification(ctx context.C
log.ZError(ctx, "JoinGroupApplicationNotification failed", err, "group", req.GroupID, "userID", userID)
}
}
return nil
}
@@ -370,7 +370,6 @@ func (g *GroupNotificationSender) MemberQuitNotification(ctx context.Context, me
return err
}
tips := &sdkws.MemberQuitTips{Group: group, QuitUser: member}
return g.Notification(ctx, mcontext.GetOpUserID(ctx), member.GroupID, constant.MemberQuitNotification, tips)
}
@@ -390,8 +389,7 @@ func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx conte
return err
}
tips := &sdkws.GroupApplicationAcceptedTips{Group: group, HandleMsg: req.HandledMsg, ReceiverAs: 1}
err = g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID)
if err != nil {
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
for _, userID := range append(userIDs, mcontext.GetOpUserID(ctx)) {
@@ -400,7 +398,6 @@ func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx conte
log.ZError(ctx, "failed", err)
}
}
return nil
}
@@ -420,8 +417,7 @@ func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx conte
return err
}
tips := &sdkws.GroupApplicationRejectedTips{Group: group, HandleMsg: req.HandledMsg}
err = g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID)
if err != nil {
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
return err
}
for _, userID := range append(userIDs, mcontext.GetOpUserID(ctx)) {
@@ -430,7 +426,6 @@ func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx conte
log.ZError(ctx, "failed", err)
}
}
return nil
}
@@ -454,7 +449,6 @@ func (g *GroupNotificationSender) GroupOwnerTransferredNotification(ctx context.
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)
}
@@ -468,7 +462,6 @@ func (g *GroupNotificationSender) MemberKickedNotification(ctx context.Context,
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)
}
@@ -494,7 +487,6 @@ func (g *GroupNotificationSender) MemberInvitedNotification(ctx context.Context,
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)
}
@@ -514,7 +506,6 @@ func (g *GroupNotificationSender) MemberEnterNotification(ctx context.Context, g
return err
}
tips := &sdkws.MemberEnterTips{Group: group, EntrantUser: user}
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.MemberEnterNotification, tips)
}
@@ -528,7 +519,6 @@ func (g *GroupNotificationSender) GroupDismissedNotification(ctx context.Context
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)
}
@@ -554,7 +544,6 @@ func (g *GroupNotificationSender) GroupMemberMutedNotification(ctx context.Conte
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)
}
@@ -577,7 +566,6 @@ func (g *GroupNotificationSender) GroupMemberCancelMutedNotification(ctx context
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)
}
@@ -603,7 +591,6 @@ func (g *GroupNotificationSender) GroupMutedNotification(ctx context.Context, gr
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)
}
@@ -629,7 +616,6 @@ func (g *GroupNotificationSender) GroupCancelMutedNotification(ctx context.Conte
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)
}
@@ -652,7 +638,6 @@ func (g *GroupNotificationSender) GroupMemberInfoSetNotification(ctx context.Con
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)
}
@@ -675,7 +660,6 @@ func (g *GroupNotificationSender) GroupMemberSetToAdminNotification(ctx context.
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)
}
@@ -698,7 +682,6 @@ func (g *GroupNotificationSender) GroupMemberSetToOrdinaryUserNotification(ctx c
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)
}
@@ -710,6 +693,5 @@ func (g *GroupNotificationSender) SuperGroupNotification(ctx context.Context, se
}
}()
err = g.Notification(ctx, sendID, recvID, constant.SuperGroupUpdateNotification, nil)
return err
}
-2
View File
@@ -37,7 +37,6 @@ func (m *MsgNotificationSender) UserDeleteMsgsNotification(ctx context.Context,
ConversationID: conversationID,
Seqs: seqs,
}
return m.Notification(ctx, userID, userID, constant.DeleteMsgsNotification, &tips)
}
@@ -48,6 +47,5 @@ func (m *MsgNotificationSender) MarkAsReadNotification(ctx context.Context, conv
Seqs: seqs,
HasReadSeq: hasReadSeq,
}
return m.NotificationWithSesstionType(ctx, sendID, recvID, constant.HasReadReceipt, sesstionType, tips)
}
+24 -28
View File
@@ -52,7 +52,6 @@ func WithUserFunc(
for _, user := range users {
result = append(result, user)
}
return result, nil
}
u.getUsersInfo = f
@@ -69,37 +68,34 @@ func NewUserNotificationSender(
for _, opt := range opts {
opt(f)
}
return f
}
// func (u *UserNotificationSender) getUsersInfoMap(
// ctx context.Context,
// userIDs []string,
// ) (map[string]*sdkws.UserInfo, error) {
// users, err := u.getUsersInfo(ctx, userIDs)
// if err != nil {
// return nil, err
// }
// result := make(map[string]*sdkws.UserInfo)
// for _, user := range users {
// result[user.GetUserID()] = user.(*sdkws.UserInfo)
// }
func (u *UserNotificationSender) getUsersInfoMap(
ctx context.Context,
userIDs []string,
) (map[string]*sdkws.UserInfo, error) {
users, err := u.getUsersInfo(ctx, userIDs)
if err != nil {
return nil, err
}
result := make(map[string]*sdkws.UserInfo)
for _, user := range users {
result[user.GetUserID()] = user.(*sdkws.UserInfo)
}
return result, nil
}
// return result, nil
// }
// func (u *UserNotificationSender) getFromToUserNickname(
// ctx context.Context,
// fromUserID, toUserID string,
// ) (string, string, error) {
// users, err := u.getUsersInfoMap(ctx, []string{fromUserID, toUserID})
// if err != nil {
// return "", "", err
// }
// return users[fromUserID].Nickname, users[toUserID].Nickname, nil
// }
func (u *UserNotificationSender) getFromToUserNickname(
ctx context.Context,
fromUserID, toUserID string,
) (string, string, error) {
users, err := u.getUsersInfoMap(ctx, []string{fromUserID, toUserID})
if err != nil {
return "", "", nil
}
return users[fromUserID].Nickname, users[toUserID].Nickname, nil
}
func (u *UserNotificationSender) UserStatusChangeNotification(
ctx context.Context,
-1
View File
@@ -36,7 +36,6 @@ func NewPush(discov discoveryregistry.SvcDiscoveryRegistry) *Push {
if err != nil {
panic(err)
}
return &Push{
discov: discov,
conn: conn,
+4 -5
View File
@@ -42,13 +42,14 @@ func NewThird(discov discoveryregistry.SvcDiscoveryRegistry) *Third {
panic(err)
}
client := third.NewThirdClient(conn)
minioClient, _ := minioInit()
minioClient, err := minioInit()
return &Third{discov: discov, Client: client, conn: conn, MinioClient: minioClient}
}
func minioInit() (*minio.Client, error) {
initUrl := config.Config.Object.Minio.Endpoint
minioClient := &minio.Client{}
var initUrl string
initUrl = config.Config.Object.Minio.Endpoint
minioUrl, err := url.Parse(initUrl)
if err != nil {
return nil, err
@@ -62,11 +63,9 @@ func minioInit() (*minio.Client, error) {
} else if minioUrl.Scheme == "https" {
opts.Secure = true
}
var minioClient *minio.Client
minioClient, err = minio.New(minioUrl.Host, opts)
if err != nil {
return nil, err
}
return minioClient, nil
}
-12
View File
@@ -45,7 +45,6 @@ func NewUser(discov discoveryregistry.SvcDiscoveryRegistry) *User {
panic(err)
}
client := user.NewUserClient(conn)
return &User{Discov: discov, Client: client, conn: conn}
}
@@ -55,7 +54,6 @@ type UserRpcClient User
// NewUserRpcClientByUser initializes a UserRpcClient based on the provided User instance.
func NewUserRpcClientByUser(user *User) *UserRpcClient {
rpc := UserRpcClient(*user)
return &rpc
}
@@ -77,7 +75,6 @@ func (u *UserRpcClient) GetUsersInfo(ctx context.Context, userIDs []string) ([]*
})); len(ids) > 0 {
return nil, errs.ErrUserIDNotFound.Wrap(strings.Join(ids, ","))
}
return resp.UsersInfo, nil
}
@@ -87,7 +84,6 @@ func (u *UserRpcClient) GetUserInfo(ctx context.Context, userID string) (*sdkws.
if err != nil {
return nil, err
}
return users[0], nil
}
@@ -97,7 +93,6 @@ func (u *UserRpcClient) GetUsersInfoMap(ctx context.Context, userIDs []string) (
if err != nil {
return nil, err
}
return utils.SliceToMap(users, func(e *sdkws.UserInfo) string {
return e.UserID
}), nil
@@ -113,7 +108,6 @@ func (u *UserRpcClient) GetPublicUserInfos(
if err != nil {
return nil, err
}
return utils.Slice(users, func(e *sdkws.UserInfo) *sdkws.PublicUserInfo {
return &sdkws.PublicUserInfo{
UserID: e.UserID,
@@ -130,7 +124,6 @@ func (u *UserRpcClient) GetPublicUserInfo(ctx context.Context, userID string) (*
if err != nil {
return nil, err
}
return users[0], nil
}
@@ -144,7 +137,6 @@ func (u *UserRpcClient) GetPublicUserInfoMap(
if err != nil {
return nil, err
}
return utils.SliceToMap(users, func(e *sdkws.PublicUserInfo) string {
return e.UserID
}), nil
@@ -158,7 +150,6 @@ func (u *UserRpcClient) GetUserGlobalMsgRecvOpt(ctx context.Context, userID stri
if err != nil {
return 0, err
}
return resp.GlobalRecvMsgOpt, nil
}
@@ -168,7 +159,6 @@ func (u *UserRpcClient) Access(ctx context.Context, ownerUserID string) error {
if err != nil {
return err
}
return authverify.CheckAccessV3(ctx, ownerUserID)
}
@@ -178,7 +168,6 @@ func (u *UserRpcClient) GetAllUserIDs(ctx context.Context, pageNumber, showNumbe
if err != nil {
return nil, err
}
return resp.UserIDs, nil
}
@@ -188,6 +177,5 @@ func (u *UserRpcClient) SetUserStatus(ctx context.Context, userID string, status
UserID: userID,
Status: status, PlatformID: int32(platformID),
})
return err
}