mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-06-26 22:40:40 +08:00
Merge branch 'openimsdk:main' into main
This commit is contained in:
commit
0bbc359e2a
2
go.mod
2
go.mod
@ -12,7 +12,7 @@ require (
|
|||||||
github.com/gorilla/websocket v1.5.1
|
github.com/gorilla/websocket v1.5.1
|
||||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
|
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
|
||||||
github.com/mitchellh/mapstructure v1.5.0
|
github.com/mitchellh/mapstructure v1.5.0
|
||||||
github.com/openimsdk/protocol v0.0.73-alpha.6
|
github.com/openimsdk/protocol v0.0.73-alpha.8
|
||||||
github.com/openimsdk/tools v0.0.50-alpha.83
|
github.com/openimsdk/tools v0.0.50-alpha.83
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/prometheus/client_golang v1.18.0
|
github.com/prometheus/client_golang v1.18.0
|
||||||
|
4
go.sum
4
go.sum
@ -347,8 +347,8 @@ github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y=
|
|||||||
github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
|
github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
|
||||||
github.com/openimsdk/gomake v0.0.15-alpha.5 h1:eEZCEHm+NsmcO3onXZPIUbGFCYPYbsX5beV3ZyOsGhY=
|
github.com/openimsdk/gomake v0.0.15-alpha.5 h1:eEZCEHm+NsmcO3onXZPIUbGFCYPYbsX5beV3ZyOsGhY=
|
||||||
github.com/openimsdk/gomake v0.0.15-alpha.5/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
|
github.com/openimsdk/gomake v0.0.15-alpha.5/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
|
||||||
github.com/openimsdk/protocol v0.0.73-alpha.6 h1:sna9coWG7HN1zObBPtvG0Ki/vzqHXiB4qKbA5P3w7kc=
|
github.com/openimsdk/protocol v0.0.73-alpha.8 h1:GqksOHXWZSqRQaGYvuVQ4IzA7kFhIXSk7NZk0LGk35A=
|
||||||
github.com/openimsdk/protocol v0.0.73-alpha.6/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw=
|
github.com/openimsdk/protocol v0.0.73-alpha.8/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw=
|
||||||
github.com/openimsdk/tools v0.0.50-alpha.83 h1:7c1D40YGqIWUmGfCII5pduETGC/8c2DyS9SQ4LvoplU=
|
github.com/openimsdk/tools v0.0.50-alpha.83 h1:7c1D40YGqIWUmGfCII5pduETGC/8c2DyS9SQ4LvoplU=
|
||||||
github.com/openimsdk/tools v0.0.50-alpha.83/go.mod h1:n2poR3asX1e1XZce4O+MOWAp+X02QJRFvhcLCXZdzRo=
|
github.com/openimsdk/tools v0.0.50-alpha.83/go.mod h1:n2poR3asX1e1XZce4O+MOWAp+X02QJRFvhcLCXZdzRo=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
||||||
|
@ -467,6 +467,10 @@ func (m *MessageApi) SendSimpleMessage(c *gin.Context) {
|
|||||||
sessionType int32
|
sessionType int32
|
||||||
recvID string
|
recvID string
|
||||||
)
|
)
|
||||||
|
if err = c.BindJSON(&req); err != nil {
|
||||||
|
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
||||||
|
return
|
||||||
|
}
|
||||||
err = json.Unmarshal(decodedData, &keyMsgData)
|
err = json.Unmarshal(decodedData, &keyMsgData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
||||||
@ -490,6 +494,11 @@ func (m *MessageApi) SendSimpleMessage(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
content, err := jsonutil.JsonMarshal(apistruct.MarkdownTextElem{Content: req.Content})
|
||||||
|
if err != nil {
|
||||||
|
apiresp.GinError(c, errs.Wrap(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
msgData := &sdkws.MsgData{
|
msgData := &sdkws.MsgData{
|
||||||
SendID: sendID,
|
SendID: sendID,
|
||||||
RecvID: recvID,
|
RecvID: recvID,
|
||||||
@ -498,17 +507,17 @@ func (m *MessageApi) SendSimpleMessage(c *gin.Context) {
|
|||||||
SenderPlatformID: constant.AdminPlatformID,
|
SenderPlatformID: constant.AdminPlatformID,
|
||||||
SessionType: sessionType,
|
SessionType: sessionType,
|
||||||
MsgFrom: constant.UserMsgType,
|
MsgFrom: constant.UserMsgType,
|
||||||
ContentType: constant.Text,
|
ContentType: constant.MarkdownText,
|
||||||
Content: []byte(req.Content),
|
Content: content,
|
||||||
OfflinePushInfo: req.OfflinePushInfo,
|
OfflinePushInfo: req.OfflinePushInfo,
|
||||||
Ex: req.Ex,
|
Ex: req.Ex,
|
||||||
}
|
}
|
||||||
|
|
||||||
sendReq := &msg.SendMsgReq{
|
sendReq := &msg.SendSimpleMsgReq{
|
||||||
MsgData: msgData,
|
MsgData: msgData,
|
||||||
}
|
}
|
||||||
|
|
||||||
respPb, err := m.Client.SendMsg(c, sendReq)
|
respPb, err := m.Client.SendSimpleMsg(c, sendReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
apiresp.GinError(c, err)
|
apiresp.GinError(c, err)
|
||||||
return
|
return
|
||||||
@ -525,7 +534,12 @@ func (m *MessageApi) SendSimpleMessage(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
m.ginRespSendMsg(c, sendReq, respPb)
|
m.ginRespSendMsg(c, &msg.SendMsgReq{MsgData: sendReq.MsgData}, &msg.SendMsgResp{
|
||||||
|
ServerMsgID: respPb.ServerMsgID,
|
||||||
|
ClientMsgID: respPb.ClientMsgID,
|
||||||
|
SendTime: respPb.SendTime,
|
||||||
|
Modify: respPb.Modify,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) CheckMsgIsSendSuccess(c *gin.Context) {
|
func (m *MessageApi) CheckMsgIsSendSuccess(c *gin.Context) {
|
||||||
|
@ -250,6 +250,7 @@ func newGinRouter(ctx context.Context, client discovery.Conn, cfg *Config) (*gin
|
|||||||
msgGroup.POST("/delete_msg_physical", m.DeleteMsgPhysical)
|
msgGroup.POST("/delete_msg_physical", m.DeleteMsgPhysical)
|
||||||
|
|
||||||
msgGroup.POST("/batch_send_msg", m.BatchSendMsg)
|
msgGroup.POST("/batch_send_msg", m.BatchSendMsg)
|
||||||
|
msgGroup.POST("/send_simple_msg", m.SendSimpleMessage)
|
||||||
msgGroup.POST("/check_msg_is_send_success", m.CheckMsgIsSendSuccess)
|
msgGroup.POST("/check_msg_is_send_success", m.CheckMsgIsSendSuccess)
|
||||||
msgGroup.POST("/get_server_time", m.GetServerTime)
|
msgGroup.POST("/get_server_time", m.GetServerTime)
|
||||||
}
|
}
|
||||||
|
@ -379,9 +379,9 @@ func (g *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite
|
|||||||
}
|
}
|
||||||
|
|
||||||
var groupMember *model.GroupMember
|
var groupMember *model.GroupMember
|
||||||
var opUserID string
|
opUserID := mcontext.GetOpUserID(ctx)
|
||||||
|
|
||||||
if !authverify.IsAdmin(ctx) {
|
if !authverify.IsAdmin(ctx) {
|
||||||
opUserID = mcontext.GetOpUserID(ctx)
|
|
||||||
var err error
|
var err error
|
||||||
groupMember, err = g.db.TakeGroupMember(ctx, req.GroupID, opUserID)
|
groupMember, err = g.db.TakeGroupMember(ctx, req.GroupID, opUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -390,8 +390,6 @@ func (g *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite
|
|||||||
if err := g.PopulateGroupMember(ctx, groupMember); err != nil {
|
if err := g.PopulateGroupMember(ctx, groupMember); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
opUserID = mcontext.GetOpUserID(ctx)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := g.webhookBeforeInviteUserToGroup(ctx, &g.config.WebhooksConfig.BeforeInviteUserToGroup, req); err != nil && err != servererrs.ErrCallbackContinue {
|
if err := g.webhookBeforeInviteUserToGroup(ctx, &g.config.WebhooksConfig.BeforeInviteUserToGroup, req); err != nil && err != servererrs.ErrCallbackContinue {
|
||||||
@ -450,10 +448,7 @@ func (g *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite
|
|||||||
|
|
||||||
const singleQuantity = 50
|
const singleQuantity = 50
|
||||||
for start := 0; start < len(groupMembers); start += singleQuantity {
|
for start := 0; start < len(groupMembers); start += singleQuantity {
|
||||||
end := start + singleQuantity
|
end := min(start+singleQuantity, len(groupMembers))
|
||||||
if end > len(groupMembers) {
|
|
||||||
end = len(groupMembers)
|
|
||||||
}
|
|
||||||
currentMembers := groupMembers[start:end]
|
currentMembers := groupMembers[start:end]
|
||||||
|
|
||||||
if err := g.db.CreateGroup(ctx, nil, currentMembers); err != nil {
|
if err := g.db.CreateGroup(ctx, nil, currentMembers); err != nil {
|
||||||
@ -464,8 +459,8 @@ func (g *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite
|
|||||||
return e.UserID
|
return e.UserID
|
||||||
})
|
})
|
||||||
|
|
||||||
if err = g.notification.GroupApplicationAgreeMemberEnterNotification(ctx, req.GroupID, req.SendMessage, opUserID, userIDs...); err != nil {
|
if len(userIDs) != 0 {
|
||||||
return nil, err
|
g.notification.GroupApplicationAgreeMemberEnterNotification(ctx, req.GroupID, req.SendMessage, opUserID, userIDs...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &pbgroup.InviteUserToGroupResp{}, nil
|
return &pbgroup.InviteUserToGroupResp{}, nil
|
||||||
|
@ -201,3 +201,25 @@ func (m *msgServer) sendMsgSingleChat(ctx context.Context, req *pbmsg.SendMsgReq
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *msgServer) SendSimpleMsg(ctx context.Context, req *pbmsg.SendSimpleMsgReq) (*pbmsg.SendSimpleMsgResp, error) {
|
||||||
|
if req.MsgData == nil {
|
||||||
|
return nil, errs.ErrArgs.WrapMsg("msg data is nil")
|
||||||
|
}
|
||||||
|
sender, err := m.UserLocalCache.GetUserInfo(ctx, req.MsgData.SendID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
req.MsgData.SenderFaceURL = sender.FaceURL
|
||||||
|
req.MsgData.SenderNickname = sender.Nickname
|
||||||
|
resp, err := m.SendMsg(ctx, &pbmsg.SendMsgReq{MsgData: req.MsgData})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &pbmsg.SendSimpleMsgResp{
|
||||||
|
ServerMsgID: resp.ServerMsgID,
|
||||||
|
ClientMsgID: resp.ClientMsgID,
|
||||||
|
SendTime: resp.SendTime,
|
||||||
|
Modify: resp.Modify,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
@ -197,6 +197,7 @@ func (s *userServer) UpdateUserInfoEx(ctx context.Context, req *pbuser.UpdateUse
|
|||||||
}
|
}
|
||||||
|
|
||||||
s.friendNotificationSender.UserInfoUpdatedNotification(ctx, req.UserInfo.UserID)
|
s.friendNotificationSender.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 {
|
//if err != nil {
|
||||||
// return nil, err
|
// return nil, err
|
||||||
@ -209,6 +210,7 @@ func (s *userServer) UpdateUserInfoEx(ctx context.Context, req *pbuser.UpdateUse
|
|||||||
//for _, friendID := range friends {
|
//for _, friendID := range friends {
|
||||||
// s.friendNotificationSender.FriendInfoUpdatedNotification(ctx, req.UserInfo.UserID, friendID)
|
// s.friendNotificationSender.FriendInfoUpdatedNotification(ctx, req.UserInfo.UserID, friendID)
|
||||||
//}
|
//}
|
||||||
|
|
||||||
s.webhookAfterUpdateUserInfoEx(ctx, &s.config.WebhooksConfig.AfterUpdateUserInfoEx, req)
|
s.webhookAfterUpdateUserInfoEx(ctx, &s.config.WebhooksConfig.AfterUpdateUserInfoEx, req)
|
||||||
if err := s.NotificationUserInfoUpdate(ctx, req.UserInfo.UserID, oldUser); err != nil {
|
if err := s.NotificationUserInfoUpdate(ctx, req.UserInfo.UserID, oldUser); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user