mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
fix: notification pull
This commit is contained in:
parent
405a9b75b0
commit
1f5259d36a
@ -171,7 +171,7 @@ func (m *msgServer) PullMessageBySeqs(ctx context.Context, req *sdkws.PullMessag
|
||||
log.ZWarn(ctx, "GetMsgBySeqs error", err, "conversationID", seq.ConversationID, "seq", seq)
|
||||
continue
|
||||
}
|
||||
resp.Msgs[seq.ConversationID] = &sdkws.PullMsgs{Msgs: notificationMsgs}
|
||||
resp.NotificationMsgs[seq.ConversationID] = &sdkws.PullMsgs{Msgs: notificationMsgs}
|
||||
}
|
||||
}
|
||||
return resp, nil
|
||||
|
@ -2,12 +2,8 @@ package rpcclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
relationTb "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
||||
sdkws "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
@ -15,7 +11,6 @@ type MetaClient struct {
|
||||
// contains filtered or unexported fields
|
||||
client discoveryregistry.SvcDiscoveryRegistry
|
||||
rpcRegisterName string
|
||||
getUsersInfo func(ctx context.Context, userIDs []string) ([]CommonUser, error)
|
||||
}
|
||||
|
||||
func NewMetaClient(client discoveryregistry.SvcDiscoveryRegistry, rpcRegisterName string, opts ...MetaClientOptions) *MetaClient {
|
||||
@ -31,49 +26,6 @@ func NewMetaClient(client discoveryregistry.SvcDiscoveryRegistry, rpcRegisterNam
|
||||
|
||||
type MetaClientOptions func(*MetaClient)
|
||||
|
||||
func WithDBFunc(fn func(ctx context.Context, userIDs []string) (users []*relationTb.UserModel, err error)) MetaClientOptions {
|
||||
return func(s *MetaClient) {
|
||||
f := func(ctx context.Context, userIDs []string) (result []CommonUser, err error) {
|
||||
users, err := fn(ctx, userIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, user := range users {
|
||||
result = append(result, user)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
s.getUsersInfo = f
|
||||
}
|
||||
}
|
||||
|
||||
func WithRpcFunc(fn func(ctx context.Context, userIDs []string) ([]*sdkws.UserInfo, error)) MetaClientOptions {
|
||||
return func(s *MetaClient) {
|
||||
f := func(ctx context.Context, userIDs []string) (result []CommonUser, err error) {
|
||||
users, err := fn(ctx, userIDs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, user := range users {
|
||||
result = append(result, user)
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
s.getUsersInfo = f
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MetaClient) getFaceURLAndName(userID string) (faceURL, nickname string, err error) {
|
||||
users, err := m.getUsersInfo(context.Background(), []string{userID})
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
if len(users) == 0 {
|
||||
return "", "", errs.ErrRecordNotFound.Wrap(fmt.Sprintf("notification user %s not found", userID))
|
||||
}
|
||||
return users[0].GetFaceURL(), users[0].GetNickname(), nil
|
||||
}
|
||||
|
||||
func (m *MetaClient) getConn(ctx context.Context) (*grpc.ClientConn, error) {
|
||||
return m.client.GetConn(ctx, m.rpcRegisterName)
|
||||
}
|
||||
|
@ -160,7 +160,6 @@ func (c *MsgClient) Notification(ctx context.Context, sendID, recvID string, con
|
||||
}
|
||||
msg.CreateTime = utils.GetCurrentTimestampByMill()
|
||||
msg.ClientMsgID = utils.GetMsgID(sendID)
|
||||
// msg.Options = make(map[string]bool, 7)
|
||||
options := config.GetOptionsByNotification(c.contentTypeConf[contentType])
|
||||
options = utils.WithOptions(options, opts...)
|
||||
msg.Options = options
|
||||
|
Loading…
x
Reference in New Issue
Block a user