mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-10-26 21:22:16 +08:00
rpc client
This commit is contained in:
parent
774b3a0478
commit
fc6569b719
@ -20,24 +20,26 @@ import (
|
|||||||
"github.com/openimsdk/tools/a2r"
|
"github.com/openimsdk/tools/a2r"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AuthApi struct{}
|
type AuthApi struct {
|
||||||
|
Client auth.AuthClient
|
||||||
|
}
|
||||||
|
|
||||||
func NewAuthApi() AuthApi {
|
func NewAuthApi(client auth.AuthClient) AuthApi {
|
||||||
return AuthApi{}
|
return AuthApi{client}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *AuthApi) GetAdminToken(c *gin.Context) {
|
func (o *AuthApi) GetAdminToken(c *gin.Context) {
|
||||||
a2r.CallV2(c, auth.GetAdminTokenCaller.Invoke)
|
a2r.Call(c, auth.AuthClient.GetAdminToken, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *AuthApi) GetUserToken(c *gin.Context) {
|
func (o *AuthApi) GetUserToken(c *gin.Context) {
|
||||||
a2r.CallV2(c, auth.GetUserTokenCaller.Invoke)
|
a2r.Call(c, auth.AuthClient.GetUserToken, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *AuthApi) ParseToken(c *gin.Context) {
|
func (o *AuthApi) ParseToken(c *gin.Context) {
|
||||||
a2r.CallV2(c, auth.ParseTokenCaller.Invoke)
|
a2r.Call(c, auth.AuthClient.ParseToken, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *AuthApi) ForceLogout(c *gin.Context) {
|
func (o *AuthApi) ForceLogout(c *gin.Context) {
|
||||||
a2r.CallV2(c, auth.ForceLogoutCaller.Invoke)
|
a2r.Call(c, auth.AuthClient.ForceLogout, o.Client)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,52 +20,54 @@ import (
|
|||||||
"github.com/openimsdk/tools/a2r"
|
"github.com/openimsdk/tools/a2r"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ConversationApi struct{}
|
type ConversationApi struct {
|
||||||
|
Client conversation.ConversationClient
|
||||||
|
}
|
||||||
|
|
||||||
func NewConversationApi() ConversationApi {
|
func NewConversationApi(client conversation.ConversationClient) ConversationApi {
|
||||||
return ConversationApi{}
|
return ConversationApi{client}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ConversationApi) GetAllConversations(c *gin.Context) {
|
func (o *ConversationApi) GetAllConversations(c *gin.Context) {
|
||||||
a2r.CallV2(c, conversation.GetAllConversationsCaller.Invoke)
|
a2r.Call(c, conversation.ConversationClient.GetAllConversations, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ConversationApi) GetSortedConversationList(c *gin.Context) {
|
func (o *ConversationApi) GetSortedConversationList(c *gin.Context) {
|
||||||
a2r.CallV2(c, conversation.GetSortedConversationListCaller.Invoke)
|
a2r.Call(c, conversation.ConversationClient.GetSortedConversationList, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ConversationApi) GetConversation(c *gin.Context) {
|
func (o *ConversationApi) GetConversation(c *gin.Context) {
|
||||||
a2r.CallV2(c, conversation.GetConversationCaller.Invoke)
|
a2r.Call(c, conversation.ConversationClient.GetConversation, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ConversationApi) GetConversations(c *gin.Context) {
|
func (o *ConversationApi) GetConversations(c *gin.Context) {
|
||||||
a2r.CallV2(c, conversation.GetConversationsCaller.Invoke)
|
a2r.Call(c, conversation.ConversationClient.GetConversations, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ConversationApi) SetConversations(c *gin.Context) {
|
func (o *ConversationApi) SetConversations(c *gin.Context) {
|
||||||
a2r.CallV2(c, conversation.SetConversationsCaller.Invoke)
|
a2r.Call(c, conversation.ConversationClient.SetConversations, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ConversationApi) GetConversationOfflinePushUserIDs(c *gin.Context) {
|
func (o *ConversationApi) GetConversationOfflinePushUserIDs(c *gin.Context) {
|
||||||
a2r.CallV2(c, conversation.GetConversationOfflinePushUserIDsCaller.Invoke)
|
a2r.Call(c, conversation.ConversationClient.GetConversationOfflinePushUserIDs, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ConversationApi) GetFullOwnerConversationIDs(c *gin.Context) {
|
func (o *ConversationApi) GetFullOwnerConversationIDs(c *gin.Context) {
|
||||||
a2r.CallV2(c, conversation.GetFullOwnerConversationIDsCaller.Invoke)
|
a2r.Call(c, conversation.ConversationClient.GetFullOwnerConversationIDs, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ConversationApi) GetIncrementalConversation(c *gin.Context) {
|
func (o *ConversationApi) GetIncrementalConversation(c *gin.Context) {
|
||||||
a2r.CallV2(c, conversation.GetIncrementalConversationCaller.Invoke)
|
a2r.Call(c, conversation.ConversationClient.GetIncrementalConversation, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ConversationApi) GetOwnerConversation(c *gin.Context) {
|
func (o *ConversationApi) GetOwnerConversation(c *gin.Context) {
|
||||||
a2r.CallV2(c, conversation.GetOwnerConversationCaller.Invoke)
|
a2r.Call(c, conversation.ConversationClient.GetOwnerConversation, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ConversationApi) GetNotNotifyConversationIDs(c *gin.Context) {
|
func (o *ConversationApi) GetNotNotifyConversationIDs(c *gin.Context) {
|
||||||
a2r.CallV2(c, conversation.GetNotNotifyConversationIDsCaller.Invoke)
|
a2r.Call(c, conversation.ConversationClient.GetNotNotifyConversationIDs, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ConversationApi) GetPinnedConversationIDs(c *gin.Context) {
|
func (o *ConversationApi) GetPinnedConversationIDs(c *gin.Context) {
|
||||||
a2r.CallV2(c, conversation.GetPinnedConversationIDsCaller.Invoke)
|
a2r.Call(c, conversation.ConversationClient.GetPinnedConversationIDs, o.Client)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,94 +21,96 @@ import (
|
|||||||
"github.com/openimsdk/tools/a2r"
|
"github.com/openimsdk/tools/a2r"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FriendApi struct{}
|
type FriendApi struct {
|
||||||
|
Client relation.FriendClient
|
||||||
|
}
|
||||||
|
|
||||||
func NewFriendApi() FriendApi {
|
func NewFriendApi(client relation.FriendClient) FriendApi {
|
||||||
return FriendApi{}
|
return FriendApi{client}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) ApplyToAddFriend(c *gin.Context) {
|
func (o *FriendApi) ApplyToAddFriend(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.ApplyToAddFriendCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.ApplyToAddFriend, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) RespondFriendApply(c *gin.Context) {
|
func (o *FriendApi) RespondFriendApply(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.RespondFriendApplyCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.RespondFriendApply, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) DeleteFriend(c *gin.Context) {
|
func (o *FriendApi) DeleteFriend(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.DeleteFriendCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.DeleteFriend, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) GetFriendApplyList(c *gin.Context) {
|
func (o *FriendApi) GetFriendApplyList(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.GetPaginationFriendsApplyToCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.GetPaginationFriendsApplyTo, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) GetDesignatedFriendsApply(c *gin.Context) {
|
func (o *FriendApi) GetDesignatedFriendsApply(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.GetDesignatedFriendsApplyCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.GetDesignatedFriendsApply, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) GetSelfApplyList(c *gin.Context) {
|
func (o *FriendApi) GetSelfApplyList(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.GetPaginationFriendsApplyFromCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.GetPaginationFriendsApplyFrom, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) GetFriendList(c *gin.Context) {
|
func (o *FriendApi) GetFriendList(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.GetPaginationFriendsCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.GetPaginationFriends, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) GetDesignatedFriends(c *gin.Context) {
|
func (o *FriendApi) GetDesignatedFriends(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.GetDesignatedFriendsCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.GetDesignatedFriends, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) SetFriendRemark(c *gin.Context) {
|
func (o *FriendApi) SetFriendRemark(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.SetFriendRemarkCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.SetFriendRemark, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) AddBlack(c *gin.Context) {
|
func (o *FriendApi) AddBlack(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.AddBlackCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.AddBlack, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) GetPaginationBlacks(c *gin.Context) {
|
func (o *FriendApi) GetPaginationBlacks(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.GetPaginationBlacksCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.GetPaginationBlacks, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) GetSpecifiedBlacks(c *gin.Context) {
|
func (o *FriendApi) GetSpecifiedBlacks(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.GetSpecifiedBlacksCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.GetSpecifiedBlacks, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) RemoveBlack(c *gin.Context) {
|
func (o *FriendApi) RemoveBlack(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.RemoveBlackCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.RemoveBlack, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) ImportFriends(c *gin.Context) {
|
func (o *FriendApi) ImportFriends(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.ImportFriendsCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.ImportFriends, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) IsFriend(c *gin.Context) {
|
func (o *FriendApi) IsFriend(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.IsFriendCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.IsFriend, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) GetFriendIDs(c *gin.Context) {
|
func (o *FriendApi) GetFriendIDs(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.GetFriendIDsCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.GetFriendIDs, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) GetSpecifiedFriendsInfo(c *gin.Context) {
|
func (o *FriendApi) GetSpecifiedFriendsInfo(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.GetSpecifiedFriendsInfoCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.GetSpecifiedFriendsInfo, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) UpdateFriends(c *gin.Context) {
|
func (o *FriendApi) UpdateFriends(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.UpdateFriendsCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.UpdateFriends, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) GetIncrementalFriends(c *gin.Context) {
|
func (o *FriendApi) GetIncrementalFriends(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.GetIncrementalFriendsCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.GetIncrementalFriends, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIncrementalBlacks is temporarily unused.
|
// GetIncrementalBlacks is temporarily unused.
|
||||||
// Deprecated: This function is currently unused and may be removed in future versions.
|
// Deprecated: This function is currently unused and may be removed in future versions.
|
||||||
func (o *FriendApi) GetIncrementalBlacks(c *gin.Context) {
|
func (o *FriendApi) GetIncrementalBlacks(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.GetIncrementalBlacksCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.GetIncrementalBlacks, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) GetFullFriendUserIDs(c *gin.Context) {
|
func (o *FriendApi) GetFullFriendUserIDs(c *gin.Context) {
|
||||||
a2r.CallV2(c, relation.GetFullFriendUserIDsCaller.Invoke)
|
a2r.Call(c, relation.FriendClient.GetFullFriendUserIDs, o.Client)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,146 +20,148 @@ import (
|
|||||||
"github.com/openimsdk/tools/a2r"
|
"github.com/openimsdk/tools/a2r"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GroupApi struct{}
|
type GroupApi struct {
|
||||||
|
Client group.GroupClient
|
||||||
|
}
|
||||||
|
|
||||||
func NewGroupApi() GroupApi {
|
func NewGroupApi(client group.GroupClient) GroupApi {
|
||||||
return GroupApi{}
|
return GroupApi{client}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) CreateGroup(c *gin.Context) {
|
func (o *GroupApi) CreateGroup(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.CreateGroupCaller.Invoke)
|
a2r.Call(c, group.GroupClient.CreateGroup, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) SetGroupInfo(c *gin.Context) {
|
func (o *GroupApi) SetGroupInfo(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.SetGroupInfoCaller.Invoke)
|
a2r.Call(c, group.GroupClient.SetGroupInfo, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) SetGroupInfoEx(c *gin.Context) {
|
func (o *GroupApi) SetGroupInfoEx(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.SetGroupInfoExCaller.Invoke)
|
a2r.Call(c, group.GroupClient.SetGroupInfoEx, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) JoinGroup(c *gin.Context) {
|
func (o *GroupApi) JoinGroup(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.JoinGroupCaller.Invoke)
|
a2r.Call(c, group.GroupClient.JoinGroup, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) QuitGroup(c *gin.Context) {
|
func (o *GroupApi) QuitGroup(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.QuitGroupCaller.Invoke)
|
a2r.Call(c, group.GroupClient.QuitGroup, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) ApplicationGroupResponse(c *gin.Context) {
|
func (o *GroupApi) ApplicationGroupResponse(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.GroupApplicationResponseCaller.Invoke)
|
a2r.Call(c, group.GroupClient.GroupApplicationResponse, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) TransferGroupOwner(c *gin.Context) {
|
func (o *GroupApi) TransferGroupOwner(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.TransferGroupOwnerCaller.Invoke)
|
a2r.Call(c, group.GroupClient.TransferGroupOwner, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) GetRecvGroupApplicationList(c *gin.Context) {
|
func (o *GroupApi) GetRecvGroupApplicationList(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.GetGroupApplicationListCaller.Invoke)
|
a2r.Call(c, group.GroupClient.GetGroupApplicationList, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) GetUserReqGroupApplicationList(c *gin.Context) {
|
func (o *GroupApi) GetUserReqGroupApplicationList(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.GetUserReqApplicationListCaller.Invoke)
|
a2r.Call(c, group.GroupClient.GetUserReqApplicationList, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) GetGroupUsersReqApplicationList(c *gin.Context) {
|
func (o *GroupApi) GetGroupUsersReqApplicationList(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.GetGroupUsersReqApplicationListCaller.Invoke)
|
a2r.Call(c, group.GroupClient.GetGroupUsersReqApplicationList, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) GetSpecifiedUserGroupRequestInfo(c *gin.Context) {
|
func (o *GroupApi) GetSpecifiedUserGroupRequestInfo(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.GetSpecifiedUserGroupRequestInfoCaller.Invoke)
|
a2r.Call(c, group.GroupClient.GetSpecifiedUserGroupRequestInfo, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) GetGroupsInfo(c *gin.Context) {
|
func (o *GroupApi) GetGroupsInfo(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.GetGroupsInfoCaller.Invoke)
|
a2r.Call(c, group.GroupClient.GetGroupsInfo, o.Client)
|
||||||
//a2r.Call(group.GroupClient.GetGroupsInfo, o.Client, c, a2r.NewNilReplaceOption(group.GroupClient.GetGroupsInfo))
|
//a2r.Call(c, group.GroupClient.GetGroupsInfo, o.Client, c, a2r.NewNilReplaceOption(group.GroupClient.GetGroupsInfo))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) KickGroupMember(c *gin.Context) {
|
func (o *GroupApi) KickGroupMember(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.KickGroupMemberCaller.Invoke)
|
a2r.Call(c, group.GroupClient.KickGroupMember, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) GetGroupMembersInfo(c *gin.Context) {
|
func (o *GroupApi) GetGroupMembersInfo(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.GetGroupMembersInfoCaller.Invoke)
|
a2r.Call(c, group.GroupClient.GetGroupMembersInfo, o.Client)
|
||||||
//a2r.Call(group.GroupClient.GetGroupMembersInfo, o.Client, c, a2r.NewNilReplaceOption(group.GroupClient.GetGroupMembersInfo))
|
//a2r.Call(c, group.GroupClient.GetGroupMembersInfo, o.Client, c, a2r.NewNilReplaceOption(group.GroupClient.GetGroupMembersInfo))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) GetGroupMemberList(c *gin.Context) {
|
func (o *GroupApi) GetGroupMemberList(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.GetGroupMemberListCaller.Invoke)
|
a2r.Call(c, group.GroupClient.GetGroupMemberList, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) InviteUserToGroup(c *gin.Context) {
|
func (o *GroupApi) InviteUserToGroup(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.InviteUserToGroupCaller.Invoke)
|
a2r.Call(c, group.GroupClient.InviteUserToGroup, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) GetJoinedGroupList(c *gin.Context) {
|
func (o *GroupApi) GetJoinedGroupList(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.GetJoinedGroupListCaller.Invoke)
|
a2r.Call(c, group.GroupClient.GetJoinedGroupList, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) DismissGroup(c *gin.Context) {
|
func (o *GroupApi) DismissGroup(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.DismissGroupCaller.Invoke)
|
a2r.Call(c, group.GroupClient.DismissGroup, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) MuteGroupMember(c *gin.Context) {
|
func (o *GroupApi) MuteGroupMember(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.MuteGroupMemberCaller.Invoke)
|
a2r.Call(c, group.GroupClient.MuteGroupMember, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) CancelMuteGroupMember(c *gin.Context) {
|
func (o *GroupApi) CancelMuteGroupMember(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.CancelMuteGroupMemberCaller.Invoke)
|
a2r.Call(c, group.GroupClient.CancelMuteGroupMember, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) MuteGroup(c *gin.Context) {
|
func (o *GroupApi) MuteGroup(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.MuteGroupCaller.Invoke)
|
a2r.Call(c, group.GroupClient.MuteGroup, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) CancelMuteGroup(c *gin.Context) {
|
func (o *GroupApi) CancelMuteGroup(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.CancelMuteGroupCaller.Invoke)
|
a2r.Call(c, group.GroupClient.CancelMuteGroup, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) SetGroupMemberInfo(c *gin.Context) {
|
func (o *GroupApi) SetGroupMemberInfo(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.SetGroupMemberInfoCaller.Invoke)
|
a2r.Call(c, group.GroupClient.SetGroupMemberInfo, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) GetGroupAbstractInfo(c *gin.Context) {
|
func (o *GroupApi) GetGroupAbstractInfo(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.GetGroupAbstractInfoCaller.Invoke)
|
a2r.Call(c, group.GroupClient.GetGroupAbstractInfo, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
// func (g *Group) SetGroupMemberNickname(c *gin.Context) {
|
// func (g *Group) SetGroupMemberNickname(c *gin.Context) {
|
||||||
// a2r.Call(group.GroupClient.SetGroupMemberNickname, g.userClient, c)
|
// a2r.Call(c, group.GroupClient.SetGroupMemberNickname, g.userClient)
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
// func (g *Group) GetGroupAllMemberList(c *gin.Context) {
|
// func (g *Group) GetGroupAllMemberList(c *gin.Context) {
|
||||||
// a2r.Call(group.GroupClient.GetGroupAllMember, g.userClient, c)
|
// a2r.Call(c, group.GroupClient.GetGroupAllMember, g.userClient)
|
||||||
//}
|
//}
|
||||||
|
|
||||||
func (o *GroupApi) GroupCreateCount(c *gin.Context) {
|
func (o *GroupApi) GroupCreateCount(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.GroupCreateCountCaller.Invoke)
|
a2r.Call(c, group.GroupClient.GroupCreateCount, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) GetGroups(c *gin.Context) {
|
func (o *GroupApi) GetGroups(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.GetGroupsCaller.Invoke)
|
a2r.Call(c, group.GroupClient.GetGroups, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) GetGroupMemberUserIDs(c *gin.Context) {
|
func (o *GroupApi) GetGroupMemberUserIDs(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.GetGroupMemberUserIDsCaller.Invoke)
|
a2r.Call(c, group.GroupClient.GetGroupMemberUserIDs, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) GetIncrementalJoinGroup(c *gin.Context) {
|
func (o *GroupApi) GetIncrementalJoinGroup(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.GetIncrementalJoinGroupCaller.Invoke)
|
a2r.Call(c, group.GroupClient.GetIncrementalJoinGroup, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) GetIncrementalGroupMember(c *gin.Context) {
|
func (o *GroupApi) GetIncrementalGroupMember(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.GetIncrementalGroupMemberCaller.Invoke)
|
a2r.Call(c, group.GroupClient.GetIncrementalGroupMember, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) GetIncrementalGroupMemberBatch(c *gin.Context) {
|
func (o *GroupApi) GetIncrementalGroupMemberBatch(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.BatchGetIncrementalGroupMemberCaller.Invoke)
|
a2r.Call(c, group.GroupClient.BatchGetIncrementalGroupMember, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) GetFullGroupMemberUserIDs(c *gin.Context) {
|
func (o *GroupApi) GetFullGroupMemberUserIDs(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.GetFullGroupMemberUserIDsCaller.Invoke)
|
a2r.Call(c, group.GroupClient.GetFullGroupMemberUserIDs, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *GroupApi) GetFullJoinGroupIDs(c *gin.Context) {
|
func (o *GroupApi) GetFullJoinGroupIDs(c *gin.Context) {
|
||||||
a2r.CallV2(c, group.GetFullJoinGroupIDsCaller.Invoke)
|
a2r.Call(c, group.GroupClient.GetFullJoinGroupIDs, o.Client)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,6 @@ import (
|
|||||||
conf "github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
conf "github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
kdisc "github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister"
|
kdisc "github.com/openimsdk/open-im-server/v3/pkg/common/discoveryregister"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/rpcclient"
|
|
||||||
"github.com/openimsdk/tools/discovery/etcd"
|
"github.com/openimsdk/tools/discovery/etcd"
|
||||||
"github.com/openimsdk/tools/errs"
|
"github.com/openimsdk/tools/errs"
|
||||||
"github.com/openimsdk/tools/log"
|
"github.com/openimsdk/tools/log"
|
||||||
@ -64,9 +63,6 @@ func Start(ctx context.Context, index int, config *Config) error {
|
|||||||
return errs.WrapMsg(err, "failed to register discovery service")
|
return errs.WrapMsg(err, "failed to register discovery service")
|
||||||
}
|
}
|
||||||
client.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, "round_robin")))
|
client.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, "round_robin")))
|
||||||
if err = rpcclient.InitRpcCaller(client, config.Discovery.RpcService); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
netDone = make(chan struct{}, 1)
|
netDone = make(chan struct{}, 1)
|
||||||
@ -94,7 +90,10 @@ func Start(ctx context.Context, index int, config *Config) error {
|
|||||||
return errs.New("only etcd support autoSetPorts", "RegisterName", "api").Wrap()
|
return errs.New("only etcd support autoSetPorts", "RegisterName", "api").Wrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
router := newGinRouter(client, config)
|
router, err := newGinRouter(ctx, client, config)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if config.API.Prometheus.Enable {
|
if config.API.Prometheus.Enable {
|
||||||
var (
|
var (
|
||||||
listener net.Listener
|
listener net.Listener
|
||||||
|
|||||||
@ -21,11 +21,10 @@ import (
|
|||||||
"github.com/openimsdk/open-im-server/v3/pkg/apistruct"
|
"github.com/openimsdk/open-im-server/v3/pkg/apistruct"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
||||||
"github.com/openimsdk/protocol/constant"
|
"github.com/openimsdk/protocol/constant"
|
||||||
"github.com/openimsdk/protocol/msg"
|
"github.com/openimsdk/protocol/msg"
|
||||||
"github.com/openimsdk/protocol/rpccall"
|
|
||||||
"github.com/openimsdk/protocol/sdkws"
|
"github.com/openimsdk/protocol/sdkws"
|
||||||
"github.com/openimsdk/protocol/user"
|
|
||||||
"github.com/openimsdk/tools/a2r"
|
"github.com/openimsdk/tools/a2r"
|
||||||
"github.com/openimsdk/tools/apiresp"
|
"github.com/openimsdk/tools/apiresp"
|
||||||
"github.com/openimsdk/tools/errs"
|
"github.com/openimsdk/tools/errs"
|
||||||
@ -38,12 +37,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type MessageApi struct {
|
type MessageApi struct {
|
||||||
validate *validator.Validate
|
Client msg.MsgClient
|
||||||
|
userClient *rpcli.UserClient
|
||||||
imAdminUserID []string
|
imAdminUserID []string
|
||||||
|
validate *validator.Validate
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMessageApi(imAdminUserID []string) MessageApi {
|
func NewMessageApi(client msg.MsgClient, userClient *rpcli.UserClient, imAdminUserID []string) MessageApi {
|
||||||
return MessageApi{validate: validator.New(), imAdminUserID: imAdminUserID}
|
return MessageApi{Client: client, userClient: userClient, imAdminUserID: imAdminUserID, validate: validator.New()}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*MessageApi) SetOptions(options map[string]bool, value bool) {
|
func (*MessageApi) SetOptions(options map[string]bool, value bool) {
|
||||||
@ -105,51 +106,51 @@ func (m *MessageApi) newUserSendMsgReq(_ *gin.Context, params *apistruct.SendMsg
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) GetSeq(c *gin.Context) {
|
func (m *MessageApi) GetSeq(c *gin.Context) {
|
||||||
a2r.CallV2(c, msg.GetMaxSeqCaller.Invoke)
|
a2r.Call(c, msg.MsgClient.GetMaxSeq, m.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) PullMsgBySeqs(c *gin.Context) {
|
func (m *MessageApi) PullMsgBySeqs(c *gin.Context) {
|
||||||
a2r.CallV2(c, msg.PullMessageBySeqsCaller.Invoke)
|
a2r.Call(c, msg.MsgClient.PullMessageBySeqs, m.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) RevokeMsg(c *gin.Context) {
|
func (m *MessageApi) RevokeMsg(c *gin.Context) {
|
||||||
a2r.CallV2(c, msg.RevokeMsgCaller.Invoke)
|
a2r.Call(c, msg.MsgClient.RevokeMsg, m.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) MarkMsgsAsRead(c *gin.Context) {
|
func (m *MessageApi) MarkMsgsAsRead(c *gin.Context) {
|
||||||
a2r.CallV2(c, msg.MarkMsgsAsReadCaller.Invoke)
|
a2r.Call(c, msg.MsgClient.MarkMsgsAsRead, m.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) MarkConversationAsRead(c *gin.Context) {
|
func (m *MessageApi) MarkConversationAsRead(c *gin.Context) {
|
||||||
a2r.CallV2(c, msg.MarkConversationAsReadCaller.Invoke)
|
a2r.Call(c, msg.MsgClient.MarkConversationAsRead, m.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) GetConversationsHasReadAndMaxSeq(c *gin.Context) {
|
func (m *MessageApi) GetConversationsHasReadAndMaxSeq(c *gin.Context) {
|
||||||
a2r.CallV2(c, msg.GetConversationsHasReadAndMaxSeqCaller.Invoke)
|
a2r.Call(c, msg.MsgClient.GetConversationsHasReadAndMaxSeq, m.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) SetConversationHasReadSeq(c *gin.Context) {
|
func (m *MessageApi) SetConversationHasReadSeq(c *gin.Context) {
|
||||||
a2r.CallV2(c, msg.SetConversationHasReadSeqCaller.Invoke)
|
a2r.Call(c, msg.MsgClient.SetConversationHasReadSeq, m.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) ClearConversationsMsg(c *gin.Context) {
|
func (m *MessageApi) ClearConversationsMsg(c *gin.Context) {
|
||||||
a2r.CallV2(c, msg.ClearConversationsMsgCaller.Invoke)
|
a2r.Call(c, msg.MsgClient.ClearConversationsMsg, m.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) UserClearAllMsg(c *gin.Context) {
|
func (m *MessageApi) UserClearAllMsg(c *gin.Context) {
|
||||||
a2r.CallV2(c, msg.UserClearAllMsgCaller.Invoke)
|
a2r.Call(c, msg.MsgClient.UserClearAllMsg, m.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) DeleteMsgs(c *gin.Context) {
|
func (m *MessageApi) DeleteMsgs(c *gin.Context) {
|
||||||
a2r.CallV2(c, msg.DeleteMsgsCaller.Invoke)
|
a2r.Call(c, msg.MsgClient.DeleteMsgs, m.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) DeleteMsgPhysicalBySeq(c *gin.Context) {
|
func (m *MessageApi) DeleteMsgPhysicalBySeq(c *gin.Context) {
|
||||||
a2r.CallV2(c, msg.DeleteMsgPhysicalBySeqCaller.Invoke)
|
a2r.Call(c, msg.MsgClient.DeleteMsgPhysicalBySeq, m.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) DeleteMsgPhysical(c *gin.Context) {
|
func (m *MessageApi) DeleteMsgPhysical(c *gin.Context) {
|
||||||
a2r.CallV2(c, msg.DeleteMsgPhysicalCaller.Invoke)
|
a2r.Call(c, msg.MsgClient.DeleteMsgPhysical, m.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) getSendMsgReq(c *gin.Context, req apistruct.SendMsg) (sendMsgReq *msg.SendMsgReq, err error) {
|
func (m *MessageApi) getSendMsgReq(c *gin.Context, req apistruct.SendMsg) (sendMsgReq *msg.SendMsgReq, err error) {
|
||||||
@ -170,14 +171,10 @@ func (m *MessageApi) getSendMsgReq(c *gin.Context, req apistruct.SendMsg) (sendM
|
|||||||
data = apistruct.AtElem{}
|
data = apistruct.AtElem{}
|
||||||
case constant.Custom:
|
case constant.Custom:
|
||||||
data = apistruct.CustomElem{}
|
data = apistruct.CustomElem{}
|
||||||
case constant.Quote:
|
|
||||||
data = apistruct.QuoteElem{}
|
|
||||||
case constant.Stream:
|
|
||||||
data = apistruct.StreamMsgElem{}
|
|
||||||
case constant.OANotification:
|
case constant.OANotification:
|
||||||
data = apistruct.OANotificationElem{}
|
data = apistruct.OANotificationElem{}
|
||||||
req.SessionType = constant.NotificationChatType
|
req.SessionType = constant.NotificationChatType
|
||||||
if err = user.GetNotificationAccountCaller.Execute(c, &user.GetNotificationAccountReq{UserID: req.SendID}); err != nil {
|
if err = m.userClient.GetNotificationByID(c, req.SendID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -224,7 +221,7 @@ func (m *MessageApi) SendMessage(c *gin.Context) {
|
|||||||
sendMsgReq.MsgData.RecvID = req.RecvID
|
sendMsgReq.MsgData.RecvID = req.RecvID
|
||||||
|
|
||||||
// Attempt to send the message using the client.
|
// Attempt to send the message using the client.
|
||||||
respPb, err := msg.SendMsgCaller.Invoke(c, sendMsgReq)
|
respPb, err := m.Client.SendMsg(c, sendMsgReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Set the status to failed and respond with an error if sending fails.
|
// Set the status to failed and respond with an error if sending fails.
|
||||||
apiresp.GinError(c, err)
|
apiresp.GinError(c, err)
|
||||||
@ -235,7 +232,7 @@ func (m *MessageApi) SendMessage(c *gin.Context) {
|
|||||||
var status = constant.MsgSendSuccessed
|
var status = constant.MsgSendSuccessed
|
||||||
|
|
||||||
// Attempt to update the message sending status in the system.
|
// Attempt to update the message sending status in the system.
|
||||||
err = msg.SetSendMsgStatusCaller.Execute(c, &msg.SetSendMsgStatusReq{
|
_, err = m.Client.SetSendMsgStatus(c, &msg.SetSendMsgStatusReq{
|
||||||
Status: int32(status),
|
Status: int32(status),
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -287,7 +284,7 @@ func (m *MessageApi) SendBusinessNotification(c *gin.Context) {
|
|||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
respPb, err := msg.SendMsgCaller.Invoke(c, &sendMsgReq)
|
respPb, err := m.Client.SendMsg(c, &sendMsgReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
apiresp.GinError(c, err)
|
apiresp.GinError(c, err)
|
||||||
return
|
return
|
||||||
@ -311,13 +308,10 @@ func (m *MessageApi) BatchSendMsg(c *gin.Context) {
|
|||||||
|
|
||||||
var recvIDs []string
|
var recvIDs []string
|
||||||
if req.IsSendAll {
|
if req.IsSendAll {
|
||||||
pageNumber := 1
|
var pageNumber int32 = 1
|
||||||
showNumber := 500
|
const showNumber = 500
|
||||||
for {
|
for {
|
||||||
recvIDsPart, err := rpccall.ExtractField(c, user.GetAllUserIDCaller.Invoke, &user.GetAllUserIDReq{Pagination: &sdkws.RequestPagination{
|
recvIDsPart, err := m.userClient.GetAllUserIDs(c, pageNumber, showNumber)
|
||||||
PageNumber: int32(pageNumber),
|
|
||||||
ShowNumber: int32(showNumber),
|
|
||||||
}}, (*user.GetAllUserIDResp).GetUserIDs)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
apiresp.GinError(c, err)
|
apiresp.GinError(c, err)
|
||||||
return
|
return
|
||||||
@ -339,7 +333,7 @@ func (m *MessageApi) BatchSendMsg(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
for _, recvID := range recvIDs {
|
for _, recvID := range recvIDs {
|
||||||
sendMsgReq.MsgData.RecvID = recvID
|
sendMsgReq.MsgData.RecvID = recvID
|
||||||
rpcResp, err := msg.SendMsgCaller.Invoke(c, sendMsgReq)
|
rpcResp, err := m.Client.SendMsg(c, sendMsgReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
resp.FailedIDs = append(resp.FailedIDs, recvID)
|
resp.FailedIDs = append(resp.FailedIDs, recvID)
|
||||||
continue
|
continue
|
||||||
@ -355,33 +349,33 @@ func (m *MessageApi) BatchSendMsg(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) CheckMsgIsSendSuccess(c *gin.Context) {
|
func (m *MessageApi) CheckMsgIsSendSuccess(c *gin.Context) {
|
||||||
a2r.CallV2(c, msg.GetSendMsgStatusCaller.Invoke)
|
a2r.Call(c, msg.MsgClient.GetSendMsgStatus, m.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) GetUsersOnlineStatus(c *gin.Context) {
|
func (m *MessageApi) GetUsersOnlineStatus(c *gin.Context) {
|
||||||
a2r.CallV2(c, msg.GetSendMsgStatusCaller.Invoke)
|
a2r.Call(c, msg.MsgClient.GetSendMsgStatus, m.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) GetActiveUser(c *gin.Context) {
|
func (m *MessageApi) GetActiveUser(c *gin.Context) {
|
||||||
a2r.CallV2(c, msg.GetActiveUserCaller.Invoke)
|
a2r.Call(c, msg.MsgClient.GetActiveUser, m.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) GetActiveGroup(c *gin.Context) {
|
func (m *MessageApi) GetActiveGroup(c *gin.Context) {
|
||||||
a2r.CallV2(c, msg.GetActiveGroupCaller.Invoke)
|
a2r.Call(c, msg.MsgClient.GetActiveGroup, m.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) SearchMsg(c *gin.Context) {
|
func (m *MessageApi) SearchMsg(c *gin.Context) {
|
||||||
a2r.CallV2(c, msg.SearchMessageCaller.Invoke)
|
a2r.Call(c, msg.MsgClient.SearchMessage, m.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) GetServerTime(c *gin.Context) {
|
func (m *MessageApi) GetServerTime(c *gin.Context) {
|
||||||
a2r.CallV2(c, msg.GetServerTimeCaller.Invoke)
|
a2r.Call(c, msg.MsgClient.GetServerTime, m.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) GetStreamMsg(c *gin.Context) {
|
func (m *MessageApi) GetStreamMsg(c *gin.Context) {
|
||||||
a2r.CallV2(c, msg.GetStreamMsgCaller.Invoke)
|
a2r.Call(c, msg.MsgClient.GetServerTime, m.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageApi) AppendStreamMsg(c *gin.Context) {
|
func (m *MessageApi) AppendStreamMsg(c *gin.Context) {
|
||||||
a2r.CallV2(c, msg.AppendStreamMsgCaller.Invoke)
|
a2r.Call(c, msg.MsgClient.GetServerTime, m.Client)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,15 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
||||||
|
"github.com/openimsdk/protocol/conversation"
|
||||||
|
"github.com/openimsdk/protocol/group"
|
||||||
|
"github.com/openimsdk/protocol/msg"
|
||||||
|
"github.com/openimsdk/protocol/relation"
|
||||||
|
"github.com/openimsdk/protocol/third"
|
||||||
|
"github.com/openimsdk/protocol/user"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -47,9 +55,37 @@ func prommetricsGin() gin.HandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newGinRouter(disCov discovery.SvcDiscoveryRegistry, config *Config) *gin.Engine {
|
func newGinRouter(ctx context.Context, client discovery.SvcDiscoveryRegistry, config *Config) (*gin.Engine, error) {
|
||||||
disCov.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()),
|
client.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||||
grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, "round_robin")))
|
grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, "round_robin")))
|
||||||
|
authConn, err := client.GetConn(ctx, config.Discovery.RpcService.Auth)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
userConn, err := client.GetConn(ctx, config.Discovery.RpcService.User)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
groupConn, err := client.GetConn(ctx, config.Discovery.RpcService.Group)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
friendConn, err := client.GetConn(ctx, config.Discovery.RpcService.Friend)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
conversationConn, err := client.GetConn(ctx, config.Discovery.RpcService.Conversation)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
thirdConn, err := client.GetConn(ctx, config.Discovery.RpcService.Third)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
msgConn, err := client.GetConn(ctx, config.Discovery.RpcService.Msg)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
gin.SetMode(gin.ReleaseMode)
|
gin.SetMode(gin.ReleaseMode)
|
||||||
r := gin.New()
|
r := gin.New()
|
||||||
if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
|
if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
|
||||||
@ -64,13 +100,12 @@ func newGinRouter(disCov discovery.SvcDiscoveryRegistry, config *Config) *gin.En
|
|||||||
case BestSpeed:
|
case BestSpeed:
|
||||||
r.Use(gzip.Gzip(gzip.BestSpeed))
|
r.Use(gzip.Gzip(gzip.BestSpeed))
|
||||||
}
|
}
|
||||||
r.Use(prommetricsGin(), gin.RecoveryWithWriter(gin.DefaultErrorWriter, mw.GinPanicErr), mw.CorsHandler(), mw.GinParseOperationID(), GinParseToken())
|
r.Use(prommetricsGin(), gin.RecoveryWithWriter(gin.DefaultErrorWriter, mw.GinPanicErr), mw.CorsHandler(), mw.GinParseOperationID(), GinParseToken(rpcli.NewAuthClient(authConn)))
|
||||||
u := NewUserApi(disCov, config.Discovery.RpcService.MessageGateway)
|
|
||||||
m := NewMessageApi(config.Share.IMAdminUserID)
|
|
||||||
j := jssdk.NewJSSdkApi()
|
j := jssdk.NewJSSdkApi()
|
||||||
pd := NewPrometheusDiscoveryApi(config, disCov)
|
|
||||||
userRouterGroup := r.Group("/user")
|
u := NewUserApi(user.NewUserClient(userConn), client, config.Discovery.RpcService)
|
||||||
{
|
{
|
||||||
|
userRouterGroup := r.Group("/user")
|
||||||
userRouterGroup.POST("/user_register", u.UserRegister)
|
userRouterGroup.POST("/user_register", u.UserRegister)
|
||||||
userRouterGroup.POST("/update_user_info", u.UpdateUserInfo)
|
userRouterGroup.POST("/update_user_info", u.UpdateUserInfo)
|
||||||
userRouterGroup.POST("/update_user_info_ex", u.UpdateUserInfoEx)
|
userRouterGroup.POST("/update_user_info_ex", u.UpdateUserInfoEx)
|
||||||
@ -96,9 +131,9 @@ func newGinRouter(disCov discovery.SvcDiscoveryRegistry, config *Config) *gin.En
|
|||||||
userRouterGroup.POST("/search_notification_account", u.SearchNotificationAccount)
|
userRouterGroup.POST("/search_notification_account", u.SearchNotificationAccount)
|
||||||
}
|
}
|
||||||
// friend routing group
|
// friend routing group
|
||||||
friendRouterGroup := r.Group("/friend")
|
|
||||||
{
|
{
|
||||||
f := NewFriendApi()
|
f := NewFriendApi(relation.NewFriendClient(friendConn))
|
||||||
|
friendRouterGroup := r.Group("/friend")
|
||||||
friendRouterGroup.POST("/delete_friend", f.DeleteFriend)
|
friendRouterGroup.POST("/delete_friend", f.DeleteFriend)
|
||||||
friendRouterGroup.POST("/get_friend_apply_list", f.GetFriendApplyList)
|
friendRouterGroup.POST("/get_friend_apply_list", f.GetFriendApplyList)
|
||||||
friendRouterGroup.POST("/get_designated_friend_apply", f.GetDesignatedFriendsApply)
|
friendRouterGroup.POST("/get_designated_friend_apply", f.GetDesignatedFriendsApply)
|
||||||
@ -121,9 +156,10 @@ func newGinRouter(disCov discovery.SvcDiscoveryRegistry, config *Config) *gin.En
|
|||||||
friendRouterGroup.POST("/get_incremental_friends", f.GetIncrementalFriends)
|
friendRouterGroup.POST("/get_incremental_friends", f.GetIncrementalFriends)
|
||||||
friendRouterGroup.POST("/get_full_friend_user_ids", f.GetFullFriendUserIDs)
|
friendRouterGroup.POST("/get_full_friend_user_ids", f.GetFullFriendUserIDs)
|
||||||
}
|
}
|
||||||
g := NewGroupApi()
|
|
||||||
groupRouterGroup := r.Group("/group")
|
g := NewGroupApi(group.NewGroupClient(groupConn))
|
||||||
{
|
{
|
||||||
|
groupRouterGroup := r.Group("/group")
|
||||||
groupRouterGroup.POST("/create_group", g.CreateGroup)
|
groupRouterGroup.POST("/create_group", g.CreateGroup)
|
||||||
groupRouterGroup.POST("/set_group_info", g.SetGroupInfo)
|
groupRouterGroup.POST("/set_group_info", g.SetGroupInfo)
|
||||||
groupRouterGroup.POST("/set_group_info_ex", g.SetGroupInfoEx)
|
groupRouterGroup.POST("/set_group_info_ex", g.SetGroupInfoEx)
|
||||||
@ -157,9 +193,9 @@ func newGinRouter(disCov discovery.SvcDiscoveryRegistry, config *Config) *gin.En
|
|||||||
groupRouterGroup.POST("/get_full_join_group_ids", g.GetFullJoinGroupIDs)
|
groupRouterGroup.POST("/get_full_join_group_ids", g.GetFullJoinGroupIDs)
|
||||||
}
|
}
|
||||||
// certificate
|
// certificate
|
||||||
authRouterGroup := r.Group("/auth")
|
|
||||||
{
|
{
|
||||||
a := NewAuthApi()
|
a := NewAuthApi(pbAuth.NewAuthClient(authConn))
|
||||||
|
authRouterGroup := r.Group("/auth")
|
||||||
authRouterGroup.POST("/get_admin_token", a.GetAdminToken)
|
authRouterGroup.POST("/get_admin_token", a.GetAdminToken)
|
||||||
authRouterGroup.POST("/get_user_token", a.GetUserToken)
|
authRouterGroup.POST("/get_user_token", a.GetUserToken)
|
||||||
authRouterGroup.POST("/parse_token", a.ParseToken)
|
authRouterGroup.POST("/parse_token", a.ParseToken)
|
||||||
@ -167,9 +203,9 @@ func newGinRouter(disCov discovery.SvcDiscoveryRegistry, config *Config) *gin.En
|
|||||||
|
|
||||||
}
|
}
|
||||||
// Third service
|
// Third service
|
||||||
thirdGroup := r.Group("/third")
|
|
||||||
{
|
{
|
||||||
t := NewThirdApi(config.API.Prometheus.GrafanaURL)
|
t := NewThirdApi(third.NewThirdClient(thirdConn), config.API.Prometheus.GrafanaURL)
|
||||||
|
thirdGroup := r.Group("/third")
|
||||||
thirdGroup.GET("/prometheus", t.GetPrometheus)
|
thirdGroup.GET("/prometheus", t.GetPrometheus)
|
||||||
thirdGroup.POST("/fcm_update_token", t.FcmUpdateToken)
|
thirdGroup.POST("/fcm_update_token", t.FcmUpdateToken)
|
||||||
thirdGroup.POST("/set_app_badge", t.SetAppBadge)
|
thirdGroup.POST("/set_app_badge", t.SetAppBadge)
|
||||||
@ -192,8 +228,9 @@ func newGinRouter(disCov discovery.SvcDiscoveryRegistry, config *Config) *gin.En
|
|||||||
objectGroup.GET("/*name", t.ObjectRedirect)
|
objectGroup.GET("/*name", t.ObjectRedirect)
|
||||||
}
|
}
|
||||||
// Message
|
// Message
|
||||||
msgGroup := r.Group("/msg")
|
m := NewMessageApi(msg.NewMsgClient(msgConn), rpcli.NewUserClient(userConn), config.Share.IMAdminUserID)
|
||||||
{
|
{
|
||||||
|
msgGroup := r.Group("/msg")
|
||||||
msgGroup.POST("/newest_seq", m.GetSeq)
|
msgGroup.POST("/newest_seq", m.GetSeq)
|
||||||
msgGroup.POST("/search_msg", m.SearchMsg)
|
msgGroup.POST("/search_msg", m.SearchMsg)
|
||||||
msgGroup.POST("/send_msg", m.SendMessage)
|
msgGroup.POST("/send_msg", m.SendMessage)
|
||||||
@ -218,9 +255,9 @@ func newGinRouter(disCov discovery.SvcDiscoveryRegistry, config *Config) *gin.En
|
|||||||
msgGroup.POST("/append_stream_msg", m.AppendStreamMsg)
|
msgGroup.POST("/append_stream_msg", m.AppendStreamMsg)
|
||||||
}
|
}
|
||||||
// Conversation
|
// Conversation
|
||||||
conversationGroup := r.Group("/conversation")
|
|
||||||
{
|
{
|
||||||
c := NewConversationApi()
|
c := NewConversationApi(conversation.NewConversationClient(conversationConn))
|
||||||
|
conversationGroup := r.Group("/conversation")
|
||||||
conversationGroup.POST("/get_sorted_conversation_list", c.GetSortedConversationList)
|
conversationGroup.POST("/get_sorted_conversation_list", c.GetSortedConversationList)
|
||||||
conversationGroup.POST("/get_all_conversations", c.GetAllConversations)
|
conversationGroup.POST("/get_all_conversations", c.GetAllConversations)
|
||||||
conversationGroup.POST("/get_conversation", c.GetConversation)
|
conversationGroup.POST("/get_conversation", c.GetConversation)
|
||||||
@ -234,35 +271,39 @@ func newGinRouter(disCov discovery.SvcDiscoveryRegistry, config *Config) *gin.En
|
|||||||
conversationGroup.POST("/get_pinned_conversation_ids", c.GetPinnedConversationIDs)
|
conversationGroup.POST("/get_pinned_conversation_ids", c.GetPinnedConversationIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
statisticsGroup := r.Group("/statistics")
|
|
||||||
{
|
{
|
||||||
|
statisticsGroup := r.Group("/statistics")
|
||||||
statisticsGroup.POST("/user/register", u.UserRegisterCount)
|
statisticsGroup.POST("/user/register", u.UserRegisterCount)
|
||||||
statisticsGroup.POST("/user/active", m.GetActiveUser)
|
statisticsGroup.POST("/user/active", m.GetActiveUser)
|
||||||
statisticsGroup.POST("/group/create", g.GroupCreateCount)
|
statisticsGroup.POST("/group/create", g.GroupCreateCount)
|
||||||
statisticsGroup.POST("/group/active", m.GetActiveGroup)
|
statisticsGroup.POST("/group/active", m.GetActiveGroup)
|
||||||
}
|
}
|
||||||
|
|
||||||
jssdk := r.Group("/jssdk")
|
{
|
||||||
jssdk.POST("/get_conversations", j.GetConversations)
|
jssdk := r.Group("/jssdk")
|
||||||
jssdk.POST("/get_active_conversations", j.GetActiveConversations)
|
jssdk.POST("/get_conversations", j.GetConversations)
|
||||||
|
jssdk.POST("/get_active_conversations", j.GetActiveConversations)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
pd := NewPrometheusDiscoveryApi(config, client)
|
||||||
|
proDiscoveryGroup := r.Group("/prometheus_discovery", pd.Enable)
|
||||||
|
proDiscoveryGroup.GET("/api", pd.Api)
|
||||||
|
proDiscoveryGroup.GET("/user", pd.User)
|
||||||
|
proDiscoveryGroup.GET("/group", pd.Group)
|
||||||
|
proDiscoveryGroup.GET("/msg", pd.Msg)
|
||||||
|
proDiscoveryGroup.GET("/friend", pd.Friend)
|
||||||
|
proDiscoveryGroup.GET("/conversation", pd.Conversation)
|
||||||
|
proDiscoveryGroup.GET("/third", pd.Third)
|
||||||
|
proDiscoveryGroup.GET("/auth", pd.Auth)
|
||||||
|
proDiscoveryGroup.GET("/push", pd.Push)
|
||||||
|
proDiscoveryGroup.GET("/msg_gateway", pd.MessageGateway)
|
||||||
|
proDiscoveryGroup.GET("/msg_transfer", pd.MessageTransfer)
|
||||||
|
}
|
||||||
|
|
||||||
proDiscoveryGroup := r.Group("/prometheus_discovery", pd.Enable)
|
return r, nil
|
||||||
proDiscoveryGroup.GET("/api", pd.Api)
|
|
||||||
proDiscoveryGroup.GET("/user", pd.User)
|
|
||||||
proDiscoveryGroup.GET("/group", pd.Group)
|
|
||||||
proDiscoveryGroup.GET("/msg", pd.Msg)
|
|
||||||
proDiscoveryGroup.GET("/friend", pd.Friend)
|
|
||||||
proDiscoveryGroup.GET("/conversation", pd.Conversation)
|
|
||||||
proDiscoveryGroup.GET("/third", pd.Third)
|
|
||||||
proDiscoveryGroup.GET("/auth", pd.Auth)
|
|
||||||
proDiscoveryGroup.GET("/push", pd.Push)
|
|
||||||
proDiscoveryGroup.GET("/msg_gateway", pd.MessageGateway)
|
|
||||||
proDiscoveryGroup.GET("/msg_transfer", pd.MessageTransfer)
|
|
||||||
|
|
||||||
return r
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GinParseToken() gin.HandlerFunc {
|
func GinParseToken(authClient *rpcli.AuthClient) gin.HandlerFunc {
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
switch c.Request.Method {
|
switch c.Request.Method {
|
||||||
case http.MethodPost:
|
case http.MethodPost:
|
||||||
@ -280,7 +321,7 @@ func GinParseToken() gin.HandlerFunc {
|
|||||||
c.Abort()
|
c.Abort()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp, err := pbAuth.ParseTokenCaller.Invoke(c, &pbAuth.ParseTokenReq{Token: token})
|
resp, err := authClient.ParseToken(c, token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
apiresp.GinError(c, err)
|
apiresp.GinError(c, err)
|
||||||
c.Abort()
|
c.Abort()
|
||||||
|
|||||||
@ -1,31 +0,0 @@
|
|||||||
// Copyright © 2023 OpenIM. All rights reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package api
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"github.com/openimsdk/protocol/user"
|
|
||||||
"github.com/openimsdk/tools/a2r"
|
|
||||||
)
|
|
||||||
|
|
||||||
type StatisticsApi struct{}
|
|
||||||
|
|
||||||
func NewStatisticsApi() StatisticsApi {
|
|
||||||
return StatisticsApi{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *StatisticsApi) UserRegister(c *gin.Context) {
|
|
||||||
a2r.CallV2(c, user.UserRegisterCountCaller.Invoke)
|
|
||||||
}
|
|
||||||
@ -16,14 +16,13 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"google.golang.org/grpc"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/openimsdk/protocol/third"
|
"github.com/openimsdk/protocol/third"
|
||||||
"github.com/openimsdk/tools/a2r"
|
"github.com/openimsdk/tools/a2r"
|
||||||
@ -33,18 +32,19 @@ import (
|
|||||||
|
|
||||||
type ThirdApi struct {
|
type ThirdApi struct {
|
||||||
GrafanaUrl string
|
GrafanaUrl string
|
||||||
|
Client third.ThirdClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewThirdApi(grafanaUrl string) ThirdApi {
|
func NewThirdApi(client third.ThirdClient, grafanaUrl string) ThirdApi {
|
||||||
return ThirdApi{GrafanaUrl: grafanaUrl}
|
return ThirdApi{Client: client, GrafanaUrl: grafanaUrl}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ThirdApi) FcmUpdateToken(c *gin.Context) {
|
func (o *ThirdApi) FcmUpdateToken(c *gin.Context) {
|
||||||
a2r.CallV2(c, third.FcmUpdateTokenCaller.Invoke)
|
a2r.Call(c, third.ThirdClient.FcmUpdateToken, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ThirdApi) SetAppBadge(c *gin.Context) {
|
func (o *ThirdApi) SetAppBadge(c *gin.Context) {
|
||||||
a2r.CallV2(c, third.SetAppBadgeCaller.Invoke)
|
a2r.Call(c, third.ThirdClient.SetAppBadge, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
// #################### s3 ####################
|
// #################### s3 ####################
|
||||||
@ -79,44 +79,44 @@ func setURLPrefix(c *gin.Context, urlPrefix *string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (o *ThirdApi) PartLimit(c *gin.Context) {
|
func (o *ThirdApi) PartLimit(c *gin.Context) {
|
||||||
a2r.CallV2(c, third.PartLimitCaller.Invoke)
|
a2r.Call(c, third.ThirdClient.PartLimit, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ThirdApi) PartSize(c *gin.Context) {
|
func (o *ThirdApi) PartSize(c *gin.Context) {
|
||||||
a2r.CallV2(c, third.PartSizeCaller.Invoke)
|
a2r.Call(c, third.ThirdClient.PartSize, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ThirdApi) InitiateMultipartUpload(c *gin.Context) {
|
func (o *ThirdApi) InitiateMultipartUpload(c *gin.Context) {
|
||||||
opt := setURLPrefixOption(third.ThirdClient.InitiateMultipartUpload, func(req *third.InitiateMultipartUploadReq) error {
|
opt := setURLPrefixOption(third.ThirdClient.InitiateMultipartUpload, func(req *third.InitiateMultipartUploadReq) error {
|
||||||
return setURLPrefix(c, &req.UrlPrefix)
|
return setURLPrefix(c, &req.UrlPrefix)
|
||||||
})
|
})
|
||||||
a2r.CallV2(c, third.InitiateMultipartUploadCaller.Invoke, opt)
|
a2r.Call(c, third.ThirdClient.InitiateMultipartUpload, o.Client, opt)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ThirdApi) AuthSign(c *gin.Context) {
|
func (o *ThirdApi) AuthSign(c *gin.Context) {
|
||||||
a2r.CallV2(c, third.AuthSignCaller.Invoke)
|
a2r.Call(c, third.ThirdClient.AuthSign, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ThirdApi) CompleteMultipartUpload(c *gin.Context) {
|
func (o *ThirdApi) CompleteMultipartUpload(c *gin.Context) {
|
||||||
opt := setURLPrefixOption(third.ThirdClient.CompleteMultipartUpload, func(req *third.CompleteMultipartUploadReq) error {
|
opt := setURLPrefixOption(third.ThirdClient.CompleteMultipartUpload, func(req *third.CompleteMultipartUploadReq) error {
|
||||||
return setURLPrefix(c, &req.UrlPrefix)
|
return setURLPrefix(c, &req.UrlPrefix)
|
||||||
})
|
})
|
||||||
a2r.CallV2(c, third.CompleteMultipartUploadCaller.Invoke, opt)
|
a2r.Call(c, third.ThirdClient.CompleteMultipartUpload, o.Client, opt)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ThirdApi) AccessURL(c *gin.Context) {
|
func (o *ThirdApi) AccessURL(c *gin.Context) {
|
||||||
a2r.CallV2(c, third.AccessURLCaller.Invoke)
|
a2r.Call(c, third.ThirdClient.AccessURL, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ThirdApi) InitiateFormData(c *gin.Context) {
|
func (o *ThirdApi) InitiateFormData(c *gin.Context) {
|
||||||
a2r.CallV2(c, third.InitiateFormDataCaller.Invoke)
|
a2r.Call(c, third.ThirdClient.InitiateFormData, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ThirdApi) CompleteFormData(c *gin.Context) {
|
func (o *ThirdApi) CompleteFormData(c *gin.Context) {
|
||||||
opt := setURLPrefixOption(third.ThirdClient.CompleteFormData, func(req *third.CompleteFormDataReq) error {
|
opt := setURLPrefixOption(third.ThirdClient.CompleteFormData, func(req *third.CompleteFormDataReq) error {
|
||||||
return setURLPrefix(c, &req.UrlPrefix)
|
return setURLPrefix(c, &req.UrlPrefix)
|
||||||
})
|
})
|
||||||
a2r.CallV2(c, third.CompleteFormDataCaller.Invoke, opt)
|
a2r.Call(c, third.ThirdClient.CompleteFormData, o.Client, opt)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ThirdApi) ObjectRedirect(c *gin.Context) {
|
func (o *ThirdApi) ObjectRedirect(c *gin.Context) {
|
||||||
@ -140,7 +140,7 @@ func (o *ThirdApi) ObjectRedirect(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
query[key] = values[0]
|
query[key] = values[0]
|
||||||
}
|
}
|
||||||
resp, err := third.AccessURLCaller.Invoke(ctx, &third.AccessURLReq{Name: name, Query: query})
|
resp, err := o.Client.AccessURL(ctx, &third.AccessURLReq{Name: name, Query: query})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errs.ErrArgs.Is(err) {
|
if errs.ErrArgs.Is(err) {
|
||||||
c.String(http.StatusBadRequest, err.Error())
|
c.String(http.StatusBadRequest, err.Error())
|
||||||
@ -158,15 +158,15 @@ func (o *ThirdApi) ObjectRedirect(c *gin.Context) {
|
|||||||
|
|
||||||
// #################### logs ####################.
|
// #################### logs ####################.
|
||||||
func (o *ThirdApi) UploadLogs(c *gin.Context) {
|
func (o *ThirdApi) UploadLogs(c *gin.Context) {
|
||||||
a2r.CallV2(c, third.UploadLogsCaller.Invoke)
|
a2r.Call(c, third.ThirdClient.UploadLogs, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ThirdApi) DeleteLogs(c *gin.Context) {
|
func (o *ThirdApi) DeleteLogs(c *gin.Context) {
|
||||||
a2r.CallV2(c, third.DeleteLogsCaller.Invoke)
|
a2r.Call(c, third.ThirdClient.DeleteLogs, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ThirdApi) SearchLogs(c *gin.Context) {
|
func (o *ThirdApi) SearchLogs(c *gin.Context) {
|
||||||
a2r.CallV2(c, third.SearchLogsCaller.Invoke)
|
a2r.Call(c, third.ThirdClient.SearchLogs, o.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ThirdApi) GetPrometheus(c *gin.Context) {
|
func (o *ThirdApi) GetPrometheus(c *gin.Context) {
|
||||||
|
|||||||
@ -16,6 +16,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
"github.com/openimsdk/protocol/constant"
|
"github.com/openimsdk/protocol/constant"
|
||||||
"github.com/openimsdk/protocol/msggateway"
|
"github.com/openimsdk/protocol/msggateway"
|
||||||
"github.com/openimsdk/protocol/user"
|
"github.com/openimsdk/protocol/user"
|
||||||
@ -27,47 +28,45 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type UserApi struct {
|
type UserApi struct {
|
||||||
Discov discovery.SvcDiscoveryRegistry
|
Client user.UserClient
|
||||||
MessageGateWayRpcName string
|
discov discovery.SvcDiscoveryRegistry
|
||||||
|
config config.RpcService
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUserApi(discov discovery.SvcDiscoveryRegistry, messageGateWayRpcName string) UserApi {
|
func NewUserApi(client user.UserClient, discov discovery.SvcDiscoveryRegistry, config config.RpcService) UserApi {
|
||||||
return UserApi{
|
return UserApi{Client: client, discov: discov, config: config}
|
||||||
Discov: discov,
|
|
||||||
MessageGateWayRpcName: messageGateWayRpcName,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserApi) UserRegister(c *gin.Context) {
|
func (u *UserApi) UserRegister(c *gin.Context) {
|
||||||
a2r.CallV2(c, user.UserRegisterCaller.Invoke)
|
a2r.Call(c, user.UserClient.UserRegister, u.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateUserInfo is deprecated. Use UpdateUserInfoEx
|
// UpdateUserInfo is deprecated. Use UpdateUserInfoEx
|
||||||
func (u *UserApi) UpdateUserInfo(c *gin.Context) {
|
func (u *UserApi) UpdateUserInfo(c *gin.Context) {
|
||||||
a2r.CallV2(c, user.UpdateUserInfoCaller.Invoke)
|
a2r.Call(c, user.UserClient.UpdateUserInfo, u.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserApi) UpdateUserInfoEx(c *gin.Context) {
|
func (u *UserApi) UpdateUserInfoEx(c *gin.Context) {
|
||||||
a2r.CallV2(c, user.UpdateUserInfoExCaller.Invoke)
|
a2r.Call(c, user.UserClient.UpdateUserInfoEx, u.Client)
|
||||||
}
|
}
|
||||||
func (u *UserApi) SetGlobalRecvMessageOpt(c *gin.Context) {
|
func (u *UserApi) SetGlobalRecvMessageOpt(c *gin.Context) {
|
||||||
a2r.CallV2(c, user.SetGlobalRecvMessageOptCaller.Invoke)
|
a2r.Call(c, user.UserClient.SetGlobalRecvMessageOpt, u.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserApi) GetUsersPublicInfo(c *gin.Context) {
|
func (u *UserApi) GetUsersPublicInfo(c *gin.Context) {
|
||||||
a2r.CallV2(c, user.GetDesignateUsersCaller.Invoke)
|
a2r.Call(c, user.UserClient.GetDesignateUsers, u.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserApi) GetAllUsersID(c *gin.Context) {
|
func (u *UserApi) GetAllUsersID(c *gin.Context) {
|
||||||
a2r.CallV2(c, user.GetAllUserIDCaller.Invoke)
|
a2r.Call(c, user.UserClient.GetAllUserID, u.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserApi) AccountCheck(c *gin.Context) {
|
func (u *UserApi) AccountCheck(c *gin.Context) {
|
||||||
a2r.CallV2(c, user.AccountCheckCaller.Invoke)
|
a2r.Call(c, user.UserClient.AccountCheck, u.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserApi) GetUsers(c *gin.Context) {
|
func (u *UserApi) GetUsers(c *gin.Context) {
|
||||||
a2r.CallV2(c, user.GetPaginationUsersCaller.Invoke)
|
a2r.Call(c, user.UserClient.GetPaginationUsers, u.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUsersOnlineStatus Get user online status.
|
// GetUsersOnlineStatus Get user online status.
|
||||||
@ -77,7 +76,7 @@ func (u *UserApi) GetUsersOnlineStatus(c *gin.Context) {
|
|||||||
apiresp.GinError(c, err)
|
apiresp.GinError(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
conns, err := u.Discov.GetConns(c, u.MessageGateWayRpcName)
|
conns, err := u.discov.GetConns(c, u.config.MessageGateway)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
apiresp.GinError(c, err)
|
apiresp.GinError(c, err)
|
||||||
return
|
return
|
||||||
@ -128,7 +127,7 @@ func (u *UserApi) GetUsersOnlineStatus(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserApi) UserRegisterCount(c *gin.Context) {
|
func (u *UserApi) UserRegisterCount(c *gin.Context) {
|
||||||
a2r.CallV2(c, user.UserRegisterCountCaller.Invoke)
|
a2r.Call(c, user.UserClient.UserRegisterCount, u.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUsersOnlineTokenDetail Get user online token details.
|
// GetUsersOnlineTokenDetail Get user online token details.
|
||||||
@ -141,7 +140,7 @@ func (u *UserApi) GetUsersOnlineTokenDetail(c *gin.Context) {
|
|||||||
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
conns, err := u.Discov.GetConns(c, u.MessageGateWayRpcName)
|
conns, err := u.discov.GetConns(c, u.config.MessageGateway)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
apiresp.GinError(c, err)
|
apiresp.GinError(c, err)
|
||||||
return
|
return
|
||||||
@ -194,52 +193,52 @@ func (u *UserApi) GetUsersOnlineTokenDetail(c *gin.Context) {
|
|||||||
|
|
||||||
// SubscriberStatus Presence status of subscribed users.
|
// SubscriberStatus Presence status of subscribed users.
|
||||||
func (u *UserApi) SubscriberStatus(c *gin.Context) {
|
func (u *UserApi) SubscriberStatus(c *gin.Context) {
|
||||||
a2r.CallV2(c, user.SubscribeOrCancelUsersStatusCaller.Invoke)
|
a2r.Call(c, user.UserClient.SubscribeOrCancelUsersStatus, u.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUserStatus Get the online status of the user.
|
// GetUserStatus Get the online status of the user.
|
||||||
func (u *UserApi) GetUserStatus(c *gin.Context) {
|
func (u *UserApi) GetUserStatus(c *gin.Context) {
|
||||||
a2r.CallV2(c, user.GetUserStatusCaller.Invoke)
|
a2r.Call(c, user.UserClient.GetUserStatus, u.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSubscribeUsersStatus Get the online status of subscribers.
|
// GetSubscribeUsersStatus Get the online status of subscribers.
|
||||||
func (u *UserApi) GetSubscribeUsersStatus(c *gin.Context) {
|
func (u *UserApi) GetSubscribeUsersStatus(c *gin.Context) {
|
||||||
a2r.CallV2(c, user.GetSubscribeUsersStatusCaller.Invoke)
|
a2r.Call(c, user.UserClient.GetSubscribeUsersStatus, u.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProcessUserCommandAdd user general function add.
|
// ProcessUserCommandAdd user general function add.
|
||||||
func (u *UserApi) ProcessUserCommandAdd(c *gin.Context) {
|
func (u *UserApi) ProcessUserCommandAdd(c *gin.Context) {
|
||||||
a2r.CallV2(c, user.ProcessUserCommandAddCaller.Invoke)
|
a2r.Call(c, user.UserClient.ProcessUserCommandAdd, u.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProcessUserCommandDelete user general function delete.
|
// ProcessUserCommandDelete user general function delete.
|
||||||
func (u *UserApi) ProcessUserCommandDelete(c *gin.Context) {
|
func (u *UserApi) ProcessUserCommandDelete(c *gin.Context) {
|
||||||
a2r.CallV2(c, user.ProcessUserCommandDeleteCaller.Invoke)
|
a2r.Call(c, user.UserClient.ProcessUserCommandDelete, u.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProcessUserCommandUpdate user general function update.
|
// ProcessUserCommandUpdate user general function update.
|
||||||
func (u *UserApi) ProcessUserCommandUpdate(c *gin.Context) {
|
func (u *UserApi) ProcessUserCommandUpdate(c *gin.Context) {
|
||||||
a2r.CallV2(c, user.ProcessUserCommandUpdateCaller.Invoke)
|
a2r.Call(c, user.UserClient.ProcessUserCommandUpdate, u.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProcessUserCommandGet user general function get.
|
// ProcessUserCommandGet user general function get.
|
||||||
func (u *UserApi) ProcessUserCommandGet(c *gin.Context) {
|
func (u *UserApi) ProcessUserCommandGet(c *gin.Context) {
|
||||||
a2r.CallV2(c, user.ProcessUserCommandGetCaller.Invoke)
|
a2r.Call(c, user.UserClient.ProcessUserCommandGet, u.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProcessUserCommandGet user general function get all.
|
// ProcessUserCommandGet user general function get all.
|
||||||
func (u *UserApi) ProcessUserCommandGetAll(c *gin.Context) {
|
func (u *UserApi) ProcessUserCommandGetAll(c *gin.Context) {
|
||||||
a2r.CallV2(c, user.ProcessUserCommandGetAllCaller.Invoke)
|
a2r.Call(c, user.UserClient.ProcessUserCommandGetAll, u.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserApi) AddNotificationAccount(c *gin.Context) {
|
func (u *UserApi) AddNotificationAccount(c *gin.Context) {
|
||||||
a2r.CallV2(c, user.AddNotificationAccountCaller.Invoke)
|
a2r.Call(c, user.UserClient.AddNotificationAccount, u.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserApi) UpdateNotificationAccountInfo(c *gin.Context) {
|
func (u *UserApi) UpdateNotificationAccountInfo(c *gin.Context) {
|
||||||
a2r.CallV2(c, user.UpdateNotificationAccountInfoCaller.Invoke)
|
a2r.Call(c, user.UserClient.UpdateNotificationAccountInfo, u.Client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserApi) SearchNotificationAccount(c *gin.Context) {
|
func (u *UserApi) SearchNotificationAccount(c *gin.Context) {
|
||||||
a2r.CallV2(c, user.SearchNotificationAccountCaller.Invoke)
|
a2r.Call(c, user.UserClient.SearchNotificationAccount, u.Client)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,3 +75,15 @@ func (x *UserClient) GetUserOnlinePlatform(ctx context.Context, userID string) (
|
|||||||
func (x *UserClient) SetUserOnlineStatus(ctx context.Context, req *user.SetUserOnlineStatusReq) error {
|
func (x *UserClient) SetUserOnlineStatus(ctx context.Context, req *user.SetUserOnlineStatusReq) error {
|
||||||
return ignoreResp(x.UserClient.SetUserOnlineStatus(ctx, req))
|
return ignoreResp(x.UserClient.SetUserOnlineStatus(ctx, req))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *UserClient) GetNotificationByID(ctx context.Context, userID string) error {
|
||||||
|
_, err := x.UserClient.GetNotificationAccount(ctx, &user.GetNotificationAccountReq{
|
||||||
|
UserID: userID,
|
||||||
|
})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *UserClient) GetAllUserIDs(ctx context.Context, pageNumber, showNumber int32) ([]string, error) {
|
||||||
|
req := &user.GetAllUserIDReq{Pagination: &sdkws.RequestPagination{PageNumber: pageNumber, ShowNumber: showNumber}}
|
||||||
|
return extractField(ctx, x.UserClient.GetAllUserID, req, (*user.GetAllUserIDResp).GetUserIDs)
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user