mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-04 09:05:59 +08:00
callback start
This commit is contained in:
@@ -41,13 +41,9 @@ type CommonCallbackResp struct {
|
||||
ActionCode int `json:"actionCode"`
|
||||
ErrCode int32 `json:"errCode"`
|
||||
ErrMsg string `json:"errMsg"`
|
||||
//OperationID string `json:"operationID"`
|
||||
}
|
||||
|
||||
func (c *CommonCallbackResp) Parse() error {
|
||||
if c == nil {
|
||||
return constant.ErrData.Wrap("callback common is nil")
|
||||
}
|
||||
func (c CommonCallbackResp) Parse() error {
|
||||
if c.ActionCode != constant.NoError || c.ErrCode != constant.NoError {
|
||||
newErr := constant.ErrCallback
|
||||
newErr.ErrCode = c.ErrCode
|
||||
|
||||
@@ -9,5 +9,5 @@ type CallbackBeforeAddFriendReq struct {
|
||||
}
|
||||
|
||||
type CallbackBeforeAddFriendResp struct {
|
||||
*CommonCallbackResp
|
||||
CommonCallbackResp
|
||||
}
|
||||
|
||||
+20
-14
@@ -5,15 +5,21 @@ import (
|
||||
common "Open_IM/pkg/proto/sdkws"
|
||||
)
|
||||
|
||||
type CallbackCommand string
|
||||
|
||||
func (c CallbackCommand) GetCallbackCommand() string {
|
||||
return string(c)
|
||||
}
|
||||
|
||||
type CallbackBeforeCreateGroupReq struct {
|
||||
CallbackCommand string `json:"callbackCommand"`
|
||||
OperationID string `json:"operationID"`
|
||||
CallbackCommand `json:"callbackCommand"`
|
||||
common.GroupInfo
|
||||
InitMemberList []*apistruct.GroupAddMemberInfo `json:"initMemberList"`
|
||||
}
|
||||
|
||||
type CallbackBeforeCreateGroupResp struct {
|
||||
*CommonCallbackResp
|
||||
CommonCallbackResp
|
||||
GroupID *string `json:"groupID"`
|
||||
GroupName *string `json:"groupName"`
|
||||
Notification *string `json:"notification"`
|
||||
@@ -30,7 +36,7 @@ type CallbackBeforeCreateGroupResp struct {
|
||||
}
|
||||
|
||||
type CallbackBeforeMemberJoinGroupReq struct {
|
||||
CallbackCommand string `json:"callbackCommand"`
|
||||
CallbackCommand `json:"callbackCommand"`
|
||||
OperationID string `json:"operationID"`
|
||||
GroupID string `json:"groupID"`
|
||||
UserID string `json:"userID"`
|
||||
@@ -39,8 +45,8 @@ type CallbackBeforeMemberJoinGroupReq struct {
|
||||
}
|
||||
|
||||
type CallbackBeforeMemberJoinGroupResp struct {
|
||||
*CommonCallbackResp
|
||||
NickName *string `json:"nickName"`
|
||||
CommonCallbackResp
|
||||
Nickname *string `json:"nickname"`
|
||||
FaceURL *string `json:"faceURL"`
|
||||
RoleLevel *int32 `json:"roleLevel"`
|
||||
MuteEndTime *int64 `json:"muteEndTime"`
|
||||
@@ -48,18 +54,18 @@ type CallbackBeforeMemberJoinGroupResp struct {
|
||||
}
|
||||
|
||||
type CallbackBeforeSetGroupMemberInfoReq struct {
|
||||
CallbackCommand string `json:"callbackCommand"`
|
||||
OperationID string `json:"operationID"`
|
||||
GroupID string `json:"groupID"`
|
||||
UserID string `json:"userID"`
|
||||
Nickname string `json:"nickName"`
|
||||
FaceURL string `json:"faceURL"`
|
||||
RoleLevel int32 `json:"roleLevel"`
|
||||
Ex string `json:"ex"`
|
||||
CallbackCommand `json:"callbackCommand"`
|
||||
OperationID string `json:"operationID"`
|
||||
GroupID string `json:"groupID"`
|
||||
UserID string `json:"userID"`
|
||||
Nickname *string `json:"nickName"`
|
||||
FaceURL *string `json:"faceURL"`
|
||||
RoleLevel *int32 `json:"roleLevel"`
|
||||
Ex *string `json:"ex"`
|
||||
}
|
||||
|
||||
type CallbackBeforeSetGroupMemberInfoResp struct {
|
||||
*CommonCallbackResp
|
||||
CommonCallbackResp
|
||||
Ex *string `json:"ex"`
|
||||
Nickname *string `json:"nickName"`
|
||||
FaceURL *string `json:"faceURL"`
|
||||
|
||||
@@ -11,7 +11,7 @@ type CallbackBeforeSendSingleMsgReq struct {
|
||||
}
|
||||
|
||||
type CallbackBeforeSendSingleMsgResp struct {
|
||||
*CommonCallbackResp
|
||||
CommonCallbackResp
|
||||
}
|
||||
|
||||
type CallbackAfterSendSingleMsgReq struct {
|
||||
@@ -20,7 +20,7 @@ type CallbackAfterSendSingleMsgReq struct {
|
||||
}
|
||||
|
||||
type CallbackAfterSendSingleMsgResp struct {
|
||||
*CommonCallbackResp
|
||||
CommonCallbackResp
|
||||
}
|
||||
|
||||
type CallbackBeforeSendGroupMsgReq struct {
|
||||
@@ -29,7 +29,7 @@ type CallbackBeforeSendGroupMsgReq struct {
|
||||
}
|
||||
|
||||
type CallbackBeforeSendGroupMsgResp struct {
|
||||
*CommonCallbackResp
|
||||
CommonCallbackResp
|
||||
}
|
||||
|
||||
type CallbackAfterSendGroupMsgReq struct {
|
||||
@@ -38,7 +38,7 @@ type CallbackAfterSendGroupMsgReq struct {
|
||||
}
|
||||
|
||||
type CallbackAfterSendGroupMsgResp struct {
|
||||
*CommonCallbackResp
|
||||
CommonCallbackResp
|
||||
}
|
||||
|
||||
type CallbackMsgModifyCommandReq struct {
|
||||
@@ -46,7 +46,7 @@ type CallbackMsgModifyCommandReq struct {
|
||||
}
|
||||
|
||||
type CallbackMsgModifyCommandResp struct {
|
||||
*CommonCallbackResp
|
||||
CommonCallbackResp
|
||||
Content *string `json:"content"`
|
||||
RecvID *string `json:"recvID"`
|
||||
GroupID *string `json:"groupID"`
|
||||
@@ -79,7 +79,7 @@ type CallbackBeforeSetMessageReactionExtReq struct {
|
||||
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
||||
}
|
||||
type CallbackBeforeSetMessageReactionExtResp struct {
|
||||
*CommonCallbackResp
|
||||
CommonCallbackResp
|
||||
ResultReactionExtensionList []*msg.KeyValueResp `json:"resultReactionExtensionList"`
|
||||
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
||||
}
|
||||
@@ -95,7 +95,7 @@ type CallbackDeleteMessageReactionExtReq struct {
|
||||
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
||||
}
|
||||
type CallbackDeleteMessageReactionExtResp struct {
|
||||
*CommonCallbackResp
|
||||
CommonCallbackResp
|
||||
ResultReactionExtensionList []*msg.KeyValueResp `json:"resultReactionExtensionList"`
|
||||
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ type CallbackUserOnlineReq struct {
|
||||
}
|
||||
|
||||
type CallbackUserOnlineResp struct {
|
||||
*CommonCallbackResp
|
||||
CommonCallbackResp
|
||||
}
|
||||
|
||||
type CallbackUserOfflineReq struct {
|
||||
@@ -19,7 +19,7 @@ type CallbackUserOfflineReq struct {
|
||||
}
|
||||
|
||||
type CallbackUserOfflineResp struct {
|
||||
*CommonCallbackResp
|
||||
CommonCallbackResp
|
||||
}
|
||||
|
||||
type CallbackUserKickOffReq struct {
|
||||
@@ -28,5 +28,5 @@ type CallbackUserKickOffReq struct {
|
||||
}
|
||||
|
||||
type CallbackUserKickOffResp struct {
|
||||
*CommonCallbackResp
|
||||
CommonCallbackResp
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ type CallbackBeforePushReq struct {
|
||||
}
|
||||
|
||||
type CallbackBeforePushResp struct {
|
||||
*CommonCallbackResp
|
||||
CommonCallbackResp
|
||||
UserIDList []string `json:"userIDList"`
|
||||
OfflinePushInfo *common.OfflinePushInfo `json:"offlinePushInfo"`
|
||||
}
|
||||
@@ -34,7 +34,7 @@ type CallbackBeforeSuperGroupOnlinePushReq struct {
|
||||
}
|
||||
|
||||
type CallbackBeforeSuperGroupOnlinePushResp struct {
|
||||
*CommonCallbackResp
|
||||
CommonCallbackResp
|
||||
UserIDList []string `json:"userIDList"`
|
||||
OfflinePushInfo *common.OfflinePushInfo `json:"offlinePushInfo"`
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ type GroupInterface interface {
|
||||
|
||||
var _ GroupInterface = (*GroupController)(nil)
|
||||
|
||||
func NewGroupInterface(db *gorm.DB, rdb redis.UniversalClient, mgoClient *mongo.Client) GroupInterface {
|
||||
return &GroupController{database: NewGroupDatabase(db, rdb, mgoClient)}
|
||||
func NewGroupInterface(database GroupDataBaseInterface) GroupInterface {
|
||||
return &GroupController{database: database}
|
||||
}
|
||||
|
||||
type GroupController struct {
|
||||
@@ -72,7 +72,7 @@ func (g *GroupController) CreateGroup(ctx context.Context, groups []*relationTb.
|
||||
}
|
||||
|
||||
func (g *GroupController) TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) {
|
||||
return g.TakeGroup(ctx, groupID)
|
||||
return g.database.TakeGroup(ctx, groupID)
|
||||
}
|
||||
|
||||
func (g *GroupController) FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) {
|
||||
@@ -175,6 +175,53 @@ func (g *GroupController) CreateSuperGroupMember(ctx context.Context, groupID st
|
||||
return g.database.CreateSuperGroupMember(ctx, groupID, userIDs)
|
||||
}
|
||||
|
||||
type Group interface {
|
||||
CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error
|
||||
TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error)
|
||||
FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error)
|
||||
SearchGroup(ctx context.Context, keyword string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupModel, error)
|
||||
UpdateGroup(ctx context.Context, groupID string, data map[string]any) error
|
||||
DismissGroup(ctx context.Context, groupID string) error // 解散群,并删除群成员
|
||||
}
|
||||
|
||||
type GroupMember interface {
|
||||
TakeGroupMember(ctx context.Context, groupID string, userID string) (groupMember *relationTb.GroupMemberModel, err error)
|
||||
TakeGroupOwner(ctx context.Context, groupID string) (*relationTb.GroupMemberModel, error)
|
||||
FindGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32) ([]*relationTb.GroupMemberModel, error)
|
||||
FindGroupMemberUserID(ctx context.Context, groupID string) ([]string, error)
|
||||
PageGroupMember(ctx context.Context, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error)
|
||||
SearchGroupMember(ctx context.Context, keyword string, groupIDs []string, userIDs []string, roleLevels []int32, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error)
|
||||
HandlerGroupRequest(ctx context.Context, groupID string, userID string, handledMsg string, handleResult int32, member *relationTb.GroupMemberModel) error
|
||||
DeleteGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
||||
MapGroupMemberUserID(ctx context.Context, groupIDs []string) (map[string]*relationTb.GroupSimpleUserID, error)
|
||||
MapGroupMemberNum(ctx context.Context, groupIDs []string) (map[string]uint32, error)
|
||||
TransferGroupOwner(ctx context.Context, groupID string, oldOwnerUserID, newOwnerUserID string, roleLevel int32) error // 转让群
|
||||
UpdateGroupMember(ctx context.Context, groupID string, userID string, data map[string]any) error
|
||||
UpdateGroupMembers(ctx context.Context, data []*relationTb.BatchUpdateGroupMember) error
|
||||
}
|
||||
|
||||
type GroupRequest interface {
|
||||
CreateGroupRequest(ctx context.Context, requests []*relationTb.GroupRequestModel) error
|
||||
TakeGroupRequest(ctx context.Context, groupID string, userID string) (*relationTb.GroupRequestModel, error)
|
||||
PageGroupRequestUser(ctx context.Context, userID string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupRequestModel, error)
|
||||
}
|
||||
|
||||
type SuperGroup interface {
|
||||
FindSuperGroup(ctx context.Context, groupIDs []string) ([]*unrelationTb.SuperGroupModel, error)
|
||||
FindJoinSuperGroup(ctx context.Context, userID string) (*unrelationTb.UserToSuperGroupModel, error)
|
||||
CreateSuperGroup(ctx context.Context, groupID string, initMemberIDList []string) error
|
||||
DeleteSuperGroup(ctx context.Context, groupID string) error
|
||||
DeleteSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
||||
CreateSuperGroupMember(ctx context.Context, groupID string, userIDs []string) error
|
||||
}
|
||||
|
||||
type GroupDataBase1 interface {
|
||||
Group
|
||||
GroupMember
|
||||
GroupRequest
|
||||
SuperGroup
|
||||
}
|
||||
|
||||
type GroupDataBaseInterface interface {
|
||||
CreateGroup(ctx context.Context, groups []*relationTb.GroupModel, groupMembers []*relationTb.GroupMemberModel) error
|
||||
TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error)
|
||||
@@ -291,7 +338,10 @@ func (g *GroupDataBase) CreateGroup(ctx context.Context, groups []*relationTb.Gr
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) TakeGroup(ctx context.Context, groupID string) (group *relationTb.GroupModel, err error) {
|
||||
return g.cache.GetGroupInfo(ctx, groupID)
|
||||
//return g.cache.GetGroupInfo(ctx, groupID)
|
||||
return cache.GetCache(ctx, g.rcClient, g.getGroupInfoKey(groupID), g.expireTime, func(ctx context.Context) (*relationTb.GroupModel, error) {
|
||||
return g.group.Take(ctx, groupID)
|
||||
})
|
||||
}
|
||||
|
||||
func (g *GroupDataBase) FindGroup(ctx context.Context, groupIDs []string) (groups []*relationTb.GroupModel, err error) {
|
||||
|
||||
Reference in New Issue
Block a user