fix: changing naming irregularities under pkg and internal packages (#520)

pull/656/head
BanTanger 2 years ago
parent 1b5eb4a5c0
commit bbac1d9d6b

@ -69,7 +69,7 @@ cert_key =
# Unix socket path
socket = /tmp/grafana.sock
# CDN Url
# CDN URL
cdn_url =
# Sets the maximum time in minutes before timing out read of an incoming request and closing idle connections.

@ -27,7 +27,7 @@ func main() {
if err := pushCmd.Exec(); err != nil {
panic(err.Error())
}
if err := pushCmd.StartSvr(config.Config.RpcRegisterName.OpenImPushName, push.Start); err != nil {
if err := pushCmd.StartSvr(config.Config.RPCRegisterName.OpenImPushName, push.Start); err != nil {
panic(err.Error())
}
}

@ -27,7 +27,7 @@ func main() {
if err := authCmd.Exec(); err != nil {
panic(err.Error())
}
if err := authCmd.StartSvr(config.Config.RpcRegisterName.OpenImAuthName, auth.Start); err != nil {
if err := authCmd.StartSvr(config.Config.RPCRegisterName.OpenImAuthName, auth.Start); err != nil {
panic(err.Error())
}
}

@ -27,7 +27,7 @@ func main() {
if err := rpcCmd.Exec(); err != nil {
panic(err.Error())
}
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImConversationName, conversation.Start); err != nil {
if err := rpcCmd.StartSvr(config.Config.RPCRegisterName.OpenImConversationName, conversation.Start); err != nil {
panic(err.Error())
}
}

@ -27,7 +27,7 @@ func main() {
if err := rpcCmd.Exec(); err != nil {
panic(err.Error())
}
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImFriendName, friend.Start); err != nil {
if err := rpcCmd.StartSvr(config.Config.RPCRegisterName.OpenImFriendName, friend.Start); err != nil {
panic(err.Error())
}
}

@ -27,7 +27,7 @@ func main() {
if err := rpcCmd.Exec(); err != nil {
panic(err.Error())
}
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImGroupName, group.Start); err != nil {
if err := rpcCmd.StartSvr(config.Config.RPCRegisterName.OpenImGroupName, group.Start); err != nil {
panic(err.Error())
}
}

@ -27,7 +27,7 @@ func main() {
if err := rpcCmd.Exec(); err != nil {
panic(err.Error())
}
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImMsgName, msg.Start); err != nil {
if err := rpcCmd.StartSvr(config.Config.RPCRegisterName.OpenImMsgName, msg.Start); err != nil {
panic(err.Error())
}
}

@ -27,7 +27,7 @@ func main() {
if err := rpcCmd.Exec(); err != nil {
panic(err.Error())
}
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImThirdName, third.Start); err != nil {
if err := rpcCmd.StartSvr(config.Config.RPCRegisterName.OpenImThirdName, third.Start); err != nil {
panic(err.Error())
}
}

@ -27,7 +27,7 @@ func main() {
if err := rpcCmd.Exec(); err != nil {
panic(err.Error())
}
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImUserName, user.Start); err != nil {
if err := rpcCmd.StartSvr(config.Config.RPCRegisterName.OpenImUserName, user.Start); err != nil {
panic(err.Error())
}
}

@ -169,7 +169,7 @@ func (m *MessageApi) SendMessage(c *gin.Context) {
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
return
}
if !tokenverify.IsAppManagerUid(c) {
if !tokenverify.IsAppManagerUID(c) {
apiresp.GinError(c, errs.ErrNoPermission.Wrap("only app manager can send message"))
return
}

@ -43,9 +43,9 @@ func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.Unive
u := NewUserApi(discov)
m := NewMessageApi(discov)
if config.Config.Prometheus.Enable {
prome.NewApiRequestCounter()
prome.NewApiRequestFailedCounter()
prome.NewApiRequestSuccessCounter()
prome.NewAPIRequestCounter()
prome.NewAPIRequestFailedCounter()
prome.NewAPIRequestSuccessCounter()
r.Use(prome.PrometheusMiddleware)
r.GET("/metrics", prome.PrometheusHandler())
}
@ -62,7 +62,7 @@ func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.Unive
userRouterGroup.POST("/get_users_online_status", ParseToken, u.GetUsersOnlineStatus)
userRouterGroup.POST("/get_users_online_token_detail", ParseToken, u.GetUsersOnlineTokenDetail)
}
//friend routing group
// friend routing group
friendRouterGroup := r.Group("/friend", ParseToken)
{
f := NewFriendApi(discov)
@ -109,7 +109,7 @@ func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.Unive
superGroupRouterGroup.POST("/get_joined_group_list", g.GetJoinedSuperGroupList)
superGroupRouterGroup.POST("/get_groups_info", g.GetSuperGroupsInfo)
}
//certificate
// certificate
authRouterGroup := r.Group("/auth")
{
a := NewAuthApi(discov)
@ -117,7 +117,7 @@ func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.Unive
authRouterGroup.POST("/parse_token", a.ParseToken)
authRouterGroup.POST("/force_logout", ParseToken, a.ForceLogout)
}
//Third service
// Third service
thirdGroup := r.Group("/third", ParseToken)
{
t := NewThirdApi(discov)
@ -134,7 +134,7 @@ func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.Unive
objectGroup.POST("/access_url", t.AccessURL)
objectGroup.GET("/*name", t.ObjectRedirect)
}
//Message
// Message
msgGroup := r.Group("/msg", ParseToken)
{
msgGroup.POST("/newest_seq", m.GetSeq)
@ -155,7 +155,7 @@ func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.Unive
msgGroup.POST("/batch_send_msg", m.ManagementBatchSendMsg)
msgGroup.POST("/check_msg_is_send_success", m.CheckMsgIsSendSuccess)
}
//Conversation
// Conversation
conversationGroup := r.Group("/conversation", ParseToken)
{
c := NewConversationApi(discov)

@ -69,7 +69,7 @@ func (u *UserApi) GetUsersOnlineStatus(c *gin.Context) {
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
return
}
conns, err := u.Discov.GetConns(c, config.Config.RpcRegisterName.OpenImMessageGatewayName)
conns, err := u.Discov.GetConns(c, config.Config.RPCRegisterName.OpenImMessageGatewayName)
if err != nil {
apiresp.GinError(c, err)
return
@ -79,7 +79,7 @@ func (u *UserApi) GetUsersOnlineStatus(c *gin.Context) {
var respResult []*msggateway.GetUsersOnlineStatusResp_SuccessResult
flag := false
//Online push message
// Online push message
for _, v := range conns {
msgClient := msggateway.NewMsgGatewayClient(v)
reply, err := msgClient.GetUsersOnlineStatus(c, &req)
@ -127,12 +127,12 @@ func (u *UserApi) GetUsersOnlineTokenDetail(c *gin.Context) {
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
return
}
conns, err := u.Discov.GetConns(c, config.Config.RpcRegisterName.OpenImMessageGatewayName)
conns, err := u.Discov.GetConns(c, config.Config.RPCRegisterName.OpenImMessageGatewayName)
if err != nil {
apiresp.GinError(c, err)
return
}
//Online push message
// Online push message
for _, v := range conns {
msgClient := msggateway.NewMsgGatewayClient(v)
reply, err := msgClient.GetUsersOnlineStatus(c, &req)

@ -26,7 +26,7 @@ import (
)
func url() string {
return config.Config.Callback.CallbackUrl
return config.Config.Callback.CallbackURL
}
func CallbackUserOnline(ctx context.Context, userID string, platformID int, isAppBackground bool, connID string) error {
@ -114,15 +114,15 @@ func CallbackUserKickOff(ctx context.Context, userID string, platformID int) err
// ConnID: connID,
// }
// callbackUserOnlineResp := &cbApi.CallbackUserOnlineResp{CommonCallbackResp: &callbackResp}
// if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, constant.CallbackUserOnlineCommand,
// if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackURL, constant.CallbackUserOnlineCommand,
// callbackUserOnlineReq, callbackUserOnlineResp, config.Config.Callback.CallbackUserOnline.CallbackTimeOut); err != nil
// {
// callbackResp.ErrCode = http2.StatusInternalServerError
// callbackResp.ErrMsg = err.Error()
// }
// return callbackResp
//}
//func callbackUserOffline(operationID, userID string, platformID int, connID string) cbApi.CommonCallbackResp {
// }
// func callbackUserOffline(operationID, userID string, platformID int, connID string) cbApi.CommonCallbackResp {
// callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
// if !config.Config.Callback.CallbackUserOffline.Enable {
// return callbackResp
@ -141,15 +141,15 @@ func CallbackUserKickOff(ctx context.Context, userID string, platformID int) err
// ConnID: connID,
// }
// callbackUserOfflineResp := &cbApi.CallbackUserOfflineResp{CommonCallbackResp: &callbackResp}
// if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, constant.CallbackUserOfflineCommand,
// if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackURL, constant.CallbackUserOfflineCommand,
// callbackOfflineReq, callbackUserOfflineResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil
// {
// callbackResp.ErrCode = http2.StatusInternalServerError
// callbackResp.ErrMsg = err.Error()
// }
// return callbackResp
//}
//func callbackUserKickOff(operationID string, userID string, platformID int) cbApi.CommonCallbackResp {
// }
// func callbackUserKickOff(operationID string, userID string, platformID int) cbApi.CommonCallbackResp {
// callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
// if !config.Config.Callback.CallbackUserKickOff.Enable {
// return callbackResp
@ -167,11 +167,11 @@ func CallbackUserKickOff(ctx context.Context, userID string, platformID int) err
// Seq: int(time.Now().UnixNano() / 1e6),
// }
// callbackUserKickOffResp := &cbApi.CallbackUserKickOffResp{CommonCallbackResp: &callbackResp}
// if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, constant.CallbackUserKickOffCommand,
// if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackURL, constant.CallbackUserKickOffCommand,
// callbackUserKickOffReq, callbackUserKickOffResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err !=
// nil {
// callbackResp.ErrCode = http2.StatusInternalServerError
// callbackResp.ErrMsg = err.Error()
// }
// return callbackResp
//}
// }

@ -116,7 +116,7 @@ func (c *Client) readMessage() {
return
}
log.ZDebug(c.ctx, "readMessage", "messageType", messageType)
if c.closed == true { //连接刚置位已经关闭,但是协程还没退出的场景
if c.closed == true { // 连接刚置位已经关闭,但是协程还没退出的场景
c.closedErr = ErrConnClosed
return
}
@ -191,7 +191,7 @@ func (c *Client) setAppBackgroundStatus(ctx context.Context, req Req) ([]byte, e
return nil, messageErr
}
c.IsBackground = isBackground
//todo callback
// todo callback
return resp, nil
}
@ -254,8 +254,6 @@ func (c *Client) writeBinaryMsg(resp Resp) error {
if c.closed == true {
return nil
}
encodedBuf := bufferPool.Get().([]byte)
resultBuf := bufferPool.Get().([]byte)
encodedBuf, err := c.longConnServer.Encode(resp)
if err != nil {
return utils.Wrap(err, "")
@ -263,7 +261,7 @@ func (c *Client) writeBinaryMsg(resp Resp) error {
_ = c.conn.SetWriteDeadline(writeWait)
if c.IsCompress {
var compressErr error
resultBuf, compressErr = c.longConnServer.Compress(encodedBuf)
resultBuf, compressErr := c.longConnServer.Compress(encodedBuf)
if compressErr != nil {
return utils.Wrap(compressErr, "")
}

@ -48,7 +48,7 @@ func (s *Server) InitServer(client discoveryregistry.SvcDiscoveryRegistry, serve
func (s *Server) Start() error {
return startrpc.Start(
s.rpcPort,
config.Config.RpcRegisterName.OpenImMessageGatewayName,
config.Config.RPCRegisterName.OpenImMessageGatewayName,
s.prometheusPort,
s.InitServer,
)
@ -84,7 +84,7 @@ func (s *Server) GetUsersOnlineStatus(
ctx context.Context,
req *msggateway.GetUsersOnlineStatusReq,
) (*msggateway.GetUsersOnlineStatusResp, error) {
if !tokenverify.IsAppManagerUid(ctx) {
if !tokenverify.IsAppManagerUID(ctx) {
return nil, errs.ErrNoPermission.Wrap("only app manager")
}
var resp msggateway.GetUsersOnlineStatusResp
@ -197,6 +197,6 @@ func (s *Server) MultiTerminalLoginCheck(
ctx context.Context,
req *msggateway.MultiTerminalLoginCheckReq,
) (*msggateway.MultiTerminalLoginCheckResp, error) {
//TODO implement me
// TODO implement me
panic("implement me")
}

@ -67,15 +67,15 @@ type MessageHandler interface {
var _ MessageHandler = (*GrpcHandler)(nil)
type GrpcHandler struct {
msgRpcClient *rpcclient.MessageRpcClient
pushClient *rpcclient.PushRpcClient
msgRPCClient *rpcclient.MessageRpcClient
pushClient *rpcclient.PushRPCClient
validate *validator.Validate
}
func NewGrpcHandler(validate *validator.Validate, client discoveryregistry.SvcDiscoveryRegistry) *GrpcHandler {
msgRpcClient := rpcclient.NewMessageRpcClient(client)
pushRpcClient := rpcclient.NewPushRpcClient(client)
return &GrpcHandler{msgRpcClient: &msgRpcClient,
msgRPCClient := rpcclient.NewMessageRpcClient(client)
pushRpcClient := rpcclient.NewPushRPCClient(client)
return &GrpcHandler{msgRPCClient: &msgRPCClient,
pushClient: &pushRpcClient, validate: validate}
}
@ -87,7 +87,7 @@ func (g GrpcHandler) GetSeq(context context.Context, data Req) ([]byte, error) {
if err := g.validate.Struct(&req); err != nil {
return nil, err
}
resp, err := g.msgRpcClient.GetMaxSeq(context, &req)
resp, err := g.msgRPCClient.GetMaxSeq(context, &req)
if err != nil {
return nil, err
}
@ -107,7 +107,7 @@ func (g GrpcHandler) SendMessage(context context.Context, data Req) ([]byte, err
return nil, err
}
req := msg.SendMsgReq{MsgData: &msgData}
resp, err := g.msgRpcClient.SendMsg(context, &req)
resp, err := g.msgRPCClient.SendMsg(context, &req)
if err != nil {
return nil, err
}
@ -119,7 +119,7 @@ func (g GrpcHandler) SendMessage(context context.Context, data Req) ([]byte, err
}
func (g GrpcHandler) SendSignalMessage(context context.Context, data Req) ([]byte, error) {
resp, err := g.msgRpcClient.SendMsg(context, nil)
resp, err := g.msgRPCClient.SendMsg(context, nil)
if err != nil {
return nil, err
}
@ -138,7 +138,7 @@ func (g GrpcHandler) PullMessageBySeqList(context context.Context, data Req) ([]
if err := g.validate.Struct(data); err != nil {
return nil, err
}
resp, err := g.msgRpcClient.PullMessageBySeqList(context, &req)
resp, err := g.msgRPCClient.PullMessageBySeqList(context, &req)
if err != nil {
return nil, err
}
@ -194,4 +194,4 @@ func (g GrpcHandler) SetUserDeviceBackground(_ context.Context, data Req) ([]byt
// return nil, err
// }
// return c, nil
//}
// }

@ -150,7 +150,7 @@ func (ws *WsServer) Run() error {
}()
http.HandleFunc("/", ws.wsHandler)
// http.HandleFunc("/metrics", func(w http.ResponseWriter, r *http.Request) {})
return http.ListenAndServe(":"+utils.IntToString(ws.port), nil) //Start listening
return http.ListenAndServe(":"+utils.IntToString(ws.port), nil) // Start listening
}
func (ws *WsServer) registerClient(client *Client) {
@ -176,7 +176,7 @@ func (ws *WsServer) registerClient(client *Client) {
log.ZDebug(client.ctx, "user exist", "userID", client.UserID, "platformID", client.PlatformID)
if clientOK {
ws.clients.Set(client.UserID, client)
//已经有同平台的连接存在
// 已经有同平台的连接存在
log.ZInfo(client.ctx, "repeat login", "userID", client.UserID, "platformID", client.PlatformID, "old remote addr", getRemoteAdders(oldClients))
atomic.AddInt64(&ws.onlineUserConnNum, 1)
} else {
@ -269,11 +269,11 @@ func (ws *WsServer) multiTerminalLoginChecker(info *kickHandler) {
}
}
log.ZDebug(info.newClient.ctx, "set token map is ", "token map", m, "userID", info.newClient.UserID)
err = ws.cache.SetTokenMapByUidPid(info.newClient.ctx, info.newClient.UserID, info.newClient.PlatformID, m)
err = ws.cache.SetTokenMapByUIDPid(info.newClient.ctx, info.newClient.UserID, info.newClient.PlatformID, m)
if err != nil {
log.ZWarn(
info.newClient.ctx,
"SetTokenMapByUidPid err",
"SetTokenMapByUIDPid err",
err,
"userID",
info.newClient.UserID,

@ -60,8 +60,8 @@ func StartTransfer(prometheusPort int) error {
msgDocModel := unrelation.NewMsgMongoDriver(mongo.GetDatabase())
chatLogDatabase := controller.NewChatLogDatabase(relation.NewChatLogGorm(db))
msgDatabase := controller.NewCommonMsgDatabase(msgDocModel, msgModel)
conversationRpcClient := rpcclient.NewConversationRpcClient(client)
groupRpcClient := rpcclient.NewGroupRpcClient(client)
conversationRpcClient := rpcclient.NewConversationRPCClient(client)
groupRpcClient := rpcclient.NewGroupRPCClient(client)
msgTransfer := NewMsgTransfer(chatLogDatabase, msgDatabase, &conversationRpcClient, &groupRpcClient)
msgTransfer.initPrometheus()
return msgTransfer.Start(prometheusPort)
@ -69,7 +69,7 @@ func StartTransfer(prometheusPort int) error {
func NewMsgTransfer(chatLogDatabase controller.ChatLogDatabase,
msgDatabase controller.CommonMsgDatabase,
conversationRpcClient *rpcclient.ConversationRpcClient, groupRpcClient *rpcclient.GroupRpcClient) *MsgTransfer {
conversationRpcClient *rpcclient.ConversationRPCClient, groupRpcClient *rpcclient.GroupRPCClient) *MsgTransfer {
return &MsgTransfer{persistentCH: NewPersistentConsumerHandler(chatLogDatabase), historyCH: NewOnlineHistoryRedisConsumerHandler(msgDatabase, conversationRpcClient, groupRpcClient),
historyMongoCH: NewOnlineHistoryMongoConsumerHandler(msgDatabase)}
}

@ -74,25 +74,25 @@ type OnlineHistoryRedisConsumerHandler struct {
singleMsgFailedCountMutex sync.Mutex
msgDatabase controller.CommonMsgDatabase
conversationRpcClient *rpcclient.ConversationRpcClient
groupRpcClient *rpcclient.GroupRpcClient
conversationRPCClient *rpcclient.ConversationRPCClient
groupRPCClient *rpcclient.GroupRPCClient
}
func NewOnlineHistoryRedisConsumerHandler(
database controller.CommonMsgDatabase,
conversationRpcClient *rpcclient.ConversationRpcClient,
groupRpcClient *rpcclient.GroupRpcClient,
conversationRPCClient *rpcclient.ConversationRPCClient,
groupRPCClient *rpcclient.GroupRPCClient,
) *OnlineHistoryRedisConsumerHandler {
var och OnlineHistoryRedisConsumerHandler
och.msgDatabase = database
och.msgDistributionCh = make(chan Cmd2Value) //no buffer channel
och.msgDistributionCh = make(chan Cmd2Value) // no buffer channel
go och.MessagesDistributionHandle()
for i := 0; i < ChannelNum; i++ {
och.chArrays[i] = make(chan Cmd2Value, 50)
go och.Run(i)
}
och.conversationRpcClient = conversationRpcClient
och.groupRpcClient = groupRpcClient
och.conversationRPCClient = conversationRPCClient
och.groupRPCClient = groupRPCClient
och.historyConsumerGroup = kafka.NewMConsumerGroup(&kafka.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0,
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.LatestMsgToRedis.Topic},
config.Config.Kafka.Addr, config.Config.Kafka.ConsumerGroupID.MsgToRedis)
@ -165,8 +165,8 @@ func (och *OnlineHistoryRedisConsumerHandler) Run(channelID int) {
// 获取消息/通知 存储的消息列表, 不存储并且推送的消息列表,
func (och *OnlineHistoryRedisConsumerHandler) getPushStorageMsgList(
totalMsgs []*ContextMsg,
) (storageMsgList, notStorageMsgList, storageNotificatoinList, notStorageNotificationList, modifyMsgList []*sdkws.MsgData) {
totalMses []*ContextMsg,
) (storageMsgList, notStorageMsgList, storageNotificationList, notStorageNotificationList, modifyMsgList []*sdkws.MsgData) {
isStorage := func(msg *sdkws.MsgData) bool {
options2 := utils.Options(msg.Options)
if options2.IsHistory() {
@ -178,7 +178,7 @@ func (och *OnlineHistoryRedisConsumerHandler) getPushStorageMsgList(
return false
}
}
for _, v := range totalMsgs {
for _, v := range totalMses {
options := utils.Options(v.message.Options)
if !options.IsNotNotification() {
// clone msg from notificationMsg
@ -205,7 +205,7 @@ func (och *OnlineHistoryRedisConsumerHandler) getPushStorageMsgList(
storageMsgList = append(storageMsgList, msg)
}
if isStorage(v.message) {
storageNotificatoinList = append(storageNotificatoinList, v.message)
storageNotificationList = append(storageNotificationList, v.message)
} else {
notStorageNotificationList = append(notStorageNotificationList, v.message)
}
@ -278,16 +278,16 @@ func (och *OnlineHistoryRedisConsumerHandler) handleMsg(
if isNewConversation {
if storageList[0].SessionType == constant.SuperGroupChatType {
log.ZInfo(ctx, "group chat first create conversation", "conversationID", conversationID)
userIDs, err := och.groupRpcClient.GetGroupMemberIDs(ctx, storageList[0].GroupID)
userIDs, err := och.groupRPCClient.GetGroupMemberIDs(ctx, storageList[0].GroupID)
if err != nil {
log.ZWarn(ctx, "get group member ids error", err, "conversationID", conversationID)
} else {
if err := och.conversationRpcClient.GroupChatFirstCreateConversation(ctx, storageList[0].GroupID, userIDs); err != nil {
if err := och.conversationRPCClient.GroupChatFirstCreateConversation(ctx, storageList[0].GroupID, userIDs); err != nil {
log.ZWarn(ctx, "single chat first create conversation error", err, "conversationID", conversationID)
}
}
} else {
if err := och.conversationRpcClient.SingleChatFirstCreateConversation(ctx, storageList[0].RecvID, storageList[0].SendID); err != nil {
if err := och.conversationRPCClient.SingleChatFirstCreateConversation(ctx, storageList[0].RecvID, storageList[0].SendID); err != nil {
log.ZWarn(ctx, "single chat first create conversation error", err, "conversationID", conversationID)
}
}
@ -312,7 +312,7 @@ func (och *OnlineHistoryRedisConsumerHandler) MessagesDistributionHandle() {
triggerChannelValue := cmd.Value.(TriggerChannelValue)
ctx := triggerChannelValue.ctx
consumerMessages := triggerChannelValue.cMsgList
//Aggregation map[userid]message list
// Aggregation map[userid]message list
log.ZDebug(ctx, "batch messages come to distribution center", "length", len(consumerMessages))
for i := 0; i < len(consumerMessages); i++ {
ctxMsg := &ContextMsg{}
@ -431,7 +431,7 @@ func (och *OnlineHistoryRedisConsumerHandler) ConsumeClaim(
ctx := mcontext.WithTriggerIDContext(context.Background(), utils.OperationIDGenerator())
log.ZDebug(ctx, "timer trigger msg consumer start", "length", len(ccMsg))
for i := 0; i < len(ccMsg)/split; i++ {
//log.Debug()
// log.Debug()
och.msgDistributionCh <- Cmd2Value{Cmd: ConsumerMsgs, Value: TriggerChannelValue{
ctx: ctx, cMsgList: ccMsg[i*split : (i+1)*split]}}
}

@ -38,7 +38,7 @@ func NewPersistentConsumerHandler(database controller.ChatLogDatabase) *Persiste
return &PersistentConsumerHandler{
persistentConsumerGroup: kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0,
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.LatestMsgToRedis.Topic},
config.Config.Kafka.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMySql),
config.Config.Kafka.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMySQL),
chatLogDatabase: database,
}
}
@ -59,9 +59,9 @@ func (pc *PersistentConsumerHandler) handleChatWs2Mysql(
}
return
log.ZDebug(ctx, "handleChatWs2Mysql", "msg", msgFromMQ.MsgData)
//Control whether to store history messages (mysql)
// Control whether to store history messages (mysql)
isPersist := utils.GetSwitchFromOptions(msgFromMQ.MsgData.Options, constant.IsPersistent)
//Only process receiver data
// Only process receiver data
if isPersist {
switch msgFromMQ.MsgData.SessionType {
case constant.SingleChatType, constant.NotificationChatType:

@ -28,7 +28,7 @@ import (
)
func url() string {
return config.Config.Callback.CallbackUrl
return config.Config.Callback.CallbackURL
}
func callbackOfflinePush(
@ -127,7 +127,7 @@ func callbackBeforeSuperGroupOnlinePush(
Seq: msg.Seq,
}
resp := &callbackstruct.CallbackBeforeSuperGroupOnlinePushResp{}
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackBeforeSuperGroupOnlinePush); err != nil {
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackURL, req, resp, config.Config.Callback.CallbackBeforeSuperGroupOnlinePush); err != nil {
if err == errs.ErrCallbackContinue {
return nil
}

@ -163,7 +163,7 @@ func (g *Client) request(ctx context.Context, url string, input interface{}, tok
header := map[string]string{"token": token}
resp := &Resp{}
resp.Data = output
return g.postReturn(ctx, config.Config.Push.GeTui.PushUrl+url, header, input, resp, 3)
return g.postReturn(ctx, config.Config.Push.GeTui.PushURL+url, header, input, resp, 3)
}
func (g *Client) postReturn(

@ -76,7 +76,7 @@ func (j *JPush) Push(ctx context.Context, userIDs []string, title, content strin
func (j *JPush) request(ctx context.Context, po body.PushObj, resp interface{}, timeout int) error {
return http2.PostReturn(
ctx,
config.Config.Push.Jpns.PushUrl,
config.Config.Push.Jpns.PushURL,
map[string]string{
"Authorization": j.getAuthorization(config.Config.Push.Jpns.AppKey, config.Config.Push.Jpns.MasterSecret),
},

@ -42,8 +42,8 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
cacheModel := cache.NewMsgCacheModel(rdb)
offlinePusher := NewOfflinePusher(cacheModel)
database := controller.NewPushDatabase(cacheModel)
groupRpcClient := rpcclient.NewGroupRpcClient(client)
conversationRpcClient := rpcclient.NewConversationRpcClient(client)
groupRpcClient := rpcclient.NewGroupRPCClient(client)
conversationRpcClient := rpcclient.NewConversationRPCClient(client)
msgRpcClient := rpcclient.NewMessageRpcClient(client)
pusher := NewPusher(
client,

@ -30,9 +30,9 @@ type Pusher struct {
offlinePusher offlinepush.OfflinePusher
groupLocalCache *localcache.GroupLocalCache
conversationLocalCache *localcache.ConversationLocalCache
msgRpcClient *rpcclient.MessageRpcClient
conversationRpcClient *rpcclient.ConversationRpcClient
groupRpcClient *rpcclient.GroupRpcClient
msgRPCClient *rpcclient.MessageRpcClient
conversationRPCClient *rpcclient.ConversationRPCClient
groupRPCClient *rpcclient.GroupRPCClient
successCount int
}
@ -40,16 +40,16 @@ var errNoOfflinePusher = errors.New("no offlinePusher is configured")
func NewPusher(discov discoveryregistry.SvcDiscoveryRegistry, offlinePusher offlinepush.OfflinePusher, database controller.PushDatabase,
groupLocalCache *localcache.GroupLocalCache, conversationLocalCache *localcache.ConversationLocalCache,
conversationRpcClient *rpcclient.ConversationRpcClient, groupRpcClient *rpcclient.GroupRpcClient, msgRpcClient *rpcclient.MessageRpcClient) *Pusher {
conversationRPCClient *rpcclient.ConversationRPCClient, groupRpcClient *rpcclient.GroupRPCClient, msgRPCClient *rpcclient.MessageRpcClient) *Pusher {
return &Pusher{
discov: discov,
database: database,
offlinePusher: offlinePusher,
groupLocalCache: groupLocalCache,
conversationLocalCache: conversationLocalCache,
msgRpcClient: msgRpcClient,
conversationRpcClient: conversationRpcClient,
groupRpcClient: groupRpcClient,
msgRPCClient: msgRPCClient,
conversationRPCClient: conversationRPCClient,
groupRPCClient: groupRpcClient,
}
}
@ -68,11 +68,11 @@ func NewOfflinePusher(cache cache.MsgModel) offlinepush.OfflinePusher {
func (p *Pusher) DeleteMemberAndSetConversationSeq(ctx context.Context, groupID string, userIDs []string) error {
conevrsationID := utils.GetConversationIDBySessionType(constant.SuperGroupChatType, groupID)
maxSeq, err := p.msgRpcClient.GetConversationMaxSeq(ctx, conevrsationID)
maxSeq, err := p.msgRPCClient.GetConversationMaxSeq(ctx, conevrsationID)
if err != nil {
return err
}
return p.conversationRpcClient.SetConversationMaxSeq(ctx, userIDs, conevrsationID, maxSeq)
return p.conversationRPCClient.SetConversationMaxSeq(ctx, userIDs, conevrsationID, maxSeq)
}
func (p *Pusher) Push2User(ctx context.Context, userIDs []string, msg *sdkws.MsgData) error {
@ -165,7 +165,7 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
ctx = mcontext.WithOpUserIDContext(ctx, config.Config.Manager.UserID[0])
}
defer func(groupID string) {
if err := p.groupRpcClient.DismissGroup(ctx, groupID); err != nil {
if err := p.groupRPCClient.DismissGroup(ctx, groupID); err != nil {
log.ZError(ctx, "DismissGroup Notification clear members", err, "groupID", groupID)
}
}(groupID)
@ -209,7 +209,7 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
}
needOfflinePushUserIDs = utils.DifferenceString(notNotificationUserIDs, needOfflinePushUserIDs)
}
//Use offline push messaging
// Use offline push messaging
if len(needOfflinePushUserIDs) > 0 {
var offlinePushUserIDs []string
err = callbackOfflinePush(ctx, needOfflinePushUserIDs, msg, &offlinePushUserIDs)
@ -235,12 +235,12 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
}
func (p *Pusher) GetConnsAndOnlinePush(ctx context.Context, msg *sdkws.MsgData, pushToUserIDs []string) (wsResults []*msggateway.SingleMsgToUserResults, err error) {
conns, err := p.discov.GetConns(ctx, config.Config.RpcRegisterName.OpenImMessageGatewayName)
conns, err := p.discov.GetConns(ctx, config.Config.RPCRegisterName.OpenImMessageGatewayName)
log.ZDebug(ctx, "get gateway conn", "conn length", len(conns))
if err != nil {
return nil, err
}
//Online push message
// Online push message
for _, v := range conns {
msgClient := msggateway.NewMsgGatewayClient(v)
reply, err := msgClient.SuperGroupOnlineBatchPushOneMsg(ctx, &msggateway.OnlineBatchPushOneMsgReq{MsgData: msg, PushToUserIDs: pushToUserIDs})
@ -293,7 +293,7 @@ func (p *Pusher) GetOfflinePushOpts(msg *sdkws.MsgData) (opts *offlinepush.Opts,
func (p *Pusher) getOfflinePushInfos(conversationID string, msg *sdkws.MsgData) (title, content string, opts *offlinepush.Opts, err error) {
if p.offlinePusher == nil {
err = errNoOfflinePusher
return
return "", "", nil, err
}
type AtContent struct {
Text string `json:"text"`
@ -302,7 +302,7 @@ func (p *Pusher) getOfflinePushInfos(conversationID string, msg *sdkws.MsgData)
}
opts, err = p.GetOfflinePushOpts(msg)
if err != nil {
return
return "", "", opts, err
}
if msg.OfflinePushInfo != nil {
title = msg.OfflinePushInfo.Title
@ -322,7 +322,7 @@ func (p *Pusher) getOfflinePushInfos(conversationID string, msg *sdkws.MsgData)
title = constant.ContentType2PushContent[int64(msg.ContentType)]
case constant.AtText:
a := AtContent{}
_ = utils.JsonStringToStruct(string(msg.Content), &a)
_ = utils.JSONStringToStruct(string(msg.Content), &a)
if utils.IsContain(conversationID, a.AtUserList) {
title = constant.ContentType2PushContent[constant.AtText] + constant.ContentType2PushContent[constant.Common]
} else {
@ -337,5 +337,5 @@ func (p *Pusher) getOfflinePushInfos(conversationID string, msg *sdkws.MsgData)
if content == "" {
content = title
}
return
return title, content, opts, err
}

@ -35,7 +35,7 @@ import (
type authServer struct {
authDatabase controller.AuthDatabase
userRpcClient *rpcclient.UserRpcClient
userRPCClient *rpcclient.UserRPCClient
RegisterCenter discoveryregistry.SvcDiscoveryRegistry
}
@ -44,9 +44,9 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
if err != nil {
return err
}
userRpcClient := rpcclient.NewUserRpcClient(client)
userRPCClient := rpcclient.NewUserRPCClient(client)
pbAuth.RegisterAuthServer(server, &authServer{
userRpcClient: &userRpcClient,
userRPCClient: &userRPCClient,
RegisterCenter: client,
authDatabase: controller.NewAuthDatabase(
cache.NewMsgCacheModel(rdb),
@ -62,7 +62,7 @@ func (s *authServer) UserToken(ctx context.Context, req *pbAuth.UserTokenReq) (*
if req.Secret != config.Config.Secret {
return nil, errs.ErrNoPermission.Wrap("secret invalid")
}
if _, err := s.userRpcClient.GetUserInfo(ctx, req.UserID); err != nil {
if _, err := s.userRPCClient.GetUserInfo(ctx, req.UserID); err != nil {
return nil, err
}
token, err := s.authDatabase.CreateToken(ctx, req.UserID, int(req.PlatformID))
@ -125,7 +125,7 @@ func (s *authServer) ForceLogout(ctx context.Context, req *pbAuth.ForceLogoutReq
}
func (s *authServer) forceKickOff(ctx context.Context, userID string, platformID int32, operationID string) error {
conns, err := s.RegisterCenter.GetConns(ctx, config.Config.RpcRegisterName.OpenImMessageGatewayName)
conns, err := s.RegisterCenter.GetConns(ctx, config.Config.RPCRegisterName.OpenImMessageGatewayName)
if err != nil {
return err
}

@ -21,7 +21,7 @@ import (
)
type conversationServer struct {
groupRpcClient *rpcclient.GroupRpcClient
groupRPCClient *rpcclient.GroupRPCClient
conversationDatabase controller.ConversationDatabase
conversationNotificationSender *notification.ConversationNotificationSender
}
@ -39,11 +39,11 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
return err
}
conversationDB := relation.NewConversationGorm(db)
groupRpcClient := rpcclient.NewGroupRpcClient(client)
groupRPCClient := rpcclient.NewGroupRPCClient(client)
msgRpcClient := rpcclient.NewMessageRpcClient(client)
pbConversation.RegisterConversationServer(server, &conversationServer{
conversationNotificationSender: notification.NewConversationNotificationSender(&msgRpcClient),
groupRpcClient: &groupRpcClient,
groupRPCClient: &groupRPCClient,
conversationDatabase: controller.NewConversationDatabase(conversationDB, cache.NewConversationRedis(rdb, cache.GetDefaultOpt(), conversationDB), tx.NewGorm(db)),
})
return nil
@ -101,7 +101,7 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbConver
return nil, errs.ErrArgs.Wrap("conversation must not be nil")
}
if req.Conversation.ConversationType == constant.GroupChatType {
groupInfo, err := c.groupRpcClient.GetGroupInfo(ctx, req.Conversation.GroupID)
groupInfo, err := c.groupRPCClient.GetGroupInfo(ctx, req.Conversation.GroupID)
if err != nil {
return nil, err
}

@ -29,7 +29,7 @@ func (s *friendServer) GetPaginationBlacks(
ctx context.Context,
req *pbFriend.GetPaginationBlacksReq,
) (resp *pbFriend.GetPaginationBlacksResp, err error) {
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
if err := s.userRPCClient.Access(ctx, req.UserID); err != nil {
return nil, err
}
var pageNumber, showNumber int32
@ -42,7 +42,7 @@ func (s *friendServer) GetPaginationBlacks(
return nil, err
}
resp = &pbFriend.GetPaginationBlacksResp{}
resp.Blacks, err = convert.BlackDB2Pb(ctx, blacks, s.userRpcClient.GetUsersInfoMap)
resp.Blacks, err = convert.BlackDB2Pb(ctx, blacks, s.userRPCClient.GetUsersInfoMap)
if err != nil {
return nil, err
}
@ -65,7 +65,7 @@ func (s *friendServer) RemoveBlack(
ctx context.Context,
req *pbFriend.RemoveBlackReq,
) (*pbFriend.RemoveBlackResp, error) {
if err := s.userRpcClient.Access(ctx, req.OwnerUserID); err != nil {
if err := s.userRPCClient.Access(ctx, req.OwnerUserID); err != nil {
return nil, err
}
if err := s.blackDatabase.Delete(ctx, []*relation.BlackModel{{OwnerUserID: req.OwnerUserID, BlockUserID: req.BlackUserID}}); err != nil {
@ -79,7 +79,7 @@ func (s *friendServer) AddBlack(ctx context.Context, req *pbFriend.AddBlackReq)
if err := tokenverify.CheckAccessV3(ctx, req.OwnerUserID); err != nil {
return nil, err
}
_, err := s.userRpcClient.GetUsersInfo(ctx, []string{req.OwnerUserID, req.BlackUserID})
_, err := s.userRPCClient.GetUsersInfo(ctx, []string{req.OwnerUserID, req.BlackUserID})
if err != nil {
return nil, err
}

@ -38,7 +38,7 @@ func CallbackBeforeAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriend
OperationID: mcontext.GetOperationID(ctx),
}
resp := &cbapi.CallbackBeforeAddFriendResp{}
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackBeforeAddFriend); err != nil {
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackURL, cbReq, resp, config.Config.Callback.CallbackBeforeAddFriend); err != nil {
if err == errs.ErrCallbackContinue {
return nil
}

@ -40,7 +40,7 @@ import (
type friendServer struct {
friendDatabase controller.FriendDatabase
blackDatabase controller.BlackDatabase
userRpcClient *rpcclient.UserRpcClient
userRPCClient *rpcclient.UserRPCClient
notificationSender *notification.FriendNotificationSender
RegisterCenter registry.SvcDiscoveryRegistry
}
@ -59,11 +59,11 @@ func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
}
blackDB := relation.NewBlackGorm(db)
friendDB := relation.NewFriendGorm(db)
userRpcClient := rpcclient.NewUserRpcClient(client)
userRPCClient := rpcclient.NewUserRPCClient(client)
msgRpcClient := rpcclient.NewMessageRpcClient(client)
notificationSender := notification.NewFriendNotificationSender(
&msgRpcClient,
notification.WithRpcFunc(userRpcClient.GetUsersInfo),
notification.WithRpcFunc(userRPCClient.GetUsersInfo),
)
pbfriend.RegisterFriendServer(server, &friendServer{
friendDatabase: controller.NewFriendDatabase(
@ -76,7 +76,7 @@ func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
blackDB,
cache.NewBlackCacheRedis(rdb, blackDB, cache.GetDefaultOpt()),
),
userRpcClient: &userRpcClient,
userRPCClient: &userRPCClient,
notificationSender: notificationSender,
RegisterCenter: client,
})
@ -99,7 +99,7 @@ func (s *friendServer) ApplyToAddFriend(
if err := CallbackBeforeAddFriend(ctx, req); err != nil && err != errs.ErrCallbackContinue {
return nil, err
}
if _, err := s.userRpcClient.GetUsersInfoMap(ctx, []string{req.ToUserID, req.FromUserID}); err != nil {
if _, err := s.userRPCClient.GetUsersInfoMap(ctx, []string{req.ToUserID, req.FromUserID}); err != nil {
return nil, err
}
in1, in2, err := s.friendDatabase.CheckIn(ctx, req.FromUserID, req.ToUserID)
@ -125,7 +125,7 @@ func (s *friendServer) ImportFriends(
if err := tokenverify.CheckAdmin(ctx); err != nil {
return nil, err
}
if _, err := s.userRpcClient.GetUsersInfo(ctx, append([]string{req.OwnerUserID}, req.FriendUserIDs...)); err != nil {
if _, err := s.userRPCClient.GetUsersInfo(ctx, append([]string{req.OwnerUserID}, req.FriendUserIDs...)); err != nil {
return nil, err
}
@ -185,7 +185,7 @@ func (s *friendServer) DeleteFriend(
) (resp *pbfriend.DeleteFriendResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
resp = &pbfriend.DeleteFriendResp{}
if err := s.userRpcClient.Access(ctx, req.OwnerUserID); err != nil {
if err := s.userRPCClient.Access(ctx, req.OwnerUserID); err != nil {
return nil, err
}
_, err = s.friendDatabase.FindFriendsWithError(ctx, req.OwnerUserID, []string{req.FriendUserID})
@ -206,7 +206,7 @@ func (s *friendServer) SetFriendRemark(
) (resp *pbfriend.SetFriendRemarkResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
resp = &pbfriend.SetFriendRemarkResp{}
if err := s.userRpcClient.Access(ctx, req.OwnerUserID); err != nil {
if err := s.userRPCClient.Access(ctx, req.OwnerUserID); err != nil {
return nil, err
}
_, err = s.friendDatabase.FindFriendsWithError(ctx, req.OwnerUserID, []string{req.FriendUserID})
@ -234,7 +234,7 @@ func (s *friendServer) GetDesignatedFriends(
if err != nil {
return nil, err
}
if resp.FriendsInfo, err = convert.FriendsDB2Pb(ctx, friends, s.userRpcClient.GetUsersInfoMap); err != nil {
if resp.FriendsInfo, err = convert.FriendsDB2Pb(ctx, friends, s.userRPCClient.GetUsersInfoMap); err != nil {
return nil, err
}
return resp, nil
@ -247,7 +247,7 @@ func (s *friendServer) GetPaginationFriendsApplyTo(
) (resp *pbfriend.GetPaginationFriendsApplyToResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
resp = &pbfriend.GetPaginationFriendsApplyToResp{}
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
if err := s.userRPCClient.Access(ctx, req.UserID); err != nil {
return nil, err
}
pageNumber, showNumber := utils.GetPage(req.Pagination)
@ -255,7 +255,7 @@ func (s *friendServer) GetPaginationFriendsApplyTo(
if err != nil {
return nil, err
}
resp.FriendRequests, err = convert.FriendRequestDB2Pb(ctx, friendRequests, s.userRpcClient.GetUsersInfoMap)
resp.FriendRequests, err = convert.FriendRequestDB2Pb(ctx, friendRequests, s.userRPCClient.GetUsersInfoMap)
if err != nil {
return nil, err
}
@ -270,7 +270,7 @@ func (s *friendServer) GetPaginationFriendsApplyFrom(
) (resp *pbfriend.GetPaginationFriendsApplyFromResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
resp = &pbfriend.GetPaginationFriendsApplyFromResp{}
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
if err := s.userRPCClient.Access(ctx, req.UserID); err != nil {
return nil, err
}
pageNumber, showNumber := utils.GetPage(req.Pagination)
@ -278,7 +278,7 @@ func (s *friendServer) GetPaginationFriendsApplyFrom(
if err != nil {
return nil, err
}
resp.FriendRequests, err = convert.FriendRequestDB2Pb(ctx, friendRequests, s.userRpcClient.GetUsersInfoMap)
resp.FriendRequests, err = convert.FriendRequestDB2Pb(ctx, friendRequests, s.userRPCClient.GetUsersInfoMap)
if err != nil {
return nil, err
}
@ -306,7 +306,7 @@ func (s *friendServer) GetPaginationFriends(
req *pbfriend.GetPaginationFriendsReq,
) (resp *pbfriend.GetPaginationFriendsResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
if err := s.userRPCClient.Access(ctx, req.UserID); err != nil {
return nil, err
}
pageNumber, showNumber := utils.GetPage(req.Pagination)
@ -315,7 +315,7 @@ func (s *friendServer) GetPaginationFriends(
return nil, err
}
resp = &pbfriend.GetPaginationFriendsResp{}
resp.FriendsInfo, err = convert.FriendsDB2Pb(ctx, friends, s.userRpcClient.GetUsersInfoMap)
resp.FriendsInfo, err = convert.FriendsDB2Pb(ctx, friends, s.userRPCClient.GetUsersInfoMap)
if err != nil {
return nil, err
}
@ -328,7 +328,7 @@ func (s *friendServer) GetFriendIDs(
req *pbfriend.GetFriendIDsReq,
) (resp *pbfriend.GetFriendIDsResp, err error) {
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
if err := s.userRPCClient.Access(ctx, req.UserID); err != nil {
return nil, err
}
resp = &pbfriend.GetFriendIDsResp{}

@ -59,7 +59,7 @@ func CallbackBeforeCreateGroup(ctx context.Context, req *group.CreateGroupReq) (
resp := &callbackstruct.CallbackBeforeCreateGroupResp{}
err = http.CallBackPostReturn(
ctx,
config.Config.Callback.CallbackUrl,
config.Config.Callback.CallbackURL,
cbReq,
resp,
config.Config.Callback.CallbackBeforeCreateGroup,
@ -104,7 +104,7 @@ func CallbackBeforeMemberJoinGroup(
resp := &callbackstruct.CallbackBeforeMemberJoinGroupResp{}
err = http.CallBackPostReturn(
ctx,
config.Config.Callback.CallbackUrl,
config.Config.Callback.CallbackURL,
callbackReq,
resp,
config.Config.Callback.CallbackBeforeMemberJoinGroup,
@ -150,7 +150,7 @@ func CallbackBeforeSetGroupMemberInfo(ctx context.Context, req *group.SetGroupMe
resp := &callbackstruct.CallbackBeforeSetGroupMemberInfoResp{}
err = http.CallBackPostReturn(
ctx,
config.Config.Callback.CallbackUrl,
config.Config.Callback.CallbackURL,
callbackReq,
resp,
config.Config.Callback.CallbackBeforeSetGroupMemberInfo,

@ -50,36 +50,36 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
if err != nil {
return err
}
userRpcClient := rpcclient.NewUserRpcClient(client)
msgRpcClient := rpcclient.NewMessageRpcClient(client)
conversationRpcClient := rpcclient.NewConversationRpcClient(client)
userRPCClient := rpcclient.NewUserRPCClient(client)
msgRPCClient := rpcclient.NewMessageRpcClient(client)
conversationRPCClient := rpcclient.NewConversationRPCClient(client)
database := controller.InitGroupDatabase(db, rdb, mongo.GetDatabase())
pbGroup.RegisterGroupServer(server, &groupServer{
GroupDatabase: database,
User: userRpcClient,
Notification: notification.NewGroupNotificationSender(database, &msgRpcClient, &userRpcClient, func(ctx context.Context, userIDs []string) ([]notification.CommonUser, error) {
users, err := userRpcClient.GetUsersInfo(ctx, userIDs)
User: userRPCClient,
Notification: notification.NewGroupNotificationSender(database, &msgRPCClient, &userRPCClient, func(ctx context.Context, userIDs []string) ([]notification.CommonUser, error) {
users, err := userRPCClient.GetUsersInfo(ctx, userIDs)
if err != nil {
return nil, err
}
return utils.Slice(users, func(e *sdkws.UserInfo) notification.CommonUser { return e }), nil
}),
conversationRpcClient: conversationRpcClient,
msgRpcClient: msgRpcClient,
conversationRPCClient: conversationRPCClient,
msgRPCClient: msgRPCClient,
})
return nil
}
type groupServer struct {
GroupDatabase controller.GroupDatabase
User rpcclient.UserRpcClient
User rpcclient.UserRPCClient
Notification *notification.GroupNotificationSender
conversationRpcClient rpcclient.ConversationRpcClient
msgRpcClient rpcclient.MessageRpcClient
conversationRPCClient rpcclient.ConversationRPCClient
msgRPCClient rpcclient.MessageRpcClient
}
func (s *groupServer) CheckGroupAdmin(ctx context.Context, groupID string) error {
if !tokenverify.IsAppManagerUid(ctx) {
if !tokenverify.IsAppManagerUID(ctx) {
groupMember, err := s.GroupDatabase.TakeGroupMember(ctx, groupID, mcontext.GetOpUserID(ctx))
if err != nil {
return err
@ -215,7 +215,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
}
}()
} else {
//s.Notification.GroupCreatedNotification(ctx, group, groupMembers, userMap)
// s.Notification.GroupCreatedNotification(ctx, group, groupMembers, userMap)
tips := &sdkws.GroupCreatedTips{
Group: resp.GroupInfo,
OperationTime: group.CreateTime.UnixMilli(),
@ -244,7 +244,7 @@ func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJo
pageNumber = req.Pagination.PageNumber
showNumber = req.Pagination.ShowNumber
}
//total, members, err := s.GroupDatabase.PageGroupMember(ctx, nil, []string{req.FromUserID}, nil, pageNumber, showNumber)
// total, members, err := s.GroupDatabase.PageGroupMember(ctx, nil, []string{req.FromUserID}, nil, pageNumber, showNumber)
total, members, err := s.GroupDatabase.PageGetJoinGroup(ctx, req.FromUserID, pageNumber, showNumber)
if err != nil {
return nil, err
@ -304,7 +304,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
}
var groupMember *relationTb.GroupMemberModel
var opUserID string
if !tokenverify.IsAppManagerUid(ctx) {
if !tokenverify.IsAppManagerUID(ctx) {
opUserID = mcontext.GetOpUserID(ctx)
groupMembers, err := s.FindGroupMember(ctx, []string{req.GroupID}, []string{opUserID}, nil)
if err != nil {
@ -316,7 +316,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
groupMember = groupMembers[0]
}
if group.NeedVerification == constant.AllNeedVerification {
if !tokenverify.IsAppManagerUid(ctx) {
if !tokenverify.IsAppManagerUID(ctx) {
if !(groupMember.RoleLevel == constant.GroupOwner || groupMember.RoleLevel == constant.GroupAdmin) {
var requests []*relationTb.GroupRequestModel
for _, userID := range req.InvitedUserIDs {
@ -349,7 +349,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
if err := s.GroupDatabase.CreateSuperGroupMember(ctx, req.GroupID, req.InvitedUserIDs); err != nil {
return nil, err
}
if err := s.conversationRpcClient.GroupChatFirstCreateConversation(ctx, req.GroupID, req.InvitedUserIDs); err != nil {
if err := s.conversationRPCClient.GroupChatFirstCreateConversation(ctx, req.GroupID, req.InvitedUserIDs); err != nil {
return nil, err
}
for _, userID := range req.InvitedUserIDs {
@ -376,7 +376,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
if err := s.GroupDatabase.CreateGroup(ctx, nil, groupMembers); err != nil {
return nil, err
}
if err := s.conversationRpcClient.GroupChatFirstCreateConversation(ctx, req.GroupID, req.InvitedUserIDs); err != nil {
if err := s.conversationRPCClient.GroupChatFirstCreateConversation(ctx, req.GroupID, req.InvitedUserIDs); err != nil {
return nil, err
}
s.Notification.MemberInvitedNotification(ctx, req.GroupID, req.Reason, req.InvitedUserIDs)
@ -459,7 +459,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
for i, member := range members {
memberMap[member.UserID] = members[i]
}
isAppManagerUid := tokenverify.IsAppManagerUid(ctx)
isAppManagerUid := tokenverify.IsAppManagerUID(ctx)
opMember := memberMap[opUserID]
for _, userID := range req.KickedUserIDs {
member, ok := memberMap[userID]
@ -501,7 +501,7 @@ func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGrou
Notification: group.Notification,
Introduction: group.Introduction,
FaceURL: group.FaceURL,
//OwnerUserID: owner[0].UserID,
// OwnerUserID: owner[0].UserID,
CreateTime: group.CreateTime.UnixMilli(),
MemberCount: num,
Ex: group.Ex,
@ -651,7 +651,7 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup
if !utils.Contain(req.HandleResult, constant.GroupResponseAgree, constant.GroupResponseRefuse) {
return nil, errs.ErrArgs.Wrap("HandleResult unknown")
}
if !tokenverify.IsAppManagerUid(ctx) {
if !tokenverify.IsAppManagerUID(ctx) {
groupMember, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, mcontext.GetOpUserID(ctx))
if err != nil {
return nil, err
@ -703,7 +703,7 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup
if err := s.GroupDatabase.HandlerGroupRequest(ctx, req.GroupID, req.FromUserID, req.HandledMsg, req.HandleResult, member); err != nil {
return nil, err
}
if err := s.conversationRpcClient.GroupChatFirstCreateConversation(ctx, req.GroupID, []string{req.FromUserID}); err != nil {
if err := s.conversationRPCClient.GroupChatFirstCreateConversation(ctx, req.GroupID, []string{req.FromUserID}); err != nil {
return nil, err
}
switch req.HandleResult {
@ -757,7 +757,7 @@ func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq)
if err := s.GroupDatabase.CreateGroup(ctx, nil, []*relationTb.GroupMemberModel{groupMember}); err != nil {
return nil, err
}
if err := s.conversationRpcClient.GroupChatFirstCreateConversation(ctx, req.GroupID, []string{req.InviterUserID}); err != nil {
if err := s.conversationRPCClient.GroupChatFirstCreateConversation(ctx, req.GroupID, []string{req.InviterUserID}); err != nil {
return nil, err
}
s.Notification.MemberEnterDirectlyNotification(ctx, req.GroupID, req.InviterUserID)
@ -811,16 +811,16 @@ func (s *groupServer) QuitGroup(ctx context.Context, req *pbGroup.QuitGroupReq)
func (s *groupServer) deleteMemberAndSetConversationSeq(ctx context.Context, groupID string, userIDs []string) error {
conevrsationID := utils.GetConversationIDBySessionType(constant.SuperGroupChatType, groupID)
maxSeq, err := s.msgRpcClient.GetConversationMaxSeq(ctx, conevrsationID)
maxSeq, err := s.msgRPCClient.GetConversationMaxSeq(ctx, conevrsationID)
if err != nil {
return err
}
return s.conversationRpcClient.SetConversationMaxSeq(ctx, userIDs, conevrsationID, maxSeq)
return s.conversationRPCClient.SetConversationMaxSeq(ctx, userIDs, conevrsationID, maxSeq)
}
func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInfoReq) (*pbGroup.SetGroupInfoResp, error) {
var opMember *relationTb.GroupMemberModel
if !tokenverify.IsAppManagerUid(ctx) {
if !tokenverify.IsAppManagerUID(ctx) {
var err error
opMember, err = s.TakeGroupMember(ctx, req.GroupInfoForSet.GroupID, mcontext.GetOpUserID(ctx))
if err != nil {
@ -880,7 +880,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
return
}
conversation.GroupAtType = &wrapperspb.Int32Value{Value: constant.GroupNotification}
if err := s.conversationRpcClient.SetConversations(nctx, resp.UserIDs, conversation); err != nil {
if err := s.conversationRPCClient.SetConversations(nctx, resp.UserIDs, conversation); err != nil {
log.ZWarn(ctx, "SetConversations", err, resp.UserIDs, conversation)
}
}()
@ -930,7 +930,7 @@ func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbGroup.Trans
if newOwner == nil {
return nil, errs.ErrArgs.Wrap("NewOwnerUser not in group " + req.NewOwnerUserID)
}
if !tokenverify.IsAppManagerUid(ctx) {
if !tokenverify.IsAppManagerUID(ctx) {
if !(mcontext.GetOpUserID(ctx) == oldOwner.UserID && oldOwner.RoleLevel == constant.GroupOwner) {
return nil, errs.ErrNoPermission.Wrap("no permission transfer group owner")
}
@ -1062,7 +1062,7 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
if err != nil {
return nil, err
}
if !tokenverify.IsAppManagerUid(ctx) {
if !tokenverify.IsAppManagerUID(ctx) {
if owner.UserID != mcontext.GetOpUserID(ctx) {
return nil, errs.ErrNoPermission.Wrap("not group owner")
}
@ -1074,9 +1074,9 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
if req.DeleteMember == false && group.Status == constant.GroupStatusDismissed {
return nil, errs.ErrDismissedAlready.Wrap("group status is dismissed")
}
//if group.Status == constant.GroupStatusDismissed {
// if group.Status == constant.GroupStatusDismissed {
// return nil, errs.ErrArgs.Wrap("group status is dismissed")
//}
// }
if err := s.GroupDatabase.DismissGroup(ctx, req.GroupID, req.DeleteMember); err != nil {
return nil, err
}
@ -1090,7 +1090,7 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
if err != nil {
return nil, err
}
//s.Notification.GroupDismissedNotification(ctx, req)
// s.Notification.GroupDismissedNotification(ctx, req)
tips := &sdkws.GroupDismissedTips{
Group: s.groupDB2PB(group, owner.UserID, num),
OpUser: &sdkws.GroupMemberFullInfo{},
@ -1106,14 +1106,14 @@ func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGrou
func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGroupMemberReq) (*pbGroup.MuteGroupMemberResp, error) {
resp := &pbGroup.MuteGroupMemberResp{}
//if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil {
// if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil {
// return nil, err
//}
// }
member, err := s.TakeGroupMember(ctx, req.GroupID, req.UserID)
if err != nil {
return nil, err
}
if !tokenverify.IsAppManagerUid(ctx) {
if !tokenverify.IsAppManagerUID(ctx) {
opMember, err := s.TakeGroupMember(ctx, req.GroupID, mcontext.GetOpUserID(ctx))
if err != nil {
return nil, err
@ -1141,11 +1141,11 @@ func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGrou
func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.CancelMuteGroupMemberReq) (*pbGroup.CancelMuteGroupMemberResp, error) {
resp := &pbGroup.CancelMuteGroupMemberResp{}
//member, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.UserID)
//if err != nil {
// member, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.UserID)
// if err != nil {
// return nil, err
//}
//if !(mcontext.GetOpUserID(ctx) == req.UserID || tokenverify.IsAppManagerUid(ctx)) {
// }
// if !(mcontext.GetOpUserID(ctx) == req.UserID || tokenverify.IsAppManagerUID(ctx)) {
// opMember, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, mcontext.GetOpUserID(ctx))
// if err != nil {
// return nil, err
@ -1153,15 +1153,15 @@ func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.Ca
// if opMember.RoleLevel <= member.RoleLevel {
// return nil, errs.ErrNoPermission.Wrap(fmt.Sprintf("self RoleLevel %d target %d", opMember.RoleLevel, member.RoleLevel))
// }
//}
//if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil {
// }
// if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil {
// return nil, err
//}
// }
member, err := s.TakeGroupMember(ctx, req.GroupID, req.UserID)
if err != nil {
return nil, err
}
if !tokenverify.IsAppManagerUid(ctx) {
if !tokenverify.IsAppManagerUID(ctx) {
opMember, err := s.TakeGroupMember(ctx, req.GroupID, mcontext.GetOpUserID(ctx))
if err != nil {
return nil, err
@ -1245,7 +1245,7 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
memberMap := utils.SliceToMap(members, func(e *relationTb.GroupMemberModel) [2]string {
return [...]string{e.GroupID, e.UserID}
})
if !tokenverify.IsAppManagerUid(ctx) {
if !tokenverify.IsAppManagerUID(ctx) {
opUserID := mcontext.GetOpUserID(ctx)
for _, member := range req.Members {
if member.RoleLevel != nil {
@ -1272,15 +1272,15 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
if !ok {
return nil, errs.ErrRecordNotFound.Wrap(fmt.Sprintf("user %s not in group %s", member.UserID, member.GroupID))
}
//if opMember.RoleLevel == constant.GroupOwner {
// if opMember.RoleLevel == constant.GroupOwner {
// continue
//}
//if dbMember.RoleLevel == constant.GroupOwner {
// }
// if dbMember.RoleLevel == constant.GroupOwner {
// return nil, errs.ErrNoPermission.Wrap("change group owner")
//}
//if opMember.RoleLevel == constant.GroupAdmin && dbMember.RoleLevel == constant.GroupAdmin {
// }
// if opMember.RoleLevel == constant.GroupAdmin && dbMember.RoleLevel == constant.GroupAdmin {
// return nil, errs.ErrNoPermission.Wrap("admin can not change other admin role info")
//}
// }
switch opMember.RoleLevel {
case constant.GroupOrdinaryUsers:
return nil, errs.ErrNoPermission.Wrap("ordinary users can not change other role level")
@ -1292,9 +1292,9 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
return nil, errs.ErrNoPermission.Wrap("admin can not change other role level")
}
case constant.GroupOwner:
//if member.RoleLevel != nil && member.RoleLevel.Value == constant.GroupOwner {
// if member.RoleLevel != nil && member.RoleLevel.Value == constant.GroupOwner {
// return nil, errs.ErrNoPermission.Wrap("owner only one")
//}
// }
}
}
}

@ -71,7 +71,7 @@ func (m *msgServer) SetConversationHasReadSeq(
) (resp *msg.SetConversationHasReadSeqResp, err error) {
maxSeq, err := m.MsgDatabase.GetMaxSeq(ctx, req.ConversationID)
if err != nil {
return
return nil, err
}
if req.HasReadSeq > maxSeq {
return nil, errs.ErrArgs.Wrap("hasReadSeq must not be bigger than maxSeq")
@ -80,7 +80,7 @@ func (m *msgServer) SetConversationHasReadSeq(
return nil, err
}
if err = m.sendMarkAsReadNotification(ctx, req.ConversationID, constant.SingleChatType, req.UserID, req.UserID, nil, req.HasReadSeq); err != nil {
return
return nil, err
}
return &msg.SetConversationHasReadSeqResp{}, nil
}
@ -94,7 +94,7 @@ func (m *msgServer) MarkMsgsAsRead(
}
maxSeq, err := m.MsgDatabase.GetMaxSeq(ctx, req.ConversationID)
if err != nil {
return
return nil, err
}
hasReadSeq := req.Seqs[len(req.Seqs)-1]
if hasReadSeq > maxSeq {
@ -102,14 +102,14 @@ func (m *msgServer) MarkMsgsAsRead(
}
conversation, err := m.Conversation.GetConversation(ctx, req.UserID, req.ConversationID)
if err != nil {
return
return nil, err
}
if err = m.MsgDatabase.MarkSingleChatMsgsAsRead(ctx, req.UserID, req.ConversationID, req.Seqs); err != nil {
return
}
currentHasReadSeq, err := m.MsgDatabase.GetHasReadSeq(ctx, req.UserID, req.ConversationID)
if err != nil && errs.Unwrap(err) != redis.Nil {
return
return nil, err
}
if hasReadSeq > currentHasReadSeq {
err = m.MsgDatabase.SetHasReadSeq(ctx, req.UserID, req.ConversationID, hasReadSeq)
@ -129,11 +129,11 @@ func (m *msgServer) MarkConversationAsRead(
) (resp *msg.MarkConversationAsReadResp, err error) {
conversation, err := m.Conversation.GetConversation(ctx, req.UserID, req.ConversationID)
if err != nil {
return
return nil, err
}
hasReadSeq, err := m.MsgDatabase.GetHasReadSeq(ctx, req.UserID, req.ConversationID)
if err != nil && errs.Unwrap(err) != redis.Nil {
return
return nil, err
}
log.ZDebug(ctx, "MarkConversationAsRead", "hasReadSeq", hasReadSeq, "req.HasReadSeq", req.HasReadSeq)
var seqs []int64
@ -153,7 +153,7 @@ func (m *msgServer) MarkConversationAsRead(
if req.HasReadSeq > hasReadSeq {
err = m.MsgDatabase.SetHasReadSeq(ctx, req.UserID, req.ConversationID, req.HasReadSeq)
if err != nil {
return
return nil, err
}
hasReadSeq = req.HasReadSeq
}
@ -177,6 +177,6 @@ func (m *msgServer) sendMarkAsReadNotification(
Seqs: seqs,
HasReadSeq: hasReadSeq,
}
m.notificationSender.NotificationWithSesstionType(ctx, sendID, recvID, constant.HasReadReceipt, sesstionType, tips)
m.notificationSender.NotificationWithSessionType(ctx, sendID, recvID, constant.HasReadReceipt, sesstionType, tips)
return nil
}

@ -29,7 +29,7 @@ import (
)
func cbURL() string {
return config.Config.Callback.CallbackUrl
return config.Config.Callback.CallbackURL
}
func toCommonCallback(ctx context.Context, msg *pbChat.SendMsgReq, command string) cbapi.CommonCallbackReq {

@ -86,7 +86,7 @@ func (m *msgServer) DeleteMsgs(ctx context.Context, req *msg.DeleteMsgsReq) (*ms
return nil, err
}
tips := &sdkws.DeleteMsgsTips{UserID: req.UserID, ConversationID: req.ConversationID, Seqs: req.Seqs}
m.notificationSender.NotificationWithSesstionType(
m.notificationSender.NotificationWithSessionType(
ctx,
req.UserID,
m.conversationAndGetRecvID(conversations[0], req.UserID),
@ -100,7 +100,7 @@ func (m *msgServer) DeleteMsgs(ctx context.Context, req *msg.DeleteMsgsReq) (*ms
}
if isSyncSelf {
tips := &sdkws.DeleteMsgsTips{UserID: req.UserID, ConversationID: req.ConversationID, Seqs: req.Seqs}
m.notificationSender.NotificationWithSesstionType(ctx, req.UserID, req.UserID, constant.DeleteMsgsNotification, constant.SingleChatType, tips)
m.notificationSender.NotificationWithSessionType(ctx, req.UserID, req.UserID, constant.DeleteMsgsNotification, constant.SingleChatType, tips)
}
}
return &msg.DeleteMsgsResp{}, nil
@ -171,7 +171,7 @@ func (m *msgServer) clearConversation(
// notification 2 self
if isSyncSelf {
tips := &sdkws.ClearConversationTips{UserID: userID, ConversationIDs: existConversationIDs}
m.notificationSender.NotificationWithSesstionType(
m.notificationSender.NotificationWithSessionType(
ctx,
userID,
userID,
@ -186,7 +186,7 @@ func (m *msgServer) clearConversation(
}
for _, conversation := range existConversations {
tips := &sdkws.ClearConversationTips{UserID: userID, ConversationIDs: []string{conversation.ConversationID}}
m.notificationSender.NotificationWithSesstionType(ctx, userID, m.conversationAndGetRecvID(conversation, userID), constant.ClearConversationNotification, conversation.ConversationType, tips)
m.notificationSender.NotificationWithSessionType(ctx, userID, m.conversationAndGetRecvID(conversation, userID), constant.ClearConversationNotification, conversation.ConversationType, tips)
}
}
if err := m.MsgDatabase.UserSetHasReadSeqs(ctx, userID, maxSeqs); err != nil {

@ -60,7 +60,7 @@ func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.
data, _ := json.Marshal(msgs[0])
log.ZInfo(ctx, "GetMsgBySeqs", "conversationID", req.ConversationID, "seq", req.Seq, "msg", string(data))
var role int32
if !tokenverify.IsAppManagerUid(ctx) {
if !tokenverify.IsAppManagerUID(ctx) {
switch msgs[0].SessionType {
case constant.SingleChatType:
if err := tokenverify.CheckAccessV3(ctx, msgs[0].SendID); err != nil {
@ -119,7 +119,7 @@ func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.
} else {
recvID = msgs[0].RecvID
}
if err := m.notificationSender.NotificationWithSesstionType(ctx, req.UserID, recvID, constant.MsgRevokeNotification, msgs[0].SessionType, &tips); err != nil {
if err := m.notificationSender.NotificationWithSessionType(ctx, req.UserID, recvID, constant.MsgRevokeNotification, msgs[0].SessionType, &tips); err != nil {
return nil, err
}
return &msg.RevokeMsgResp{}, nil

@ -30,7 +30,6 @@ import (
)
func (m *msgServer) SendMsg(ctx context.Context, req *pbMsg.SendMsgReq) (resp *pbMsg.SendMsgResp, error error) {
resp = &pbMsg.SendMsgResp{}
if req.MsgData != nil {
flag := isMessageHasReadEnabled(req.MsgData)
if !flag {
@ -101,9 +100,9 @@ func (m *msgServer) setConversationAtInfo(nctx context.Context, msg *sdkws.MsgDa
return
}
atUserID = utils.DifferenceString([]string{constant.AtAllString}, msg.AtUserIDList)
if len(atUserID) == 0 { //just @everyone
if len(atUserID) == 0 { // just @everyone
conversation.GroupAtType = &wrapperspb.Int32Value{Value: constant.AtAll}
} else { //@Everyone and @other people
} else { // @Everyone and @other people
conversation.GroupAtType = &wrapperspb.Int32Value{Value: constant.AtAllAtMe}
err := m.Conversation.SetConversations(ctx, atUserID, conversation)
if err != nil {

@ -20,9 +20,9 @@ type MessageInterceptorChain []MessageInterceptorFunc
type msgServer struct {
RegisterCenter discoveryregistry.SvcDiscoveryRegistry
MsgDatabase controller.CommonMsgDatabase
Group *rpcclient.GroupRpcClient
User *rpcclient.UserRpcClient
Conversation *rpcclient.ConversationRpcClient
Group *rpcclient.GroupRPCClient
User *rpcclient.UserRPCClient
Conversation *rpcclient.ConversationRPCClient
friend *rpcclient.FriendRpcClient
GroupLocalCache *localcache.GroupLocalCache
ConversationLocalCache *localcache.ConversationLocalCache
@ -61,13 +61,13 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
cacheModel := cache.NewMsgCacheModel(rdb)
msgDocModel := unrelation.NewMsgMongoDriver(mongo.GetDatabase())
msgDatabase := controller.NewCommonMsgDatabase(msgDocModel, cacheModel)
conversationClient := rpcclient.NewConversationRpcClient(client)
userRpcClient := rpcclient.NewUserRpcClient(client)
groupRpcClient := rpcclient.NewGroupRpcClient(client)
conversationClient := rpcclient.NewConversationRPCClient(client)
userRPCClient := rpcclient.NewUserRPCClient(client)
groupRpcClient := rpcclient.NewGroupRPCClient(client)
friendRpcClient := rpcclient.NewFriendRpcClient(client)
s := &msgServer{
Conversation: &conversationClient,
User: &userRpcClient,
User: &userRPCClient,
Group: &groupRpcClient,
MsgDatabase: msgDatabase,
RegisterCenter: client,

@ -62,7 +62,7 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
third.RegisterThirdServer(server, &thirdServer{
apiURL: apiURL,
thirdDatabase: controller.NewThirdDatabase(cache.NewMsgCacheModel(rdb)),
userRpcClient: rpcclient.NewUserRpcClient(client),
userRPCClient: rpcclient.NewUserRPCClient(client),
s3dataBase: controller.NewS3Database(o, relation.NewObjectInfo(db)),
defaultExpire: time.Hour * 24 * 7,
})
@ -73,7 +73,7 @@ type thirdServer struct {
apiURL string
thirdDatabase controller.ThirdDatabase
s3dataBase controller.S3Database
userRpcClient rpcclient.UserRpcClient
userRPCClient rpcclient.UserRPCClient
defaultExpire time.Duration
}

@ -30,7 +30,7 @@ import (
type userServer struct {
controller.UserDatabase
notificationSender *notification.FriendNotificationSender
friendRpcClient *rpcclient.FriendRpcClient
friendRPCClient *rpcclient.FriendRpcClient
RegisterCenter registry.SvcDiscoveryRegistry
}
@ -57,12 +57,12 @@ func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
cache := cache.NewUserCacheRedis(rdb, userDB, cache.GetDefaultOpt())
database := controller.NewUserDatabase(userDB, cache, tx.NewGorm(db))
friendRpcClient := rpcclient.NewFriendRpcClient(client)
msgRpcClient := rpcclient.NewMessageRpcClient(client)
msgRPCClient := rpcclient.NewMessageRpcClient(client)
u := &userServer{
UserDatabase: database,
RegisterCenter: client,
friendRpcClient: &friendRpcClient,
notificationSender: notification.NewFriendNotificationSender(&msgRpcClient, notification.WithDBFunc(database.FindWithError)),
friendRPCClient: &friendRpcClient,
notificationSender: notification.NewFriendNotificationSender(&msgRPCClient, notification.WithDBFunc(database.FindWithError)),
}
pbuser.RegisterUserServer(server, u)
return u.UserDatabase.InitOnce(context.Background(), users)
@ -96,7 +96,7 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbuser.UpdateUserI
return nil, err
}
_ = s.notificationSender.UserInfoUpdatedNotification(ctx, req.UserInfo.UserID)
friends, err := s.friendRpcClient.GetFriendIDs(ctx, req.UserInfo.UserID)
friends, err := s.friendRPCClient.GetFriendIDs(ctx, req.UserInfo.UserID)
if err != nil {
return nil, err
}

@ -69,8 +69,8 @@ func InitMsgTool() (*MsgTool, error) {
userDatabase := controller.NewUserDatabase(userDB, cache.NewUserCacheRedis(rdb, relation.NewUserGorm(db), cache.GetDefaultOpt()), tx.NewGorm(db))
groupDatabase := controller.InitGroupDatabase(db, rdb, mongo.GetDatabase())
conversationDatabase := controller.NewConversationDatabase(relation.NewConversationGorm(db), cache.NewConversationRedis(rdb, cache.GetDefaultOpt(), relation.NewConversationGorm(db)), tx.NewGorm(db))
msgRpcClient := rpcclient.NewMessageRpcClient(discov)
msgNotificationSender := notification.NewMsgNotificationSender(rpcclient.WithRpcClient(&msgRpcClient))
msgRPCClient := rpcclient.NewMessageRpcClient(discov)
msgNotificationSender := notification.NewMsgNotificationSender(rpcclient.WithRPCClient(&msgRPCClient))
msgTool := NewMsgTool(msgDatabase, userDatabase, groupDatabase, conversationDatabase, msgNotificationSender)
return msgTool, nil
}

@ -19,7 +19,7 @@ import (
"net/http"
)
func httpJson(w http.ResponseWriter, data any) {
func httpJSON(w http.ResponseWriter, data any) {
body, err := json.Marshal(data)
if err != nil {
http.Error(w, "json marshal error: "+err.Error(), http.StatusInternalServerError)
@ -31,9 +31,9 @@ func httpJson(w http.ResponseWriter, data any) {
}
func HttpError(w http.ResponseWriter, err error) {
httpJson(w, ParseError(err))
httpJSON(w, ParseError(err))
}
func HttpSuccess(w http.ResponseWriter, data any) {
httpJson(w, ApiSuccess(data))
httpJSON(w, ApiSuccess(data))
}

@ -19,7 +19,7 @@ type AwsStorageCredentialReq struct {
}
type AwsStorageCredentialRespData struct {
AccessKeyId string `json:"accessKeyID"`
AccessKeyID string `json:"accessKeyID"`
SecretAccessKey string `json:"secretAccessKey"`
SessionToken string `json:"sessionToken"`
RegionID string `json:"regionId"`

@ -50,7 +50,7 @@ type PictureBaseInfo struct {
Size int64 `mapstructure:"size" `
Width int32 `mapstructure:"width" `
Height int32 `mapstructure:"height"`
Url string `mapstructure:"url" `
URL string `mapstructure:"url" `
}
type PictureElem struct {
@ -114,7 +114,7 @@ type OANotificationElem struct {
NotificationFaceURL string `mapstructure:"notificationFaceURL" json:"notificationFaceURL"`
NotificationType int32 `mapstructure:"notificationType" json:"notificationType" validate:"required"`
Text string `mapstructure:"text" json:"text" validate:"required"`
Url string `mapstructure:"url" json:"url"`
URL string `mapstructure:"url" json:"url"`
MixType int32 `mapstructure:"mixType" json:"mixType"`
PictureElem PictureElem `mapstructure:"pictureElem" json:"pictureElem"`
SoundElem SoundElem `mapstructure:"soundElem" json:"soundElem"`

@ -22,7 +22,7 @@ type OSSCredentialReq struct {
type OSSCredentialRespData struct {
Endpoint string `json:"endpoint"`
AccessKeyId string `json:"access_key_id"`
AccessKeyID string `json:"access_key_id"`
AccessKeySecret string `json:"access_key_secret"`
Token string `json:"token"`
Bucket string `json:"bucket"`

@ -16,15 +16,15 @@ package cmd
import "github.com/spf13/cobra"
type ApiCmd struct {
type APICmd struct {
*RootCmd
}
func NewApiCmd() *ApiCmd {
return &ApiCmd{NewRootCmd("api")}
func NewApiCmd() *APICmd {
return &APICmd{NewRootCmd("api")}
}
func (a *ApiCmd) AddApi(f func(port int) error) {
func (a *APICmd) AddApi(f func(port int) error) {
a.Command.RunE = func(cmd *cobra.Command, args []string) error {
return f(a.getPortFlag(cmd))
}

@ -64,7 +64,7 @@ func NewRootCmd(name string, opts ...func(*CmdOpts)) (rootCmd *RootCmd) {
if cmdOpts.loggerPrefixName == "" {
cmdOpts.loggerPrefixName = "OpenIM.log.all"
}
if err := log.InitFromConfig(cmdOpts.loggerPrefixName, name, config.Config.Log.RemainLogLevel, config.Config.Log.IsStdout, config.Config.Log.IsJson, config.Config.Log.StorageLocation, config.Config.Log.RemainRotationCount); err != nil {
if err := log.InitFromConfig(cmdOpts.loggerPrefixName, name, config.Config.Log.RemainLogLevel, config.Config.Log.IsStdout, config.Config.Log.IsJSON, config.Config.Log.StorageLocation, config.Config.Log.RemainRotationCount); err != nil {
panic(err)
}
return nil

@ -64,7 +64,7 @@ type config struct {
} `yaml:"mysql"`
Mongo struct {
Uri string `yaml:"uri"`
URI string `yaml:"uri"`
Address []string `yaml:"address"`
Database string `yaml:"database"`
Username string `yaml:"username"`
@ -94,7 +94,7 @@ type config struct {
ConsumerGroupID struct {
MsgToRedis string `yaml:"msgToRedis"`
MsgToMongo string `yaml:"msgToMongo"`
MsgToMySql string `yaml:"msgToMySql"`
MsgToMySQL string `yaml:"msgToMySql"`
MsgToPush string `yaml:"msgToPush"`
} `yaml:"consumerGroupID"`
} `yaml:"kafka"`
@ -105,7 +105,7 @@ type config struct {
} `yaml:"rpc"`
Api struct {
OpenImApiPort []int `yaml:"openImApiPort"`
OpenImAPIPort []int `yaml:"openImApiPort"`
ListenIP string `yaml:"listenIP"`
} `yaml:"api"`
@ -135,7 +135,7 @@ type config struct {
} `yaml:"oss"`
} `yaml:"object"`
RpcPort struct {
RPCPort struct {
OpenImUserPort []int `yaml:"openImUserPort"`
OpenImFriendPort []int `yaml:"openImFriendPort"`
OpenImMessagePort []int `yaml:"openImMessagePort"`
@ -148,7 +148,7 @@ type config struct {
OpenImThirdPort []int `yaml:"openImThirdPort"`
} `yaml:"rpcPort"`
RpcRegisterName struct {
RPCRegisterName struct {
OpenImUserName string `yaml:"openImUserName"`
OpenImFriendName string `yaml:"openImFriendName"`
OpenImMsgName string `yaml:"openImMsgName"`
@ -166,7 +166,7 @@ type config struct {
RemainRotationCount uint `yaml:"remainRotationCount"`
RemainLogLevel int `yaml:"remainLogLevel"`
IsStdout bool `yaml:"isStdout"`
IsJson bool `yaml:"isJson"`
IsJSON bool `yaml:"isJson"`
WithStack bool `yaml:"withStack"`
} `yaml:"log"`
@ -180,7 +180,7 @@ type config struct {
Push struct {
Enable string `yaml:"enable"`
GeTui struct {
PushUrl string `yaml:"pushUrl"`
PushURL string `yaml:"pushUrl"`
AppKey string `yaml:"appKey"`
Intent string `yaml:"intent"`
MasterSecret string `yaml:"masterSecret"`
@ -193,7 +193,7 @@ type config struct {
Jpns struct {
AppKey string `yaml:"appKey"`
MasterSecret string `yaml:"masterSecret"`
PushUrl string `yaml:"pushUrl"`
PushURL string `yaml:"pushUrl"`
PushIntent string `yaml:"pushIntent"`
} `yaml:"jpns"`
}
@ -224,7 +224,7 @@ type config struct {
Production bool `yaml:"production"`
} `yaml:"iosPush"`
Callback struct {
CallbackUrl string `yaml:"url"`
CallbackURL string `yaml:"url"`
CallbackBeforeSendSingleMsg CallBackConfig `yaml:"beforeSendSingleMsg"`
CallbackAfterSendSingleMsg CallBackConfig `yaml:"afterSendSingleMsg"`
CallbackBeforeSendGroupMsg CallBackConfig `yaml:"beforeSendGroupMsg"`
@ -280,9 +280,9 @@ type notification struct {
GroupMemberSetToOrdinary NotificationConf `yaml:"groupMemberSetToOrdinaryUser"`
GroupInfoSetAnnouncement NotificationConf `yaml:"groupInfoSetAnnouncement"`
GroupInfoSetName NotificationConf `yaml:"groupInfoSetName"`
////////////////////////user///////////////////////
// //////////////////////user///////////////////////
UserInfoUpdated NotificationConf `yaml:"userInfoUpdated"`
//////////////////////friend///////////////////////
// ////////////////////friend///////////////////////
FriendApplicationAdded NotificationConf `yaml:"friendApplicationAdded"`
FriendApplicationApproved NotificationConf `yaml:"friendApplicationApproved"`
FriendApplicationRejected NotificationConf `yaml:"friendApplicationRejected"`
@ -292,21 +292,21 @@ type notification struct {
BlackAdded NotificationConf `yaml:"blackAdded"`
BlackDeleted NotificationConf `yaml:"blackDeleted"`
FriendInfoUpdated NotificationConf `yaml:"friendInfoUpdated"`
//////////////////////conversation///////////////////////
// ////////////////////conversation///////////////////////
ConversationChanged NotificationConf `yaml:"conversationChanged"`
ConversationSetPrivate NotificationConf `yaml:"conversationSetPrivate"`
}
func GetServiceNames() []string {
return []string{
Config.RpcRegisterName.OpenImUserName,
Config.RpcRegisterName.OpenImFriendName,
Config.RpcRegisterName.OpenImMsgName,
Config.RpcRegisterName.OpenImPushName,
Config.RpcRegisterName.OpenImMessageGatewayName,
Config.RpcRegisterName.OpenImGroupName,
Config.RpcRegisterName.OpenImAuthName,
Config.RpcRegisterName.OpenImConversationName,
Config.RpcRegisterName.OpenImThirdName,
Config.RPCRegisterName.OpenImUserName,
Config.RPCRegisterName.OpenImFriendName,
Config.RPCRegisterName.OpenImMsgName,
Config.RPCRegisterName.OpenImPushName,
Config.RPCRegisterName.OpenImMessageGatewayName,
Config.RPCRegisterName.OpenImGroupName,
Config.RPCRegisterName.OpenImAuthName,
Config.RPCRegisterName.OpenImConversationName,
Config.RPCRegisterName.OpenImThirdName,
}
}

@ -100,8 +100,8 @@ type MsgModel interface {
thirdCache
AddTokenFlag(ctx context.Context, userID string, platformID int, token string, flag int) error
GetTokensWithoutError(ctx context.Context, userID string, platformID int) (map[string]int, error)
SetTokenMapByUidPid(ctx context.Context, userID string, platformID int, m map[string]int) error
DeleteTokenByUidPid(ctx context.Context, userID string, platformID int, fields []string) error
SetTokenMapByUIDPid(ctx context.Context, userID string, platformID int, m map[string]int) error
DeleteTokenByUIDPid(ctx context.Context, userID string, platformID int, fields []string) error
GetMessagesBySeq(
ctx context.Context,
conversationID string,
@ -330,7 +330,7 @@ func (c *msgCache) GetTokensWithoutError(ctx context.Context, userID string, pla
return mm, nil
}
func (c *msgCache) SetTokenMapByUidPid(ctx context.Context, userID string, platform int, m map[string]int) error {
func (c *msgCache) SetTokenMapByUIDPid(ctx context.Context, userID string, platform int, m map[string]int) error {
key := uidPidToken + userID + ":" + constant.PlatformIDToName(platform)
mm := make(map[string]interface{})
for k, v := range m {
@ -339,7 +339,7 @@ func (c *msgCache) SetTokenMapByUidPid(ctx context.Context, userID string, platf
return errs.Wrap(c.rdb.HSet(ctx, key, mm).Err())
}
func (c *msgCache) DeleteTokenByUidPid(ctx context.Context, userID string, platform int, fields []string) error {
func (c *msgCache) DeleteTokenByUIDPid(ctx context.Context, userID string, platform int, fields []string) error {
key := uidPidToken + userID + ":" + constant.PlatformIDToName(platform)
return errs.Wrap(c.rdb.HDel(ctx, key, fields...).Err())
}
@ -359,7 +359,7 @@ func (c *msgCache) GetMessagesBySeq(
) (seqMsgs []*sdkws.MsgData, failedSeqs []int64, err error) {
pipe := c.rdb.Pipeline()
for _, v := range seqs {
//MESSAGE_CACHE:169.254.225.224_reliability1653387820_0_1
// MESSAGE_CACHE:169.254.225.224_reliability1653387820_0_1
key := c.getMessageCacheKey(conversationID, v)
if err := pipe.Get(ctx, key).Err(); err != nil && err != redis.Nil {
return nil, nil, err

@ -26,9 +26,9 @@ import (
)
type AuthDatabase interface {
//结果为空 不返回错误
// 结果为空 不返回错误
GetTokensWithoutError(ctx context.Context, userID string, platformID int) (map[string]int, error)
//创建token
// 创建token
CreateToken(ctx context.Context, userID string, platformID int) (string, error)
}
@ -66,7 +66,7 @@ func (a *authDatabase) CreateToken(ctx context.Context, userID string, platformI
}
}
if len(deleteTokenKey) != 0 {
err := a.cache.DeleteTokenByUidPid(ctx, userID, platformID, deleteTokenKey)
err := a.cache.DeleteTokenByUIDPid(ctx, userID, platformID, deleteTokenKey)
if err != nil {
return "", err
}

@ -26,7 +26,7 @@ type ConversationLocalCache struct {
lock sync.Mutex
superGroupRecvMsgNotNotifyUserIDs map[string]Hash
conversationIDs map[string]Hash
client *rpcclient.ConversationRpcClient
client *rpcclient.ConversationRPCClient
}
type Hash struct {
@ -34,7 +34,7 @@ type Hash struct {
ids []string
}
func NewConversationLocalCache(client *rpcclient.ConversationRpcClient) *ConversationLocalCache {
func NewConversationLocalCache(client *rpcclient.ConversationRPCClient) *ConversationLocalCache {
return &ConversationLocalCache{
superGroupRecvMsgNotNotifyUserIDs: make(map[string]Hash),
conversationIDs: make(map[string]Hash),

@ -26,7 +26,7 @@ import (
type GroupLocalCache struct {
lock sync.Mutex
cache map[string]GroupMemberIDsHash
client *rpcclient.GroupRpcClient
client *rpcclient.GroupRPCClient
}
type GroupMemberIDsHash struct {
@ -34,7 +34,7 @@ type GroupMemberIDsHash struct {
userIDs []string
}
func NewGroupLocalCache(client *rpcclient.GroupRpcClient) *GroupLocalCache {
func NewGroupLocalCache(client *rpcclient.GroupRPCClient) *GroupLocalCache {
return &GroupLocalCache{
cache: make(map[string]GroupMemberIDsHash, 0),
client: client,

@ -38,12 +38,12 @@ type Mongo struct {
func NewMongo() (*Mongo, error) {
specialerror.AddReplace(mongo.ErrNoDocuments, errs.ErrRecordNotFound)
uri := "mongodb://sample.host:27017/?maxPoolSize=20&w=majority"
if config.Config.Mongo.Uri != "" {
if config.Config.Mongo.URI != "" {
// example:
// mongodb://$user:$password@mongo1.mongo:27017,mongo2.mongo:27017,mongo3.mongo:27017/$DBDatabase/?replicaSet=rs0&readPreference=secondary&authSource=admin&maxPoolSize=$DBMaxPoolSize
uri = config.Config.Mongo.Uri
uri = config.Config.Mongo.URI
} else {
//mongodb://mongodb1.example.com:27317,mongodb2.example.com:27017/?replicaSet=mySet&authSource=authDB
// mongodb://mongodb1.example.com:27317,mongodb2.example.com:27017/?replicaSet=mySet&authSource=authDB
mongodbHosts := ""
for i, v := range config.Config.Mongo.Address {
if i == len(config.Config.Mongo.Address)-1 {

@ -50,16 +50,16 @@ func InitFromConfig(
loggerPrefixName, moduleName string,
logLevel int,
isStdout bool,
isJson bool,
isJSON bool,
logLocation string,
rotateCount uint,
) error {
l, err := NewZapLogger(loggerPrefixName, moduleName, logLevel, isStdout, isJson, logLocation, rotateCount)
l, err := NewZapLogger(loggerPrefixName, moduleName, logLevel, isStdout, isJSON, logLocation, rotateCount)
if err != nil {
return err
}
pkgLogger = l.WithCallDepth(2)
if isJson {
if isJSON {
pkgLogger = pkgLogger.WithName(moduleName)
}
return nil
@ -104,7 +104,7 @@ func NewZapLogger(
loggerPrefixName, loggerName string,
logLevel int,
isStdout bool,
isJson bool,
isJSON bool,
logLocation string,
rotateCount uint,
) (*ZapLogger, error) {
@ -114,7 +114,7 @@ func NewZapLogger(
// InitialFields: map[string]interface{}{"PID": os.Getegid()},
DisableStacktrace: true,
}
if isJson {
if isJSON {
zapConfig.Encoding = "json"
} else {
zapConfig.Encoding = "console"
@ -123,7 +123,7 @@ func NewZapLogger(
// zapConfig.OutputPaths = append(zapConfig.OutputPaths, "stdout", "stderr")
// }
zl := &ZapLogger{level: logLevelMap[logLevel], loggerName: loggerName, loggerPrefixName: loggerPrefixName}
opts, err := zl.cores(isStdout, isJson, logLocation, rotateCount)
opts, err := zl.cores(isStdout, isJSON, logLocation, rotateCount)
if err != nil {
return nil, err
}
@ -135,7 +135,7 @@ func NewZapLogger(
return zl, nil
}
func (l *ZapLogger) cores(isStdout bool, isJson bool, logLocation string, rotateCount uint) (zap.Option, error) {
func (l *ZapLogger) cores(isStdout bool, isJSON bool, logLocation string, rotateCount uint) (zap.Option, error) {
c := zap.NewProductionEncoderConfig()
c.EncodeTime = l.timeEncoder
c.EncodeDuration = zapcore.SecondsDurationEncoder
@ -145,7 +145,7 @@ func (l *ZapLogger) cores(isStdout bool, isJson bool, logLocation string, rotate
c.CallerKey = "caller"
c.NameKey = "logger"
var fileEncoder zapcore.Encoder
if isJson {
if isJSON {
c.EncodeLevel = zapcore.CapitalLevelEncoder
fileEncoder = zapcore.NewJSONEncoder(c)
fileEncoder.AddInt("PID", os.Getpid())

@ -45,7 +45,7 @@ func RpcClientInterceptor(
if ctx == nil {
return errs.ErrInternalServer.Wrap("call rpc request context is nil")
}
ctx, err = getRpcContext(ctx, method)
ctx, err = getRPCContext(ctx, method)
if err != nil {
return err
}
@ -74,7 +74,7 @@ func RpcClientInterceptor(
return errs.NewCodeError(int(sta.Code()), sta.Message()).Wrap()
}
func getRpcContext(ctx context.Context, method string) (context.Context, error) {
func getRPCContext(ctx context.Context, method string) (context.Context, error) {
// ctx, _ = context.WithTimeout(ctx, time.Second*5)
md := metadata.Pairs()
if keys, _ := ctx.Value(constant.RpcCustomHeader).([]string); len(keys) > 0 {

@ -20,17 +20,17 @@ import (
)
var (
//auth rpc
// auth rpc
UserLoginCounter prometheus.Counter
UserRegisterCounter prometheus.Counter
//seg
// seg
SeqGetSuccessCounter prometheus.Counter
SeqGetFailedCounter prometheus.Counter
SeqSetSuccessCounter prometheus.Counter
SeqSetFailedCounter prometheus.Counter
//msg-db
// msg-db
MsgInsertRedisSuccessCounter prometheus.Counter
MsgInsertRedisFailedCounter prometheus.Counter
MsgInsertMongoSuccessCounter prometheus.Counter
@ -40,7 +40,7 @@ var (
MsgPullFromMongoSuccessCounter prometheus.Counter
MsgPullFromMongoFailedCounter prometheus.Counter
//msg-ws
// msg-ws
MsgRecvTotalCounter prometheus.Counter
GetNewestSeqTotalCounter prometheus.Counter
PullMsgBySeqListTotalCounter prometheus.Counter
@ -50,7 +50,7 @@ var (
WorkSuperGroupChatMsgRecvSuccessCounter prometheus.Counter
OnlineUserGauge prometheus.Gauge
//msg-msg
// msg-msg
SingleChatMsgProcessSuccessCounter prometheus.Counter
SingleChatMsgProcessFailedCounter prometheus.Counter
GroupChatMsgProcessSuccessCounter prometheus.Counter
@ -58,14 +58,14 @@ var (
WorkSuperGroupChatMsgProcessSuccessCounter prometheus.Counter
WorkSuperGroupChatMsgProcessFailedCounter prometheus.Counter
//msg-push
// msg-push
MsgOnlinePushSuccessCounter prometheus.Counter
MsgOfflinePushSuccessCounter prometheus.Counter
MsgOfflinePushFailedCounter prometheus.Counter
// api
ApiRequestCounter prometheus.Counter
ApiRequestSuccessCounter prometheus.Counter
ApiRequestFailedCounter prometheus.Counter
APIRequestCounter prometheus.Counter
APIRequestSuccessCounter prometheus.Counter
APIRequestFailedCounter prometheus.Counter
// grpc
GrpcRequestCounter prometheus.Counter
@ -136,31 +136,31 @@ func NewSeqSetFailedCounter() {
})
}
func NewApiRequestCounter() {
if ApiRequestCounter != nil {
func NewAPIRequestCounter() {
if APIRequestCounter != nil {
return
}
ApiRequestCounter = promauto.NewCounter(prometheus.CounterOpts{
APIRequestCounter = promauto.NewCounter(prometheus.CounterOpts{
Name: "api_request",
Help: "The number of api request",
})
}
func NewApiRequestSuccessCounter() {
if ApiRequestSuccessCounter != nil {
func NewAPIRequestSuccessCounter() {
if APIRequestFailedCounter != nil {
return
}
ApiRequestSuccessCounter = promauto.NewCounter(prometheus.CounterOpts{
APIRequestFailedCounter = promauto.NewCounter(prometheus.CounterOpts{
Name: "api_request_success",
Help: "The number of api request success",
})
}
func NewApiRequestFailedCounter() {
if ApiRequestFailedCounter != nil {
func NewAPIRequestFailedCounter() {
if APIRequestFailedCounter != nil {
return
}
ApiRequestFailedCounter = promauto.NewCounter(prometheus.CounterOpts{
APIRequestFailedCounter = promauto.NewCounter(prometheus.CounterOpts{
Name: "api_request_failed",
Help: "The number of api request failed",
})

@ -29,7 +29,7 @@ import (
type Claims struct {
UserID string
PlatformID int //login platform
PlatformID int // login platform
jwt.RegisteredClaims
}
@ -40,9 +40,9 @@ func BuildClaims(uid string, platformID int, ttl int64) Claims {
UserID: uid,
PlatformID: platformID,
RegisteredClaims: jwt.RegisteredClaims{
ExpiresAt: jwt.NewNumericDate(now.Add(time.Duration(ttl*24) * time.Hour)), //Expiration time
IssuedAt: jwt.NewNumericDate(now), //Issuing time
NotBefore: jwt.NewNumericDate(before), //Begin Effective time
ExpiresAt: jwt.NewNumericDate(now.Add(time.Duration(ttl*24) * time.Hour)), // Expiration time
IssuedAt: jwt.NewNumericDate(now), // Issuing time
NotBefore: jwt.NewNumericDate(before), // Begin Effective time
}}
}
@ -87,7 +87,7 @@ func CheckAccessV3(ctx context.Context, ownerUserID string) (err error) {
return errs.ErrNoPermission.Wrap(utils.GetSelfFuncName())
}
func IsAppManagerUid(ctx context.Context) bool {
func IsAppManagerUID(ctx context.Context) bool {
return utils.IsContain(mcontext.GetOpUserID(ctx), config.Config.Manager.UserID)
}

@ -25,7 +25,7 @@ import (
)
func NewAuth(discov discoveryregistry.SvcDiscoveryRegistry) *Auth {
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImAuthName)
conn, err := discov.GetConn(context.Background(), config.Config.RPCRegisterName.OpenImAuthName)
if err != nil {
panic(err)
}

@ -18,7 +18,7 @@ type Conversation struct {
}
func NewConversation(discov discoveryregistry.SvcDiscoveryRegistry) *Conversation {
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImConversationName)
conn, err := discov.GetConn(context.Background(), config.Config.RPCRegisterName.OpenImConversationName)
if err != nil {
panic(err)
}
@ -26,13 +26,13 @@ func NewConversation(discov discoveryregistry.SvcDiscoveryRegistry) *Conversatio
return &Conversation{discov: discov, conn: conn, Client: client}
}
type ConversationRpcClient Conversation
type ConversationRPCClient Conversation
func NewConversationRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) ConversationRpcClient {
return ConversationRpcClient(*NewConversation(discov))
func NewConversationRPCClient(discov discoveryregistry.SvcDiscoveryRegistry) ConversationRPCClient {
return ConversationRPCClient(*NewConversation(discov))
}
func (c *ConversationRpcClient) GetSingleConversationRecvMsgOpt(ctx context.Context, userID, conversationID string) (int32, error) {
func (c *ConversationRPCClient) GetSingleConversationRecvMsgOpt(ctx context.Context, userID, conversationID string) (int32, error) {
var req pbConversation.GetConversationReq
req.OwnerUserID = userID
req.ConversationID = conversationID
@ -43,26 +43,26 @@ func (c *ConversationRpcClient) GetSingleConversationRecvMsgOpt(ctx context.Cont
return conversation.GetConversation().RecvMsgOpt, err
}
func (c *ConversationRpcClient) SingleChatFirstCreateConversation(ctx context.Context, recvID, sendID string) error {
func (c *ConversationRPCClient) SingleChatFirstCreateConversation(ctx context.Context, recvID, sendID string) error {
_, err := c.Client.CreateSingleChatConversations(ctx, &pbConversation.CreateSingleChatConversationsReq{RecvID: recvID, SendID: sendID})
return err
}
func (c *ConversationRpcClient) GroupChatFirstCreateConversation(ctx context.Context, groupID string, userIDs []string) error {
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 {
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 {
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
}
func (c *ConversationRpcClient) GetConversationIDs(ctx context.Context, ownerUserID string) ([]string, error) {
func (c *ConversationRPCClient) GetConversationIDs(ctx context.Context, ownerUserID string) ([]string, error) {
resp, err := c.Client.GetConversationIDs(ctx, &pbConversation.GetConversationIDsReq{UserID: ownerUserID})
if err != nil {
return nil, err
@ -70,7 +70,7 @@ func (c *ConversationRpcClient) GetConversationIDs(ctx context.Context, ownerUse
return resp.ConversationIDs, nil
}
func (c *ConversationRpcClient) GetConversation(ctx context.Context, ownerUserID, conversationID string) (*pbConversation.Conversation, error) {
func (c *ConversationRPCClient) GetConversation(ctx context.Context, ownerUserID, conversationID string) (*pbConversation.Conversation, error) {
resp, err := c.Client.GetConversation(ctx, &pbConversation.GetConversationReq{OwnerUserID: ownerUserID, ConversationID: conversationID})
if err != nil {
return nil, err
@ -78,7 +78,7 @@ func (c *ConversationRpcClient) GetConversation(ctx context.Context, ownerUserID
return resp.Conversation, nil
}
func (c *ConversationRpcClient) GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*pbConversation.Conversation, error) {
func (c *ConversationRPCClient) GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*pbConversation.Conversation, error) {
resp, err := c.Client.GetConversationsByConversationID(ctx, &pbConversation.GetConversationsByConversationIDReq{ConversationIDs: conversationIDs})
if err != nil {
return nil, err
@ -89,7 +89,7 @@ func (c *ConversationRpcClient) GetConversationsByConversationID(ctx context.Con
return resp.Conversations, nil
}
func (c *ConversationRpcClient) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*pbConversation.Conversation, error) {
func (c *ConversationRPCClient) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*pbConversation.Conversation, error) {
resp, err := c.Client.GetConversations(ctx, &pbConversation.GetConversationsReq{OwnerUserID: ownerUserID, ConversationIDs: conversationIDs})
if err != nil {
return nil, err

@ -32,7 +32,7 @@ type Friend struct {
}
func NewFriend(discov discoveryregistry.SvcDiscoveryRegistry) *Friend {
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImFriendName)
conn, err := discov.GetConn(context.Background(), config.Config.RPCRegisterName.OpenImFriendName)
if err != nil {
panic(err)
}

@ -36,7 +36,7 @@ type Group struct {
}
func NewGroup(discov discoveryregistry.SvcDiscoveryRegistry) *Group {
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImGroupName)
conn, err := discov.GetConn(context.Background(), config.Config.RPCRegisterName.OpenImGroupName)
if err != nil {
panic(err)
}
@ -44,13 +44,13 @@ func NewGroup(discov discoveryregistry.SvcDiscoveryRegistry) *Group {
return &Group{discov: discov, conn: conn, Client: client}
}
type GroupRpcClient Group
type GroupRPCClient Group
func NewGroupRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) GroupRpcClient {
return GroupRpcClient(*NewGroup(discov))
func NewGroupRPCClient(discov discoveryregistry.SvcDiscoveryRegistry) GroupRPCClient {
return GroupRPCClient(*NewGroup(discov))
}
func (g *GroupRpcClient) GetGroupInfos(
func (g *GroupRPCClient) GetGroupInfos(
ctx context.Context,
groupIDs []string,
complete bool,
@ -71,7 +71,7 @@ func (g *GroupRpcClient) GetGroupInfos(
return resp.GroupInfos, nil
}
func (g *GroupRpcClient) GetGroupInfo(ctx context.Context, groupID string) (*sdkws.GroupInfo, error) {
func (g *GroupRPCClient) GetGroupInfo(ctx context.Context, groupID string) (*sdkws.GroupInfo, error) {
groups, err := g.GetGroupInfos(ctx, []string{groupID}, true)
if err != nil {
return nil, err
@ -79,7 +79,7 @@ func (g *GroupRpcClient) GetGroupInfo(ctx context.Context, groupID string) (*sdk
return groups[0], nil
}
func (g *GroupRpcClient) GetGroupInfoMap(
func (g *GroupRPCClient) GetGroupInfoMap(
ctx context.Context,
groupIDs []string,
complete bool,
@ -93,7 +93,7 @@ func (g *GroupRpcClient) GetGroupInfoMap(
}), nil
}
func (g *GroupRpcClient) GetGroupMemberInfos(
func (g *GroupRPCClient) GetGroupMemberInfos(
ctx context.Context,
groupID string,
userIDs []string,
@ -116,7 +116,7 @@ func (g *GroupRpcClient) GetGroupMemberInfos(
return resp.Members, nil
}
func (g *GroupRpcClient) GetGroupMemberInfo(
func (g *GroupRPCClient) GetGroupMemberInfo(
ctx context.Context,
groupID string,
userID string,
@ -128,7 +128,7 @@ func (g *GroupRpcClient) GetGroupMemberInfo(
return members[0], nil
}
func (g *GroupRpcClient) GetGroupMemberInfoMap(
func (g *GroupRPCClient) GetGroupMemberInfoMap(
ctx context.Context,
groupID string,
userIDs []string,
@ -143,7 +143,7 @@ func (g *GroupRpcClient) GetGroupMemberInfoMap(
}), nil
}
func (g *GroupRpcClient) GetOwnerAndAdminInfos(
func (g *GroupRPCClient) GetOwnerAndAdminInfos(
ctx context.Context,
groupID string,
) ([]*sdkws.GroupMemberFullInfo, error) {
@ -157,7 +157,7 @@ func (g *GroupRpcClient) GetOwnerAndAdminInfos(
return resp.Members, nil
}
func (g *GroupRpcClient) GetOwnerInfo(ctx context.Context, groupID string) (*sdkws.GroupMemberFullInfo, error) {
func (g *GroupRPCClient) GetOwnerInfo(ctx context.Context, groupID string) (*sdkws.GroupMemberFullInfo, error) {
resp, err := g.Client.GetGroupMemberRoleLevel(ctx, &group.GetGroupMemberRoleLevelReq{
GroupID: groupID,
RoleLevels: []int32{constant.GroupOwner},
@ -165,7 +165,7 @@ func (g *GroupRpcClient) GetOwnerInfo(ctx context.Context, groupID string) (*sdk
return resp.Members[0], err
}
func (g *GroupRpcClient) GetGroupMemberIDs(ctx context.Context, groupID string) ([]string, error) {
func (g *GroupRPCClient) GetGroupMemberIDs(ctx context.Context, groupID string) ([]string, error) {
resp, err := g.Client.GetGroupMemberUserIDs(ctx, &group.GetGroupMemberUserIDsReq{
GroupID: groupID,
})
@ -175,7 +175,7 @@ func (g *GroupRpcClient) GetGroupMemberIDs(ctx context.Context, groupID string)
return resp.UserIDs, nil
}
func (g *GroupRpcClient) GetGroupInfoCache(ctx context.Context, groupID string) (*sdkws.GroupInfo, error) {
func (g *GroupRPCClient) GetGroupInfoCache(ctx context.Context, groupID string) (*sdkws.GroupInfo, error) {
resp, err := g.Client.GetGroupInfoCache(ctx, &group.GetGroupInfoCacheReq{
GroupID: groupID,
})
@ -185,7 +185,7 @@ func (g *GroupRpcClient) GetGroupInfoCache(ctx context.Context, groupID string)
return resp.GroupInfo, nil
}
func (g *GroupRpcClient) GetGroupMemberCache(
func (g *GroupRPCClient) GetGroupMemberCache(
ctx context.Context,
groupID string,
groupMemberID string,
@ -200,7 +200,7 @@ func (g *GroupRpcClient) GetGroupMemberCache(
return resp.Member, nil
}
func (g *GroupRpcClient) DismissGroup(ctx context.Context, groupID string) error {
func (g *GroupRPCClient) DismissGroup(ctx context.Context, groupID string) error {
_, err := g.Client.DismissGroup(ctx, &group.DismissGroupReq{
GroupID: groupID,
DeleteMember: true,

@ -112,7 +112,7 @@ type Message struct {
}
func NewMessage(discov discoveryregistry.SvcDiscoveryRegistry) *Message {
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImMsgName)
conn, err := discov.GetConn(context.Background(), config.Config.RPCRegisterName.OpenImMsgName)
if err != nil {
panic(err)
}
@ -164,15 +164,15 @@ func WithLocalSendMsg(sendMsg func(ctx context.Context, req *msg.SendMsgReq) (*m
}
}
func WithRpcClient(msgRpcClient *MessageRpcClient) NotificationSenderOptions {
func WithRPCClient(msgRpcClient *MessageRpcClient) NotificationSenderOptions {
return func(s *NotificationSender) {
s.sendMsg = msgRpcClient.SendMsg
}
}
func WithUserRpcClient(userRpcClient *UserRpcClient) NotificationSenderOptions {
func WithUserRPCClient(userRPCClient *UserRPCClient) NotificationSenderOptions {
return func(s *NotificationSender) {
s.getUserInfo = userRpcClient.GetUserInfo
s.getUserInfo = userRPCClient.GetUserInfo
}
}
@ -185,18 +185,17 @@ func NewNotificationSender(opts ...NotificationSenderOptions) *NotificationSende
}
type notificationOpt struct {
WithRpcGetUsername bool
WithRPCGetUsername bool
}
type NotificationOptions func(*notificationOpt)
func WithRpcGetUserName() NotificationOptions {
func WithRPCGetUserName() NotificationOptions {
return func(opt *notificationOpt) {
opt.WithRpcGetUsername = true
opt.WithRPCGetUsername = true
}
}
func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, sendID, recvID string, contentType, sesstionType int32, m proto.Message, opts ...NotificationOptions) (err error) {
func (s *NotificationSender) NotificationWithSessionType(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 {
@ -209,7 +208,7 @@ func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, s
}
var req msg.SendMsgReq
var msg sdkws.MsgData
if notificationOpt.WithRpcGetUsername && s.getUserInfo != nil {
if notificationOpt.WithRPCGetUsername && s.getUserInfo != nil {
userInfo, err := s.getUserInfo(ctx, sendID)
if err != nil {
log.ZWarn(ctx, "getUserInfo failed", err, "sendID", sendID)
@ -248,5 +247,5 @@ func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, s
}
func (s *NotificationSender) Notification(ctx context.Context, sendID, recvID string, contentType int32, m proto.Message, opts ...NotificationOptions) error {
return s.NotificationWithSesstionType(ctx, sendID, recvID, contentType, s.sessionTypeConf[contentType], m, opts...)
return s.NotificationWithSessionType(ctx, sendID, recvID, contentType, s.sessionTypeConf[contentType], m, opts...)
}

@ -27,7 +27,7 @@ type ConversationNotificationSender struct {
}
func NewConversationNotificationSender(msgRpcClient *rpcclient.MessageRpcClient) *ConversationNotificationSender {
return &ConversationNotificationSender{rpcclient.NewNotificationSender(rpcclient.WithRpcClient(msgRpcClient))}
return &ConversationNotificationSender{rpcclient.NewNotificationSender(rpcclient.WithRPCClient(msgRpcClient))}
}
// SetPrivate调用

@ -85,7 +85,7 @@ func NewFriendNotificationSender(
opts ...friendNotificationSenderOptions,
) *FriendNotificationSender {
f := &FriendNotificationSender{
NotificationSender: rpcclient.NewNotificationSender(rpcclient.WithRpcClient(msgRpcClient)),
NotificationSender: rpcclient.NewNotificationSender(rpcclient.WithRPCClient(msgRpcClient)),
}
for _, opt := range opts {
opt(f)

@ -16,9 +16,9 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
)
func NewGroupNotificationSender(db controller.GroupDatabase, msgRpcClient *rpcclient.MessageRpcClient, userRpcClient *rpcclient.UserRpcClient, fn func(ctx context.Context, userIDs []string) ([]CommonUser, error)) *GroupNotificationSender {
func NewGroupNotificationSender(db controller.GroupDatabase, msgRpcClient *rpcclient.MessageRpcClient, userRPCClient *rpcclient.UserRPCClient, fn func(ctx context.Context, userIDs []string) ([]CommonUser, error)) *GroupNotificationSender {
return &GroupNotificationSender{
NotificationSender: rpcclient.NewNotificationSender(rpcclient.WithRpcClient(msgRpcClient), rpcclient.WithUserRpcClient(userRpcClient)),
NotificationSender: rpcclient.NewNotificationSender(rpcclient.WithRPCClient(msgRpcClient), rpcclient.WithUserRPCClient(userRPCClient)),
getUsersInfo: fn,
db: db,
}
@ -103,7 +103,7 @@ func (g *GroupNotificationSender) getGroupMembers(ctx context.Context, groupID s
res = append(res, g.groupMemberDB2PB(member, user.AppMangerLevel))
delete(users, member.UserID)
}
//for userID, info := range users {
// for userID, info := range users {
// if info.AppMangerLevel == constant.AppAdmin {
// res = append(res, &sdkws.GroupMemberFullInfo{
// GroupID: groupID,
@ -113,7 +113,7 @@ func (g *GroupNotificationSender) getGroupMembers(ctx context.Context, groupID s
// AppMangerLevel: info.AppMangerLevel,
// })
// }
//}
// }
return res, nil
}
@ -250,7 +250,7 @@ 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())
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetNotification, tips, rpcclient.WithRPCGetUserName())
}
func (g *GroupNotificationSender) GroupInfoSetNameNotification(ctx context.Context, tips *sdkws.GroupInfoSetNameTips) (err error) {
@ -264,7 +264,7 @@ 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())
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetAnnouncementNotification, tips, rpcclient.WithRPCGetUserName())
}
func (g *GroupNotificationSender) JoinGroupApplicationNotification(ctx context.Context, req *pbGroup.JoinGroupReq) (err error) {

@ -32,5 +32,5 @@ func (m *MsgNotificationSender) MarkAsReadNotification(ctx context.Context, conv
Seqs: seqs,
HasReadSeq: hasReadSeq,
}
return m.NotificationWithSesstionType(ctx, sendID, recvID, constant.HasReadReceipt, sesstionType, tips)
return m.NotificationWithSessionType(ctx, sendID, recvID, constant.HasReadReceipt, sesstionType, tips)
}

@ -31,7 +31,7 @@ type Push struct {
}
func NewPush(discov discoveryregistry.SvcDiscoveryRegistry) *Push {
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImPushName)
conn, err := discov.GetConn(context.Background(), config.Config.RPCRegisterName.OpenImPushName)
if err != nil {
panic(err)
}
@ -42,13 +42,13 @@ func NewPush(discov discoveryregistry.SvcDiscoveryRegistry) *Push {
}
}
type PushRpcClient Push
type PushRPCClient Push
func NewPushRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) PushRpcClient {
return PushRpcClient(*NewPush(discov))
func NewPushRPCClient(discov discoveryregistry.SvcDiscoveryRegistry) PushRPCClient {
return PushRPCClient(*NewPush(discov))
}
func (p *PushRpcClient) DelUserPushToken(
func (p *PushRPCClient) DelUserPushToken(
ctx context.Context,
req *push.DelUserPushTokenReq,
) (*push.DelUserPushTokenResp, error) {

@ -31,7 +31,7 @@ type Third struct {
}
func NewThird(discov discoveryregistry.SvcDiscoveryRegistry) *Third {
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImThirdName)
conn, err := discov.GetConn(context.Background(), config.Config.RPCRegisterName.OpenImThirdName)
if err != nil {
panic(err)
}

@ -36,7 +36,7 @@ type User struct {
}
func NewUser(discov discoveryregistry.SvcDiscoveryRegistry) *User {
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImUserName)
conn, err := discov.GetConn(context.Background(), config.Config.RPCRegisterName.OpenImUserName)
if err != nil {
panic(err)
}
@ -44,13 +44,13 @@ func NewUser(discov discoveryregistry.SvcDiscoveryRegistry) *User {
return &User{Discov: discov, Client: client, conn: conn}
}
type UserRpcClient User
type UserRPCClient User
func NewUserRpcClient(client discoveryregistry.SvcDiscoveryRegistry) UserRpcClient {
return UserRpcClient(*NewUser(client))
func NewUserRPCClient(client discoveryregistry.SvcDiscoveryRegistry) UserRPCClient {
return UserRPCClient(*NewUser(client))
}
func (u *UserRpcClient) GetUsersInfo(ctx context.Context, userIDs []string) ([]*sdkws.UserInfo, error) {
func (u *UserRPCClient) GetUsersInfo(ctx context.Context, userIDs []string) ([]*sdkws.UserInfo, error) {
resp, err := u.Client.GetDesignateUsers(ctx, &user.GetDesignateUsersReq{
UserIDs: userIDs,
})
@ -65,7 +65,7 @@ func (u *UserRpcClient) GetUsersInfo(ctx context.Context, userIDs []string) ([]*
return resp.UsersInfo, nil
}
func (u *UserRpcClient) GetUserInfo(ctx context.Context, userID string) (*sdkws.UserInfo, error) {
func (u *UserRPCClient) GetUserInfo(ctx context.Context, userID string) (*sdkws.UserInfo, error) {
users, err := u.GetUsersInfo(ctx, []string{userID})
if err != nil {
return nil, err
@ -73,7 +73,7 @@ func (u *UserRpcClient) GetUserInfo(ctx context.Context, userID string) (*sdkws.
return users[0], nil
}
func (u *UserRpcClient) GetUsersInfoMap(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error) {
func (u *UserRPCClient) GetUsersInfoMap(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error) {
users, err := u.GetUsersInfo(ctx, userIDs)
if err != nil {
return nil, err
@ -83,7 +83,7 @@ func (u *UserRpcClient) GetUsersInfoMap(ctx context.Context, userIDs []string) (
}), nil
}
func (u *UserRpcClient) GetPublicUserInfos(
func (u *UserRPCClient) GetPublicUserInfos(
ctx context.Context,
userIDs []string,
complete bool,
@ -102,7 +102,7 @@ func (u *UserRpcClient) GetPublicUserInfos(
}), nil
}
func (u *UserRpcClient) GetPublicUserInfo(ctx context.Context, userID string) (*sdkws.PublicUserInfo, error) {
func (u *UserRPCClient) GetPublicUserInfo(ctx context.Context, userID string) (*sdkws.PublicUserInfo, error) {
users, err := u.GetPublicUserInfos(ctx, []string{userID}, true)
if err != nil {
return nil, err
@ -110,7 +110,7 @@ func (u *UserRpcClient) GetPublicUserInfo(ctx context.Context, userID string) (*
return users[0], nil
}
func (u *UserRpcClient) GetPublicUserInfoMap(
func (u *UserRPCClient) GetPublicUserInfoMap(
ctx context.Context,
userIDs []string,
complete bool,
@ -124,7 +124,7 @@ func (u *UserRpcClient) GetPublicUserInfoMap(
}), nil
}
func (u *UserRpcClient) GetUserGlobalMsgRecvOpt(ctx context.Context, userID string) (int32, error) {
func (u *UserRPCClient) GetUserGlobalMsgRecvOpt(ctx context.Context, userID string) (int32, error) {
resp, err := u.Client.GetGlobalRecvMessageOpt(ctx, &user.GetGlobalRecvMessageOptReq{
UserID: userID,
})
@ -134,7 +134,7 @@ func (u *UserRpcClient) GetUserGlobalMsgRecvOpt(ctx context.Context, userID stri
return resp.GlobalRecvMsgOpt, err
}
func (u *UserRpcClient) Access(ctx context.Context, ownerUserID string) error {
func (u *UserRPCClient) Access(ctx context.Context, ownerUserID string) error {
_, err := u.GetUserInfo(ctx, ownerUserID)
if err != nil {
return err

@ -88,7 +88,7 @@ func StructToJsonBytes(param interface{}) []byte {
}
// The incoming parameter must be a pointer
func JsonStringToStruct(s string, args interface{}) error {
func JSONStringToStruct(s string, args interface{}) error {
err := json.Unmarshal([]byte(s), args)
return err
}

Loading…
Cancel
Save