Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8cc4e30bae |
@@ -1,5 +1,4 @@
|
|||||||
# Open-IM-Server
|
# Open-IM-Server
|
||||||

|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|||||||
Submodule cmd/Open-IM-SDK-Core updated: 588c9bb77b...539290887a
@@ -30,22 +30,18 @@ func main() {
|
|||||||
gin.SetMode(gin.ReleaseMode)
|
gin.SetMode(gin.ReleaseMode)
|
||||||
f, _ := os.Create("../logs/api.log")
|
f, _ := os.Create("../logs/api.log")
|
||||||
gin.DefaultWriter = io.MultiWriter(f)
|
gin.DefaultWriter = io.MultiWriter(f)
|
||||||
gin.SetMode(gin.DebugMode)
|
|
||||||
r := gin.Default()
|
r := gin.Default()
|
||||||
r.Use(utils.CorsHandler())
|
r.Use(utils.CorsHandler())
|
||||||
|
|
||||||
log.Info("load config: ", config.Config)
|
log.Info("load config: ", config.Config)
|
||||||
// user routing group, which handles user registration and login services
|
// user routing group, which handles user registration and login services
|
||||||
userRouterGroup := r.Group("/user")
|
userRouterGroup := r.Group("/user")
|
||||||
{
|
{
|
||||||
userRouterGroup.POST("/update_user_info", user.UpdateUserInfo) //1
|
userRouterGroup.POST("/update_user_info", user.UpdateUserInfo) //1
|
||||||
userRouterGroup.POST("/set_global_msg_recv_opt", user.SetGlobalRecvMessageOpt)
|
|
||||||
userRouterGroup.POST("/get_users_info", user.GetUsersInfo) //1
|
userRouterGroup.POST("/get_users_info", user.GetUsersInfo) //1
|
||||||
userRouterGroup.POST("/get_self_user_info", user.GetSelfUserInfo) //1
|
userRouterGroup.POST("/get_self_user_info", user.GetSelfUserInfo) //1
|
||||||
userRouterGroup.POST("/get_users_online_status", user.GetUsersOnlineStatus) //1
|
userRouterGroup.POST("/get_users_online_status", user.GetUsersOnlineStatus) //1
|
||||||
userRouterGroup.POST("/get_users_info_from_cache", user.GetUsersInfoFromCache)
|
|
||||||
userRouterGroup.POST("/get_user_friend_from_cache", user.GetFriendIDListFromCache)
|
|
||||||
userRouterGroup.POST("/get_black_list_from_cache", user.GetBlackIDListFromCache)
|
|
||||||
}
|
}
|
||||||
//friend routing group
|
//friend routing group
|
||||||
friendRouterGroup := r.Group("/friend")
|
friendRouterGroup := r.Group("/friend")
|
||||||
@@ -71,7 +67,7 @@ func main() {
|
|||||||
{
|
{
|
||||||
groupRouterGroup.POST("/create_group", group.CreateGroup) //1
|
groupRouterGroup.POST("/create_group", group.CreateGroup) //1
|
||||||
groupRouterGroup.POST("/set_group_info", group.SetGroupInfo) //1
|
groupRouterGroup.POST("/set_group_info", group.SetGroupInfo) //1
|
||||||
groupRouterGroup.POST("/join_group", group.JoinGroup) //1
|
groupRouterGroup.POST("join_group", group.JoinGroup) //1
|
||||||
groupRouterGroup.POST("/quit_group", group.QuitGroup) //1
|
groupRouterGroup.POST("/quit_group", group.QuitGroup) //1
|
||||||
groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse) //1
|
groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse) //1
|
||||||
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner) //1
|
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner) //1
|
||||||
@@ -83,27 +79,21 @@ func main() {
|
|||||||
groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1
|
groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1
|
||||||
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1
|
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1
|
||||||
groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1
|
groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1
|
||||||
groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList)
|
groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList) //1
|
||||||
groupRouterGroup.POST("/dismiss_group", group.DismissGroup) //
|
groupRouterGroup.POST("/dismiss_group", group.DismissGroup) //
|
||||||
groupRouterGroup.POST("/mute_group_member", group.MuteGroupMember)
|
groupRouterGroup.POST("/mute_group_member", group.MuteGroupMember)
|
||||||
groupRouterGroup.POST("/cancel_mute_group_member", group.CancelMuteGroupMember) //MuteGroup
|
groupRouterGroup.POST("/cancel_mute_group_member", group.CancelMuteGroupMember) //MuteGroup
|
||||||
groupRouterGroup.POST("/mute_group", group.MuteGroup)
|
groupRouterGroup.POST("/mute_group", group.MuteGroup)
|
||||||
groupRouterGroup.POST("/cancel_mute_group", group.CancelMuteGroup)
|
groupRouterGroup.POST("/cancel_mute_group", group.CancelMuteGroup)
|
||||||
|
|
||||||
groupRouterGroup.POST("/set_group_member_nickname", group.SetGroupMemberNickname)
|
groupRouterGroup.POST("/set_group_member_nickname", group.SetGroupMemberNickname)
|
||||||
groupRouterGroup.POST("/set_group_member_info", group.SetGroupMemberInfo)
|
|
||||||
}
|
|
||||||
superGroupRouterGroup := r.Group("/super_group")
|
|
||||||
{
|
|
||||||
superGroupRouterGroup.POST("/get_joined_group_list", group.GetJoinedSuperGroupList)
|
|
||||||
superGroupRouterGroup.POST("/get_groups_info", group.GetSuperGroupsInfo)
|
|
||||||
}
|
}
|
||||||
//certificate
|
//certificate
|
||||||
authRouterGroup := r.Group("/auth")
|
authRouterGroup := r.Group("/auth")
|
||||||
{
|
{
|
||||||
authRouterGroup.POST("/user_register", apiAuth.UserRegister) //1
|
authRouterGroup.POST("/user_register", apiAuth.UserRegister) //1
|
||||||
authRouterGroup.POST("/user_token", apiAuth.UserToken) //1
|
authRouterGroup.POST("/user_token", apiAuth.UserToken) //1
|
||||||
authRouterGroup.POST("/parse_token", apiAuth.ParseToken) //1
|
|
||||||
authRouterGroup.POST("/force_logout", apiAuth.ForceLogout) //1
|
|
||||||
}
|
}
|
||||||
//Third service
|
//Third service
|
||||||
thirdGroup := r.Group("/third")
|
thirdGroup := r.Group("/third")
|
||||||
@@ -112,10 +102,6 @@ func main() {
|
|||||||
thirdGroup.POST("/ali_oss_credential", apiThird.AliOSSCredential)
|
thirdGroup.POST("/ali_oss_credential", apiThird.AliOSSCredential)
|
||||||
thirdGroup.POST("/minio_storage_credential", apiThird.MinioStorageCredential)
|
thirdGroup.POST("/minio_storage_credential", apiThird.MinioStorageCredential)
|
||||||
thirdGroup.POST("/minio_upload", apiThird.MinioUploadFile)
|
thirdGroup.POST("/minio_upload", apiThird.MinioUploadFile)
|
||||||
thirdGroup.POST("/upload_update_app", apiThird.UploadUpdateApp)
|
|
||||||
thirdGroup.POST("/get_download_url", apiThird.GetDownloadURL)
|
|
||||||
thirdGroup.POST("/get_rtc_invitation_info", apiThird.GetRTCInvitationInfo)
|
|
||||||
thirdGroup.POST("/get_rtc_invitation_start_app", apiThird.GetRTCInvitationInfoStartApp)
|
|
||||||
}
|
}
|
||||||
//Message
|
//Message
|
||||||
chatGroup := r.Group("/msg")
|
chatGroup := r.Group("/msg")
|
||||||
@@ -124,14 +110,12 @@ func main() {
|
|||||||
chatGroup.POST("/send_msg", apiChat.SendMsg)
|
chatGroup.POST("/send_msg", apiChat.SendMsg)
|
||||||
chatGroup.POST("/pull_msg_by_seq", apiChat.PullMsgBySeqList)
|
chatGroup.POST("/pull_msg_by_seq", apiChat.PullMsgBySeqList)
|
||||||
chatGroup.POST("/del_msg", apiChat.DelMsg)
|
chatGroup.POST("/del_msg", apiChat.DelMsg)
|
||||||
chatGroup.POST("/clear_msg", apiChat.ClearMsg)
|
|
||||||
}
|
}
|
||||||
//Manager
|
//Manager
|
||||||
managementGroup := r.Group("/manager")
|
managementGroup := r.Group("/manager")
|
||||||
{
|
{
|
||||||
managementGroup.POST("/delete_user", manage.DeleteUser) //1
|
managementGroup.POST("/delete_user", manage.DeleteUser) //1
|
||||||
managementGroup.POST("/send_msg", manage.ManagementSendMsg)
|
managementGroup.POST("/send_msg", manage.ManagementSendMsg)
|
||||||
managementGroup.POST("/batch_send_msg", manage.ManagementBatchSendMsg)
|
|
||||||
managementGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1
|
managementGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1
|
||||||
managementGroup.POST("/account_check", manage.AccountCheck) //1
|
managementGroup.POST("/account_check", manage.AccountCheck) //1
|
||||||
managementGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1
|
managementGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1
|
||||||
@@ -145,7 +129,6 @@ func main() {
|
|||||||
conversationGroup.POST("/set_conversation", conversation.SetConversation)
|
conversationGroup.POST("/set_conversation", conversation.SetConversation)
|
||||||
conversationGroup.POST("/batch_set_conversation", conversation.BatchSetConversations)
|
conversationGroup.POST("/batch_set_conversation", conversation.BatchSetConversations)
|
||||||
conversationGroup.POST("/set_recv_msg_opt", conversation.SetRecvMsgOpt)
|
conversationGroup.POST("/set_recv_msg_opt", conversation.SetRecvMsgOpt)
|
||||||
conversationGroup.POST("/modify_conversation_field", conversation.ModifyConversationField)
|
|
||||||
}
|
}
|
||||||
// office
|
// office
|
||||||
officeGroup := r.Group("/office")
|
officeGroup := r.Group("/office")
|
||||||
@@ -166,7 +149,6 @@ func main() {
|
|||||||
officeGroup.POST("/get_user_work_moments", office.GetUserWorkMoments)
|
officeGroup.POST("/get_user_work_moments", office.GetUserWorkMoments)
|
||||||
officeGroup.POST("/get_user_friend_work_moments", office.GetUserFriendWorkMoments)
|
officeGroup.POST("/get_user_friend_work_moments", office.GetUserFriendWorkMoments)
|
||||||
officeGroup.POST("/set_user_work_moments_level", office.SetUserWorkMomentsLevel)
|
officeGroup.POST("/set_user_work_moments_level", office.SetUserWorkMomentsLevel)
|
||||||
officeGroup.POST("/delete_comment", office.DeleteComment)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
organizationGroup := r.Group("/organization")
|
organizationGroup := r.Group("/organization")
|
||||||
@@ -191,16 +173,10 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
go apiThird.MinioInit()
|
go apiThird.MinioInit()
|
||||||
defaultPorts := config.Config.Api.GinPort
|
ginPort := flag.Int("port", 10000, "get ginServerPort from cmd,default 10000 as port")
|
||||||
ginPort := flag.Int("port", defaultPorts[0], "get ginServerPort from cmd,default 10002 as port")
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
address := "0.0.0.0:" + strconv.Itoa(*ginPort)
|
fmt.Println("start api server, port: ", *ginPort)
|
||||||
if config.Config.Api.ListenIP != "" {
|
err := r.Run(":" + strconv.Itoa(*ginPort))
|
||||||
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
|
|
||||||
}
|
|
||||||
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
|
|
||||||
fmt.Println("start api server, address: ", address)
|
|
||||||
err := r.Run(address)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("", "run failed ", *ginPort, err.Error())
|
log.Error("", "run failed ", *ginPort, err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,8 @@ package main
|
|||||||
import (
|
import (
|
||||||
"Open_IM/internal/cms_api"
|
"Open_IM/internal/cms_api"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -15,14 +12,6 @@ func main() {
|
|||||||
gin.SetMode(gin.ReleaseMode)
|
gin.SetMode(gin.ReleaseMode)
|
||||||
router := cms_api.NewGinRouter()
|
router := cms_api.NewGinRouter()
|
||||||
router.Use(utils.CorsHandler())
|
router.Use(utils.CorsHandler())
|
||||||
defaultPorts := config.Config.CmsApi.GinPort
|
fmt.Println("start cms api server, port: ", 8000)
|
||||||
ginPort := flag.Int("port", defaultPorts[0], "get ginServerPort from cmd,default 10006 as port")
|
router.Run(":" + "8000")
|
||||||
flag.Parse()
|
|
||||||
address := "0.0.0.0:" + strconv.Itoa(*ginPort)
|
|
||||||
if config.Config.Api.ListenIP != "" {
|
|
||||||
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
|
|
||||||
}
|
|
||||||
address = config.Config.CmsApi.ListenIP + ":" + strconv.Itoa(*ginPort)
|
|
||||||
fmt.Println("start cms api server, address: ", address)
|
|
||||||
router.Run(address)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -24,7 +23,7 @@ func main() {
|
|||||||
r := gin.Default()
|
r := gin.Default()
|
||||||
r.Use(utils.CorsHandler())
|
r.Use(utils.CorsHandler())
|
||||||
|
|
||||||
authRouterGroup := r.Group("/demo")
|
authRouterGroup := r.Group("/auth")
|
||||||
{
|
{
|
||||||
authRouterGroup.POST("/code", register.SendVerificationCode)
|
authRouterGroup.POST("/code", register.SendVerificationCode)
|
||||||
authRouterGroup.POST("/verify", register.Verify)
|
authRouterGroup.POST("/verify", register.Verify)
|
||||||
@@ -32,17 +31,11 @@ func main() {
|
|||||||
authRouterGroup.POST("/login", register.Login)
|
authRouterGroup.POST("/login", register.Login)
|
||||||
authRouterGroup.POST("/reset_password", register.ResetPassword)
|
authRouterGroup.POST("/reset_password", register.ResetPassword)
|
||||||
}
|
}
|
||||||
defaultPorts := config.Config.Demo.Port
|
|
||||||
ginPort := flag.Int("port", defaultPorts[0], "get ginServerPort from cmd,default 42233 as port")
|
ginPort := flag.Int("port", 42233, "get ginServerPort from cmd,default 42233 as port")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
fmt.Println("start demo api server, port: ", *ginPort)
|
fmt.Println("start demo api server, port: ", *ginPort)
|
||||||
address := "0.0.0.0:" + strconv.Itoa(*ginPort)
|
err := r.Run(":" + strconv.Itoa(*ginPort))
|
||||||
if config.Config.Api.ListenIP != "" {
|
|
||||||
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
|
|
||||||
}
|
|
||||||
address = config.Config.CmsApi.ListenIP + ":" + strconv.Itoa(*ginPort)
|
|
||||||
fmt.Println("start demo api server address: ", address)
|
|
||||||
err := r.Run(address)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("", "run failed ", *ginPort, err.Error())
|
log.Error("", "run failed ", *ginPort, err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/internal/msg_gateway/gate"
|
"Open_IM/internal/msg_gateway/gate"
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"flag"
|
"flag"
|
||||||
@@ -12,10 +11,8 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.NewPrivateLog(constant.LogFileName)
|
log.NewPrivateLog(constant.LogFileName)
|
||||||
defaultRpcPorts := config.Config.RpcPort.OpenImMessageGatewayPort
|
rpcPort := flag.Int("rpc_port", 10400, "rpc listening port")
|
||||||
defaultWsPorts := config.Config.LongConnSvr.WebsocketPort
|
wsPort := flag.Int("ws_port", 17778, "ws listening port")
|
||||||
rpcPort := flag.Int("rpc_port", defaultRpcPorts[0], "rpc listening port")
|
|
||||||
wsPort := flag.Int("ws_port", defaultWsPorts[0], "ws listening port")
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/internal/push/logic"
|
"Open_IM/internal/push/logic"
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"flag"
|
"flag"
|
||||||
@@ -11,8 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
defaultPorts := config.Config.RpcPort.OpenImPushPort
|
rpcPort := flag.Int("port", 10700, "rpc listening port")
|
||||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
.PHONY: all build run gotool install clean help
|
||||||
|
|
||||||
BINARY_NAME=open_im_cache
|
BINARY_NAME=open_im_timer_task
|
||||||
BIN_DIR=../../../bin/
|
BIN_DIR=../../bin/
|
||||||
|
|
||||||
all: gotool build
|
all: gotool build
|
||||||
|
|
||||||
@@ -22,3 +22,4 @@ install:
|
|||||||
clean:
|
clean:
|
||||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
||||||
|
|
||||||
|
|
||||||
63
cmd/open_im_timer_task/main.go
Normal file
63
cmd/open_im_timer_task/main.go
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
|
"Open_IM/pkg/common/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
log.NewPrivateLog(constant.LogFileName)
|
||||||
|
//for {
|
||||||
|
// fmt.Println("start delete mongodb expired record")
|
||||||
|
// timeUnixBegin := time.Now().Unix()
|
||||||
|
// count, _ := db.DB.MgoUserCount()
|
||||||
|
// fmt.Println("mongodb record count: ", count)
|
||||||
|
// for i := 0; i < count; i++ {
|
||||||
|
// time.Sleep(1 * time.Millisecond)
|
||||||
|
// uid, _ := db.DB.MgoSkipUID(i)
|
||||||
|
// fmt.Println("operate uid: ", uid)
|
||||||
|
// err := db.DB.DelUserChat(uid)
|
||||||
|
// if err != nil {
|
||||||
|
// fmt.Println("operate uid failed: ", uid, err.Error())
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// timeUnixEnd := time.Now().Unix()
|
||||||
|
// costTime := timeUnixEnd - timeUnixBegin
|
||||||
|
// if costTime > int64(config.Config.Mongo.DBRetainChatRecords*24*3600) {
|
||||||
|
// continue
|
||||||
|
// } else {
|
||||||
|
// sleepTime := 0
|
||||||
|
// if int64(config.Config.Mongo.DBRetainChatRecords*24*3600)-costTime > 24*3600 {
|
||||||
|
// sleepTime = 24 * 3600
|
||||||
|
// } else {
|
||||||
|
// sleepTime = config.Config.Mongo.DBRetainChatRecords*24*3600 - int(costTime)
|
||||||
|
// }
|
||||||
|
// fmt.Println("sleep: ", sleepTime)
|
||||||
|
// time.Sleep(time.Duration(sleepTime) * time.Second)
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//for {
|
||||||
|
// uidList, err := im_mysql_model.SelectAllUserID()
|
||||||
|
// if err != nil {
|
||||||
|
// //log.NewError("999999", err.Error())
|
||||||
|
// } else {
|
||||||
|
// for _, v := range uidList {
|
||||||
|
// minSeq, err := commonDB.DB.GetMinSeqFromMongo(v)
|
||||||
|
// if err != nil {
|
||||||
|
// //log.NewError("999999", "get user minSeq err", err.Error(), v)
|
||||||
|
// continue
|
||||||
|
// } else {
|
||||||
|
// err := commonDB.DB.SetUserMinSeq(v, minSeq)
|
||||||
|
// if err != nil {
|
||||||
|
// //log.NewError("999999", "set user minSeq err", err.Error(), v)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// time.Sleep(time.Duration(100) * time.Millisecond)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,14 +2,12 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
rpcMessageCMS "Open_IM/internal/rpc/admin_cms"
|
rpcMessageCMS "Open_IM/internal/rpc/admin_cms"
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
defaultPorts := config.Config.RpcPort.OpenImAdminCmsPort
|
rpcPort := flag.Int("port", 11000, "rpc listening port")
|
||||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
fmt.Println("start cms rpc server, port: ", *rpcPort)
|
fmt.Println("start cms rpc server, port: ", *rpcPort)
|
||||||
rpcServer := rpcMessageCMS.NewAdminCMSServer(*rpcPort)
|
rpcServer := rpcMessageCMS.NewAdminCMSServer(*rpcPort)
|
||||||
|
|||||||
@@ -2,14 +2,12 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
rpcAuth "Open_IM/internal/rpc/auth"
|
rpcAuth "Open_IM/internal/rpc/auth"
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
defaultPorts := config.Config.RpcPort.OpenImAuthPort
|
rpcPort := flag.Int("port", 10600, "RpcToken default listen port 10800")
|
||||||
rpcPort := flag.Int("port", defaultPorts[0], "RpcToken default listen port 10800")
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
fmt.Println("start auth rpc server, port: ", *rpcPort)
|
fmt.Println("start auth rpc server, port: ", *rpcPort)
|
||||||
rpcServer := rpcAuth.NewRpcAuthServer(*rpcPort)
|
rpcServer := rpcAuth.NewRpcAuthServer(*rpcPort)
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
rpcCache "Open_IM/internal/rpc/cache"
|
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
defaultPorts := config.Config.RpcPort.OpenImCachePort
|
|
||||||
rpcPort := flag.Int("port", defaultPorts[0], "RpcToken default listen port 10800")
|
|
||||||
flag.Parse()
|
|
||||||
fmt.Println("start auth rpc server, port: ", *rpcPort)
|
|
||||||
rpcServer := rpcCache.NewCacheServer(*rpcPort)
|
|
||||||
rpcServer.Run()
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
|
||||||
|
|
||||||
BINARY_NAME=open_im_conversation
|
|
||||||
BIN_DIR=../../../bin/
|
|
||||||
|
|
||||||
all: gotool build
|
|
||||||
|
|
||||||
build:
|
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
|
||||||
|
|
||||||
run:
|
|
||||||
@go run ./
|
|
||||||
|
|
||||||
gotool:
|
|
||||||
go fmt ./
|
|
||||||
go vet ./
|
|
||||||
|
|
||||||
install:
|
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
|
||||||
|
|
||||||
clean:
|
|
||||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
|
||||||
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
rpcConversation "Open_IM/internal/rpc/conversation"
|
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
defaultPorts := config.Config.RpcPort.OpenImConversationPort
|
|
||||||
rpcPort := flag.Int("port", defaultPorts[0], "RpcConversation default listen port 11300")
|
|
||||||
flag.Parse()
|
|
||||||
fmt.Println("start conversation rpc server, port: ", *rpcPort)
|
|
||||||
rpcServer := rpcConversation.NewRpcConversationServer(*rpcPort)
|
|
||||||
rpcServer.Run()
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -2,14 +2,13 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/internal/rpc/friend"
|
"Open_IM/internal/rpc/friend"
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
defaultPorts := config.Config.RpcPort.OpenImFriendPort
|
|
||||||
rpcPort := flag.Int("port", defaultPorts[0], "get RpcFriendPort from cmd,default 12000 as port")
|
rpcPort := flag.Int("port", 10200, "get RpcFriendPort from cmd,default 12000 as port")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
fmt.Println("start friend rpc server, port: ", *rpcPort)
|
fmt.Println("start friend rpc server, port: ", *rpcPort)
|
||||||
rpcServer := friend.NewFriendServer(*rpcPort)
|
rpcServer := friend.NewFriendServer(*rpcPort)
|
||||||
|
|||||||
@@ -2,14 +2,12 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/internal/rpc/group"
|
"Open_IM/internal/rpc/group"
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
defaultPorts := config.Config.RpcPort.OpenImGroupPort
|
rpcPort := flag.Int("port", 10500, "get RpcGroupPort from cmd,default 16000 as port")
|
||||||
rpcPort := flag.Int("port", defaultPorts[0], "get RpcGroupPort from cmd,default 16000 as port")
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
fmt.Println("start group rpc server, port: ", *rpcPort)
|
fmt.Println("start group rpc server, port: ", *rpcPort)
|
||||||
rpcServer := group.NewGroupServer(*rpcPort)
|
rpcServer := group.NewGroupServer(*rpcPort)
|
||||||
|
|||||||
@@ -2,14 +2,12 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
rpcMessageCMS "Open_IM/internal/rpc/message_cms"
|
rpcMessageCMS "Open_IM/internal/rpc/message_cms"
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
defaultPorts := config.Config.RpcPort.OpenImMessageCmsPort[0]
|
rpcPort := flag.Int("port", 10900, "rpc listening port")
|
||||||
rpcPort := flag.Int("port", defaultPorts, "rpc listening port")
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
fmt.Println("start msg cms rpc server, port: ", *rpcPort)
|
fmt.Println("start msg cms rpc server, port: ", *rpcPort)
|
||||||
rpcServer := rpcMessageCMS.NewMessageCMSServer(*rpcPort)
|
rpcServer := rpcMessageCMS.NewMessageCMSServer(*rpcPort)
|
||||||
|
|||||||
@@ -2,14 +2,12 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
rpcChat "Open_IM/internal/rpc/msg"
|
rpcChat "Open_IM/internal/rpc/msg"
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
defaultPorts := config.Config.RpcPort.OpenImMessagePort
|
rpcPort := flag.Int("port", 10300, "rpc listening port")
|
||||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
fmt.Println("start msg rpc server, port: ", *rpcPort)
|
fmt.Println("start msg rpc server, port: ", *rpcPort)
|
||||||
rpcServer := rpcChat.NewRpcChatServer(*rpcPort)
|
rpcServer := rpcChat.NewRpcChatServer(*rpcPort)
|
||||||
|
|||||||
@@ -2,14 +2,12 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
rpc "Open_IM/internal/rpc/office"
|
rpc "Open_IM/internal/rpc/office"
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
defaultPorts := config.Config.RpcPort.OpenImOfficePort
|
rpcPort := flag.Int("port", 11100, "rpc listening port")
|
||||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
fmt.Println("start office rpc server, port: ", *rpcPort)
|
fmt.Println("start office rpc server, port: ", *rpcPort)
|
||||||
rpcServer := rpc.NewOfficeServer(*rpcPort)
|
rpcServer := rpc.NewOfficeServer(*rpcPort)
|
||||||
|
|||||||
@@ -2,14 +2,12 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/internal/rpc/organization"
|
"Open_IM/internal/rpc/organization"
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
defaultPorts := config.Config.RpcPort.OpenImOrganizationPort
|
rpcPort := flag.Int("port", 11200, "get RpcOrganizationPort from cmd,default 11200 as port")
|
||||||
rpcPort := flag.Int("port", defaultPorts[0], "get RpcOrganizationPort from cmd,default 11200 as port")
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
fmt.Println("start organization rpc server, port: ", *rpcPort)
|
fmt.Println("start organization rpc server, port: ", *rpcPort)
|
||||||
rpcServer := organization.NewServer(*rpcPort)
|
rpcServer := organization.NewServer(*rpcPort)
|
||||||
|
|||||||
@@ -2,14 +2,12 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/internal/rpc/statistics"
|
"Open_IM/internal/rpc/statistics"
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
defaultPorts := config.Config.RpcPort.OpenImStatisticsPort
|
rpcPort := flag.Int("port", 10800, "rpc listening port")
|
||||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
fmt.Println("start statistics rpc server, port: ", *rpcPort)
|
fmt.Println("start statistics rpc server, port: ", *rpcPort)
|
||||||
rpcServer := statistics.NewStatisticsServer(*rpcPort)
|
rpcServer := statistics.NewStatisticsServer(*rpcPort)
|
||||||
|
|||||||
@@ -2,14 +2,12 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/internal/rpc/user"
|
"Open_IM/internal/rpc/user"
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
defaultPorts := config.Config.RpcPort.OpenImUserPort
|
rpcPort := flag.Int("port", 10100, "rpc listening port")
|
||||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
fmt.Println("start user rpc server, port: ", *rpcPort)
|
fmt.Println("start user rpc server, port: ", *rpcPort)
|
||||||
rpcServer := user.NewUserServer(*rpcPort)
|
rpcServer := user.NewUserServer(*rpcPort)
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
# The class cannot be named by Pascal or camel case.
|
# The class cannot be named by Pascal or camel case.
|
||||||
# The class cannot be named by Pascal or camel case.
|
|
||||||
# If it is not used, the corresponding structure will not be set,
|
# If it is not used, the corresponding structure will not be set,
|
||||||
# and it will not be read naturally.
|
# and it will not be read naturally.
|
||||||
serverversion: 2.0.0
|
serverversion: 2.0.0
|
||||||
#---------------Infrastructure configuration---------------------#
|
#---------------Infrastructure configuration---------------------#
|
||||||
etcd:
|
etcd:
|
||||||
etcdSchema: openim #默认即可
|
etcdSchema: openIM #默认即可
|
||||||
etcdAddr: [ 127.0.0.1:2379 ] #单机部署时,默认即可
|
etcdAddr: [ 127.0.0.1:2379 ] #单机部署时,默认即可
|
||||||
|
|
||||||
k8sMod: false #开启k8s模式 使用pod里面环境变量请求services调用服务 而并非etcd
|
|
||||||
|
|
||||||
mysql:
|
mysql:
|
||||||
dbMysqlAddress: [ 127.0.0.1:13306 ] #mysql地址 目前仅支持单机,默认即可
|
dbMysqlAddress: [ 127.0.0.1:13306 ] #mysql地址 目前仅支持单机,默认即可
|
||||||
dbMysqlUserName: root #mysql用户名,建议修改
|
dbMysqlUserName: root #mysql用户名,建议修改
|
||||||
@@ -23,40 +20,32 @@ mysql:
|
|||||||
|
|
||||||
mongo:
|
mongo:
|
||||||
dbUri: ""#当dbUri值不为空则直接使用该值
|
dbUri: ""#当dbUri值不为空则直接使用该值
|
||||||
dbAddress: 127.0.0.1:37017 #单机时为mongo地址,使用分片集群时,为mongos地址 默认即可
|
dbAddress: [ 127.0.0.1:37017 ] #mongo地址 目前仅支持单机,默认即可
|
||||||
dbDirect: false
|
dbDirect: false
|
||||||
dbTimeout: 60
|
dbTimeout: 10
|
||||||
dbDatabase: openIM #mongo db 默认即可
|
dbDatabase: openIM #mongo db 默认即可
|
||||||
dbSource: admin
|
dbSource: admin
|
||||||
dbUserName: #mongo用户名,建议先不设置
|
dbUserName: #mongo用户名,建议先不设置
|
||||||
dbPassword: #mongo密码,建议先不设置
|
dbPassword: #mongo密码,建议先不设置
|
||||||
dbMaxPoolSize: 100
|
dbMaxPoolSize: 20
|
||||||
dbRetainChatRecords: 3650 #mongo保存离线消息时间(天),根据需求修改
|
dbRetainChatRecords: 3650 #mongo保存离线消息时间(天),根据需求修改
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
dbAddress: [ 127.0.0.1:16379 ] #redis地址 单机时,填写一个地址即可,使用redis集群时候,填写集群中多个节点地址(主从地址都可以填写,增加容灾能力),默认即可
|
dbAddress: 127.0.0.1:16379 #redis地址 目前仅支持单机,默认即可
|
||||||
dbMaxIdle: 128
|
dbMaxIdle: 128
|
||||||
dbMaxActive: 0
|
dbMaxActive: 0
|
||||||
dbIdleTimeout: 120
|
dbIdleTimeout: 120
|
||||||
dbPassWord: openIM #redis密码 建议修改
|
dbPassWord: openIM #redis密码 建议修改
|
||||||
enableCluster: false #如果外部redis以集群方式启动,需要打开此开关
|
|
||||||
|
|
||||||
kafka:
|
kafka:
|
||||||
ws2mschat:
|
ws2mschat:
|
||||||
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||||
topic: "ws2ms_chat"
|
topic: "ws2ms_chat"
|
||||||
ws2mschatoffline:
|
|
||||||
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
|
||||||
topic: "ws2ms_chat_offline"
|
|
||||||
msgtomongo:
|
|
||||||
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
|
||||||
topic: "msg_to_mongo"
|
|
||||||
ms2pschat:
|
ms2pschat:
|
||||||
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||||
topic: "ms2ps_chat"
|
topic: "ms2ps_chat"
|
||||||
consumergroupid:
|
consumergroupid:
|
||||||
msgToTransfer: mongo
|
msgToMongo: mongo
|
||||||
msgToMongo: mongo_ex
|
|
||||||
msgToMySql: mysql
|
msgToMySql: mysql
|
||||||
msgToPush: push
|
msgToPush: push
|
||||||
|
|
||||||
@@ -70,11 +59,6 @@ kafka:
|
|||||||
#如果是单机模式,用0.0.0.0或者不填,默认即可
|
#如果是单机模式,用0.0.0.0或者不填,默认即可
|
||||||
serverip: 0.0.0.0
|
serverip: 0.0.0.0
|
||||||
|
|
||||||
rpcRegisterIP: 127.0.0.1
|
|
||||||
listenIP: 0.0.0.0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# endpoints 内部组件间访问的端点host名称,访问时,可以内部直接访问 host:port 来访问
|
# endpoints 内部组件间访问的端点host名称,访问时,可以内部直接访问 host:port 来访问
|
||||||
endpoints:
|
endpoints:
|
||||||
api: openim_api
|
api: openim_api
|
||||||
@@ -92,28 +76,24 @@ endpoints:
|
|||||||
rpc_office: openim_rpc_office
|
rpc_office: openim_rpc_office
|
||||||
|
|
||||||
api:
|
api:
|
||||||
openImApiPort: [ 10002 ] #api服务端口,默认即可,需要开放此端口或做nginx转发
|
openImApiPort: [ 10000 ] #api服务端口,默认即可,需要开放此端口或做nginx转发
|
||||||
listenIP: 0.0.0.0
|
|
||||||
cmsapi:
|
cmsapi:
|
||||||
openImCmsApiPort: [ 10006 ] #管理后台api服务端口,默认即可,需要开放此端口或做nginx转发
|
openImCmsApiPort: [ 8000 ] #管理后台api服务端口,默认即可,需要开放此端口或做nginx转发
|
||||||
listenIP: 0.0.0.0
|
|
||||||
sdk:
|
sdk:
|
||||||
openImSdkWsPort: [ 10003 ] #jssdk服务端口,默认即可,项目中使用jssdk才需开放此端口或做nginx转发
|
openImSdkWsPort: [ 30000 ] #jssdk服务端口,默认即可,项目中使用jssdk才需开放此端口或做nginx转发
|
||||||
dataDir: [ ../db/sdk/ ]
|
|
||||||
#对象存储服务,以下配置二选一,目前支持两种,腾讯云和minio,二者配置好其中一种即可(如果使用minio参考https://doc.rentsoft.cn/#/qa/minio搭建minio服务器)
|
#对象存储服务,以下配置二选一,目前支持两种,腾讯云和minio,二者配置好其中一种即可(如果使用minio参考https://doc.rentsoft.cn/#/qa/minio搭建minio服务器)
|
||||||
credential: #腾讯cos,发送图片、视频、文件时需要,请自行申请后替换,必须修改
|
credential: #腾讯cos,发送图片、视频、文件时需要,请自行申请后替换,必须修改
|
||||||
tencent:
|
tencent:
|
||||||
appID: 1302656840
|
appID: 1302656840
|
||||||
region: ap-chengdu
|
region: ap-chengdu
|
||||||
bucket: echat-1302656840
|
bucket: echat-1302656840
|
||||||
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC1
|
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC
|
||||||
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe1
|
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe
|
||||||
minio: #MinIO 发送图片、视频、文件时需要,请自行申请后替换,必须修改。 客户端初始化InitSDK,中 object_storage参数为minio
|
minio: #MinIO 发送图片、视频、文件时需要,请自行申请后替换,必须修改。 客户端初始化InitSDK,中 object_storage参数为minio
|
||||||
bucket: openim # 存储内容桶
|
bucket: openim
|
||||||
appBucket: app # 存储app的桶
|
|
||||||
location: us-east-1
|
location: us-east-1
|
||||||
endpoint: http://127.0.0.1:10005 #minio外网ip 这个ip是给客户端访问的
|
endpoint: http://127.0.0.1:9000 #minio外网ip 这个ip是给客户端访问的
|
||||||
endpointInner: http://127.0.0.1:10005 #minio内网地址 如果im server 可以通过内网访问到 minio就可以填写
|
endpointInner: http://127.0.0.1:9000 #minio内网地址 如果im server 可以通过内网访问到 minio就可以填写
|
||||||
endpointInnerEnable: true #是否启用minio内网地址 启用可以让桶初始化,IM server连接minio走内网地址访问
|
endpointInnerEnable: true #是否启用minio内网地址 启用可以让桶初始化,IM server连接minio走内网地址访问
|
||||||
accessKeyID: user12345
|
accessKeyID: user12345
|
||||||
secretAccessKey: key12345
|
secretAccessKey: key12345
|
||||||
@@ -131,20 +111,18 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申
|
|||||||
|
|
||||||
|
|
||||||
rpcport: #rpc服务端口 默认即可
|
rpcport: #rpc服务端口 默认即可
|
||||||
openImUserPort: [ 10110 ]
|
openImUserPort: [ 10100 ]
|
||||||
openImFriendPort: [ 10120 ]
|
openImFriendPort: [ 10200 ]
|
||||||
openImMessagePort: [ 10130 ]
|
openImOfflineMessagePort: [ 10300 ]
|
||||||
openImMessageGatewayPort: [ 10140 ]
|
openImOnlineRelayPort: [ 10400 ]
|
||||||
openImGroupPort: [ 10150 ]
|
openImGroupPort: [ 10500 ]
|
||||||
openImAuthPort: [ 10160 ]
|
openImAuthPort: [ 10600 ]
|
||||||
openImPushPort: [ 10170 ]
|
openImPushPort: [ 10700 ]
|
||||||
openImStatisticsPort: [ 10180 ]
|
openImStatisticsPort: [ 10800 ]
|
||||||
openImMessageCmsPort: [ 10190 ]
|
openImMessageCmsPort: [ 10900 ]
|
||||||
openImAdminCmsPort: [ 10200 ]
|
openImAdminCmsPort: [ 11000 ]
|
||||||
openImOfficePort: [ 10210 ]
|
openImOfficePort: [ 11100 ]
|
||||||
openImOrganizationPort: [ 10220 ]
|
openImOrganizationPort: [ 11200 ]
|
||||||
openImConversationPort: [ 10230 ]
|
|
||||||
openImCachePort: [10240]
|
|
||||||
c2c:
|
c2c:
|
||||||
callbackBeforeSendMsg:
|
callbackBeforeSendMsg:
|
||||||
switch: false
|
switch: false
|
||||||
@@ -163,14 +141,12 @@ rpcregistername: #rpc注册服务名,默认即可
|
|||||||
openImOnlineMessageRelayName: OnlineMessageRelay
|
openImOnlineMessageRelayName: OnlineMessageRelay
|
||||||
openImGroupName: Group
|
openImGroupName: Group
|
||||||
openImAuthName: Auth
|
openImAuthName: Auth
|
||||||
openImStatisticsName: Statistics
|
OpenImStatisticsName: Statistics
|
||||||
openImMessageCMSName: MessageCMS
|
OpenImMessageCMSName: MessageCMS
|
||||||
openImAdminCMSName: AdminCMS
|
openImAdminCMSName: AdminCMS
|
||||||
openImOfficeName: Office
|
openImOfficeName: Office
|
||||||
openImOrganizationName: Organization
|
openImOrganizationName: Organization
|
||||||
openImConversationName: Conversation
|
|
||||||
openImCacheName: Cache
|
|
||||||
openImRealTimeCommName: RealTimeComm
|
|
||||||
log:
|
log:
|
||||||
storageLocation: ../logs/
|
storageLocation: ../logs/
|
||||||
rotationTime: 24
|
rotationTime: 24
|
||||||
@@ -188,7 +164,7 @@ modulename: #日志文件按模块命名,默认即可
|
|||||||
pushName: push
|
pushName: push
|
||||||
|
|
||||||
longconnsvr:
|
longconnsvr:
|
||||||
openImWsPort: [ 10001 ] # ws服务端口,默认即可,要开放此端口或做nginx转发
|
openImWsPort: [ 17778 ] # ws服务端口,默认即可,要开放此端口或做nginx转发
|
||||||
websocketMaxConnNum: 10000
|
websocketMaxConnNum: 10000
|
||||||
websocketMaxMsgLen: 4096
|
websocketMaxMsgLen: 4096
|
||||||
websocketTimeOut: 10
|
websocketTimeOut: 10
|
||||||
@@ -222,7 +198,6 @@ manager:
|
|||||||
#app管理员userID和对应的secret 建议修改。 用于管理后台登录,也可以用户管理后台对应的api
|
#app管理员userID和对应的secret 建议修改。 用于管理后台登录,也可以用户管理后台对应的api
|
||||||
appManagerUid: [ "openIM123456","openIM654321", "openIM333", "openIMAdmin"]
|
appManagerUid: [ "openIM123456","openIM654321", "openIM333", "openIMAdmin"]
|
||||||
secrets: [ "openIM1","openIM2", "openIM333", "openIMAdmin"]
|
secrets: [ "openIM1","openIM2", "openIM333", "openIMAdmin"]
|
||||||
appSysNotificationName: "系统通知"
|
|
||||||
|
|
||||||
secret: tuoyun
|
secret: tuoyun
|
||||||
# 多端互踢策略
|
# 多端互踢策略
|
||||||
@@ -230,15 +205,7 @@ secret: tuoyun
|
|||||||
multiloginpolicy: 1
|
multiloginpolicy: 1
|
||||||
|
|
||||||
#chat log insert to db
|
#chat log insert to db
|
||||||
chatpersistencemysql: true
|
chatPersistenceMysql: true
|
||||||
#可靠性存储
|
|
||||||
reliablestorage: false
|
|
||||||
#消息缓存时间
|
|
||||||
msgCacheTimeout: 86400
|
|
||||||
#群聊已读开启
|
|
||||||
groupMessageHasReadReceiptEnable: true
|
|
||||||
#单聊已读开启
|
|
||||||
singleMessageHasReadReceiptEnable: true
|
|
||||||
|
|
||||||
#token config
|
#token config
|
||||||
tokenpolicy:
|
tokenpolicy:
|
||||||
@@ -266,7 +233,7 @@ callback:
|
|||||||
# callback url 需要自行更换callback url
|
# callback url 需要自行更换callback url
|
||||||
callbackUrl : "http://127.0.0.1:8080/callback"
|
callbackUrl : "http://127.0.0.1:8080/callback"
|
||||||
# 开启关闭操作前后回调的配置
|
# 开启关闭操作前后回调的配置
|
||||||
callbackBeforeSendSingleMsg:
|
callbackbeforeSendSingleMsg:
|
||||||
enable: false # 回调是否启用
|
enable: false # 回调是否启用
|
||||||
callbackTimeOut: 2 # 回调超时时间
|
callbackTimeOut: 2 # 回调超时时间
|
||||||
callbackFailedContinue: true # 回调超时是否继续执行代码
|
callbackFailedContinue: true # 回调超时是否继续执行代码
|
||||||
@@ -284,16 +251,7 @@ callback:
|
|||||||
enable: false
|
enable: false
|
||||||
callbackTimeOut: 2
|
callbackTimeOut: 2
|
||||||
callbackFailedContinue: true
|
callbackFailedContinue: true
|
||||||
callbackUserOnline:
|
|
||||||
enable: false
|
|
||||||
callbackTimeOut: 2
|
|
||||||
callbackUserOffline:
|
|
||||||
enable: false
|
|
||||||
callbackTimeOut: 2
|
|
||||||
callbackOfflinePush:
|
|
||||||
enable: false
|
|
||||||
callbackTimeOut: 2
|
|
||||||
callbackFailedContinue: true # 回调超时是否继续离线推送
|
|
||||||
|
|
||||||
notification:
|
notification:
|
||||||
groupCreated:
|
groupCreated:
|
||||||
@@ -667,27 +625,14 @@ notification:
|
|||||||
openTips: "burn after reading was opened"
|
openTips: "burn after reading was opened"
|
||||||
closeTips: "burn after reading was closed"
|
closeTips: "burn after reading was closed"
|
||||||
|
|
||||||
###################organization################
|
|
||||||
joinDepartmentNotification:
|
|
||||||
conversation:
|
|
||||||
reliabilityLevel: 3
|
|
||||||
unreadCount: true
|
|
||||||
offlinePush:
|
|
||||||
switch: false
|
|
||||||
title: "welcome user join department"
|
|
||||||
desc: "welcome user join department"
|
|
||||||
ext: "welcome user join department"
|
|
||||||
defaultTips:
|
|
||||||
tips: "welcome user join department"
|
|
||||||
|
|
||||||
#---------------demo configuration---------------------#
|
#---------------demo configuration---------------------#
|
||||||
#The following configuration items are applied to openIM Demo configuration
|
#The following configuration items are applied to openIM Demo configuration
|
||||||
#是否启动demo,如果自身没有账号体系,设置为true
|
#是否启动demo,如果自身没有账号体系,设置为true
|
||||||
demoswitch: true
|
demoswitch: true
|
||||||
demo:
|
demo:
|
||||||
listenIP: 0.0.0.0
|
|
||||||
#demo对外服务端口,默认即可,需要开放此端口或做nginx转发
|
#demo对外服务端口,默认即可,需要开放此端口或做nginx转发
|
||||||
openImDemoPort: [ 10004 ]
|
openImDemoPort: [ 42233 ]
|
||||||
alismsverify: #阿里云短信配置,在阿里云申请成功后修改以下四项,必须修改
|
alismsverify: #阿里云短信配置,在阿里云申请成功后修改以下四项,必须修改
|
||||||
accessKeyId: LTAI5tJPkn4HuuePdiLdGqe7
|
accessKeyId: LTAI5tJPkn4HuuePdiLdGqe7
|
||||||
accessKeySecret: 4n9OJ7ZCVN1U6KeHDAtOyNeVZcjOuV
|
accessKeySecret: 4n9OJ7ZCVN1U6KeHDAtOyNeVZcjOuV
|
||||||
@@ -702,8 +647,7 @@ demo:
|
|||||||
senderAuthorizationCode: "gxyausfoevlzbfag"
|
senderAuthorizationCode: "gxyausfoevlzbfag"
|
||||||
smtpAddr: "smtp.qq.com"
|
smtpAddr: "smtp.qq.com"
|
||||||
smtpPort: 25 #需开放此端口 出口方向
|
smtpPort: 25 #需开放此端口 出口方向
|
||||||
testDepartMentID: 001
|
|
||||||
imAPIURL: http://127.0.0.1:10002
|
|
||||||
|
|
||||||
rtc:
|
rtc:
|
||||||
signalTimeout: 35
|
port: 11300
|
||||||
|
address: 127.0.0.1
|
||||||
@@ -6,7 +6,6 @@ ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
|||||||
|
|
||||||
# 将可执行文件复制到目标目录
|
# 将可执行文件复制到目标目录
|
||||||
ADD ./open_im_api $WORKDIR/main
|
ADD ./open_im_api $WORKDIR/main
|
||||||
COPY ./start_api.sh $$WORKDIR
|
|
||||||
|
|
||||||
# 创建用于挂载的几个目录,添加可执行权限
|
# 创建用于挂载的几个目录,添加可执行权限
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
|
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
|
||||||
@@ -14,4 +13,4 @@ RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
|
|||||||
|
|
||||||
|
|
||||||
WORKDIR $WORKDIR
|
WORKDIR $WORKDIR
|
||||||
CMD ./start_api.sh
|
CMD ./main
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
FROM ubuntu
|
|
||||||
|
|
||||||
# 设置固定的项目路径
|
|
||||||
ENV WORKDIR /Open-IM-Server
|
|
||||||
ENV CMDDIR $WORKDIR/cmd
|
|
||||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
|
||||||
|
|
||||||
|
|
||||||
# 将可执行文件复制到目标目录
|
|
||||||
ADD ./open_im_admin_cms $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
# 创建用于挂载的几个目录,添加可执行权限
|
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
|
||||||
chmod +x $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config", "/Open-IM-Server/script"]
|
|
||||||
|
|
||||||
|
|
||||||
WORKDIR $CMDDIR
|
|
||||||
CMD ./main
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: admin-cms-deployment
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: admin-cms # 选择这个指定标签执行
|
|
||||||
replicas: 2 # 运行pod数量
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: admin-cms # 标签
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: admin-cms
|
|
||||||
image: openim/admin_cms:v2.0.10k
|
|
||||||
# imagePullPolicy: Always #每次启动都重新拉取镜像
|
|
||||||
ports:
|
|
||||||
- containerPort: 10200
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: config
|
|
||||||
strategy: #更新策略
|
|
||||||
type: RollingUpdate # 滚动更新
|
|
||||||
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
FROM ubuntu
|
|
||||||
|
|
||||||
# 设置固定的项目路径
|
|
||||||
ENV WORKDIR /Open-IM-Server
|
|
||||||
ENV CMDDIR $WORKDIR/cmd
|
|
||||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
|
||||||
|
|
||||||
# 将可执行文件复制到目标目录
|
|
||||||
ADD ./open_im_api $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
# 创建用于挂载的几个目录,添加可执行权限
|
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
|
||||||
chmod +x $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
|
||||||
|
|
||||||
|
|
||||||
WORKDIR $CMDDIR
|
|
||||||
CMD ./main
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: api-deployment
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: api # 选择这个指定标签执行
|
|
||||||
replicas: 2 # 运行pod数量
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: api # 标签
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: api
|
|
||||||
image: openim/api:v2.0.10k
|
|
||||||
imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 10002
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: config
|
|
||||||
strategy: #更新策略
|
|
||||||
type: RollingUpdate # 滚动更新
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: api
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- name: api-port
|
|
||||||
protocol: TCP
|
|
||||||
port: 10002
|
|
||||||
targetPort: 10002
|
|
||||||
selector:
|
|
||||||
app: api
|
|
||||||
type: NodePort
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
FROM ubuntu
|
|
||||||
|
|
||||||
# 设置固定的项目路径
|
|
||||||
ENV WORKDIR /Open-IM-Server
|
|
||||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
|
||||||
|
|
||||||
# 将可执行文件复制到目标目录
|
|
||||||
ADD ./open_im_auth $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
# 创建用于挂载的几个目录,添加可执行权限
|
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
|
||||||
chmod +x $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
|
||||||
|
|
||||||
|
|
||||||
WORKDIR $WORKDIR
|
|
||||||
CMD ./cmd/main
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: auth-deployment
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: auth # 选择这个指定标签执行
|
|
||||||
replicas: 2 # 运行pod数量
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: auth # 标签
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: auth
|
|
||||||
image: openim/auth:v2.0.10k
|
|
||||||
# imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 10160
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: config
|
|
||||||
strategy: #更新策略
|
|
||||||
type: RollingUpdate # 滚动更新
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
#/bin/sh
|
|
||||||
source ./path_info.cfg
|
|
||||||
|
|
||||||
# images version
|
|
||||||
version=v2.0.10k
|
|
||||||
git pull
|
|
||||||
cd ../script/; ./build_all_service.sh
|
|
||||||
cd ../deploy_k8s/
|
|
||||||
|
|
||||||
for i in ${service[*]}
|
|
||||||
do
|
|
||||||
mv ../bin/open_im_${i} ./${i}/
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "move success"
|
|
||||||
|
|
||||||
echo "start to build images"
|
|
||||||
|
|
||||||
for i in ${service[*]}
|
|
||||||
do
|
|
||||||
echo "start to build images" $i
|
|
||||||
cd $i
|
|
||||||
image="openim/${i}:$version"
|
|
||||||
docker build -t $image . -f ./${i}.Dockerfile
|
|
||||||
echo "build ${dockerfile} success"
|
|
||||||
docker push $image
|
|
||||||
echo "push ${image} success "
|
|
||||||
cd ..
|
|
||||||
done
|
|
||||||
|
|
||||||
18
deploy_k8s/cache/cache.Dockerfile
vendored
18
deploy_k8s/cache/cache.Dockerfile
vendored
@@ -1,18 +0,0 @@
|
|||||||
FROM ubuntu
|
|
||||||
|
|
||||||
# 设置固定的项目路径
|
|
||||||
ENV WORKDIR /Open-IM-Server
|
|
||||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
|
||||||
|
|
||||||
|
|
||||||
# 将可执行文件复制到目标目录
|
|
||||||
ADD ./open_im_cache $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
# 创建用于挂载的几个目录,添加可执行权限
|
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
|
||||||
chmod +x $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
|
||||||
|
|
||||||
WORKDIR $WORKDIR
|
|
||||||
CMD ./cmd/main
|
|
||||||
31
deploy_k8s/cache/deployment.yaml
vendored
31
deploy_k8s/cache/deployment.yaml
vendored
@@ -1,31 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: cache-deployment
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: cache # 选择这个指定标签执行
|
|
||||||
replicas: 2 # 运行pod数量
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: cache # 标签
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: cache
|
|
||||||
image: openim/cache:v2.0.10k
|
|
||||||
# imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 10240
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: config
|
|
||||||
strategy: #更新策略
|
|
||||||
type: RollingUpdate # 滚动更新
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
FROM ubuntu
|
|
||||||
|
|
||||||
# 设置固定的项目路径
|
|
||||||
ENV WORKDIR /Open-IM-Server
|
|
||||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
|
||||||
|
|
||||||
# 将可执行文件复制到目标目录
|
|
||||||
ADD ./open_im_cms_api $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
# 创建用于挂载的几个目录,添加可执行权限
|
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
|
||||||
chmod +x $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
|
||||||
|
|
||||||
WORKDIR $WORKDIR
|
|
||||||
CMD ./cmd/main
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: cms-api-deployment
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: cms-api # 选择这个指定标签执行
|
|
||||||
replicas: 2 # 运行pod数量
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: cms-api # 标签
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: cms-api
|
|
||||||
image: openim/cms_api:v2.0.10k
|
|
||||||
# imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 10006
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: config
|
|
||||||
strategy: #更新策略
|
|
||||||
type: RollingUpdate # 滚动更新
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: cms-api
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- name: cms-api-port
|
|
||||||
protocol: TCP
|
|
||||||
port: 10006
|
|
||||||
targetPort: 10006
|
|
||||||
selector:
|
|
||||||
app: cms-api
|
|
||||||
type: NodePort
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
FROM ubuntu
|
|
||||||
|
|
||||||
# 设置固定的项目路径
|
|
||||||
ENV WORKDIR /Open-IM-Server
|
|
||||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
|
||||||
|
|
||||||
# 将可执行文件复制到目标目录
|
|
||||||
ADD ./open_im_conversation $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
# 创建用于挂载的几个目录,添加可执行权限
|
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
|
||||||
chmod +x $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
|
||||||
|
|
||||||
WORKDIR $WORKDIR
|
|
||||||
CMD ./cmd/main
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: conversation-deployment
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: conversation # 选择这个指定标签执行
|
|
||||||
replicas: 2 # 运行pod数量
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: conversation # 标签
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: conversation
|
|
||||||
image: openim/conversation:v2.0.10k
|
|
||||||
# imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 10230
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: config
|
|
||||||
strategy: #更新策略
|
|
||||||
type: RollingUpdate # 滚动更新
|
|
||||||
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
FROM ubuntu
|
|
||||||
|
|
||||||
# 设置固定的项目路径
|
|
||||||
ENV WORKDIR /Open-IM-Server
|
|
||||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
|
||||||
|
|
||||||
# 将可执行文件复制到目标目录
|
|
||||||
ADD ./open_im_demo $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
# 创建用于挂载的几个目录,添加可执行权限
|
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
|
||||||
chmod +x $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
|
||||||
|
|
||||||
|
|
||||||
WORKDIR $WORKDIR
|
|
||||||
CMD ./cmd/main
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: demo-deployment
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: demo # 选择这个指定标签执行
|
|
||||||
replicas: 2 # 运行pod数量
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: demo # 标签
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: demo
|
|
||||||
image: openim/demo:v2.0.10k
|
|
||||||
imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 10004
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: config
|
|
||||||
strategy: #更新策略
|
|
||||||
type: RollingUpdate # 滚动更新
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: demo
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- name: demo
|
|
||||||
protocol: TCP
|
|
||||||
port: 10004
|
|
||||||
targetPort: 10004
|
|
||||||
selector:
|
|
||||||
app: demo
|
|
||||||
type: NodePort
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: friend-deployment
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: friend # 选择这个指定标签执行
|
|
||||||
replicas: 2 # 运行pod数量
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: friend # 标签
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: friend
|
|
||||||
image: openim/friend:v2.0.10k
|
|
||||||
# imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 10120
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: config
|
|
||||||
strategy: #更新策略
|
|
||||||
type: RollingUpdate # 滚动更新
|
|
||||||
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
FROM ubuntu
|
|
||||||
|
|
||||||
# 设置固定的项目路径
|
|
||||||
ENV WORKDIR /Open-IM-Server
|
|
||||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
|
||||||
|
|
||||||
|
|
||||||
# 将可执行文件复制到目标目录
|
|
||||||
ADD ./open_im_friend $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
# 创建用于挂载的几个目录,添加可执行权限
|
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
|
||||||
chmod +x $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
|
||||||
|
|
||||||
WORKDIR $WORKDIR
|
|
||||||
CMD ./cmd/main
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: group-deployment
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: group # 选择这个指定标签执行
|
|
||||||
replicas: 2 # 运行pod数量
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: group # 标签
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: group
|
|
||||||
image: openim/group:v2.0.10k
|
|
||||||
# imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 10150
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: config
|
|
||||||
strategy: #更新策略
|
|
||||||
type: RollingUpdate # 滚动更新
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
FROM ubuntu
|
|
||||||
|
|
||||||
# 设置固定的项目路径
|
|
||||||
ENV WORKDIR /Open-IM-Server
|
|
||||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
|
||||||
|
|
||||||
# 将可执行文件复制到目标目录
|
|
||||||
ADD ./open_im_group $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
# 创建用于挂载的几个目录,添加可执行权限
|
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
|
||||||
chmod +x $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
|
||||||
|
|
||||||
|
|
||||||
WORKDIR $WORKDIR
|
|
||||||
CMD ./cmd/main
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: networking.k8s.io/v1
|
|
||||||
kind: Ingress
|
|
||||||
metadata:
|
|
||||||
annotations:
|
|
||||||
kubernetes.io/ingress.class: "nginx"
|
|
||||||
nginx.ingress.kubernetes.io/proxy-http-version: "1.1"
|
|
||||||
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
|
|
||||||
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
|
|
||||||
name: sdk-server-ingress
|
|
||||||
spec:
|
|
||||||
rules:
|
|
||||||
- host: sdk-server.openim.xxx.com
|
|
||||||
http:
|
|
||||||
paths:
|
|
||||||
- backend:
|
|
||||||
service:
|
|
||||||
name: sdk-server
|
|
||||||
port:
|
|
||||||
number: 10003
|
|
||||||
path: /
|
|
||||||
pathType: Prefix
|
|
||||||
---
|
|
||||||
apiVersion: networking.k8s.io/v1
|
|
||||||
kind: Ingress
|
|
||||||
metadata:
|
|
||||||
annotations:
|
|
||||||
kubernetes.io/ingress.class: "nginx"
|
|
||||||
nginx.ingress.kubernetes.io/proxy-http-version: "1.1"
|
|
||||||
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
|
|
||||||
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
|
|
||||||
name: msg-gateway-ingress
|
|
||||||
spec:
|
|
||||||
rules:
|
|
||||||
- host: msg-gateway.openim.xxx.com
|
|
||||||
http:
|
|
||||||
paths:
|
|
||||||
- backend:
|
|
||||||
service:
|
|
||||||
name: msg-gateway
|
|
||||||
port:
|
|
||||||
number: 10001
|
|
||||||
path: /
|
|
||||||
pathType: Prefix
|
|
||||||
---
|
|
||||||
apiVersion: networking.k8s.io/v1
|
|
||||||
kind: Ingress
|
|
||||||
metadata:
|
|
||||||
annotations:
|
|
||||||
kubernetes.io/ingress.class: "nginx"
|
|
||||||
name: api-ingress
|
|
||||||
spec:
|
|
||||||
rules:
|
|
||||||
- host: api.openim.xxx.com
|
|
||||||
http:
|
|
||||||
paths:
|
|
||||||
- backend:
|
|
||||||
service:
|
|
||||||
name: api
|
|
||||||
port:
|
|
||||||
number: 10002
|
|
||||||
path: /
|
|
||||||
pathType: Prefix
|
|
||||||
---
|
|
||||||
apiVersion: networking.k8s.io/v1
|
|
||||||
kind: Ingress
|
|
||||||
metadata:
|
|
||||||
annotations:
|
|
||||||
kubernetes.io/ingress.class: "nginx"
|
|
||||||
name: demo-ingress
|
|
||||||
spec:
|
|
||||||
rules:
|
|
||||||
- host: demo.openim.xxx.com
|
|
||||||
http:
|
|
||||||
paths:
|
|
||||||
- backend:
|
|
||||||
service:
|
|
||||||
name: demo
|
|
||||||
port:
|
|
||||||
number: 10004
|
|
||||||
path: /
|
|
||||||
pathType: Prefix
|
|
||||||
---
|
|
||||||
apiVersion: networking.k8s.io/v1
|
|
||||||
kind: Ingress
|
|
||||||
metadata:
|
|
||||||
annotations:
|
|
||||||
kubernetes.io/ingress.class: "nginx"
|
|
||||||
name: cms-api-ingress
|
|
||||||
spec:
|
|
||||||
rules:
|
|
||||||
- host: cms-api.openim.xxx.com
|
|
||||||
http:
|
|
||||||
paths:
|
|
||||||
- backend:
|
|
||||||
service:
|
|
||||||
name: cms-api
|
|
||||||
port:
|
|
||||||
number: 10006
|
|
||||||
path: /
|
|
||||||
pathType: Prefix
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
#### openIM k8s部署文档
|
|
||||||
### 1. 修改配置文件
|
|
||||||
在Open-IM-SERVER目录下修改config/config.yaml配置文件, 将MySQL, Kafka, MongoDB等配置修改。
|
|
||||||
使用demo需要修改demo/imAPIURL地址 让demo能请求到im的api
|
|
||||||
|
|
||||||
### 2. 项目根目录创建im configMap到k8s openim namespace
|
|
||||||
kubectl create namespace openim
|
|
||||||
kubectl -n openim create configmap config --from-file=config/config.yaml
|
|
||||||
openim 为im项目的namespace, 可选
|
|
||||||
查看configmap
|
|
||||||
kubectl -n openim get configmap
|
|
||||||
|
|
||||||
### 3(可选). 修改每个deployment.yml
|
|
||||||
kubectl get nodes
|
|
||||||
kubectl label node k8s-node1 role=kube-Node
|
|
||||||
应需要调度的node打上标签
|
|
||||||
nodeSelector:
|
|
||||||
node: kube-Node
|
|
||||||
创建资源清单时添加上nodeSelector属性对应即可
|
|
||||||
修改每种服务数量,建议至少每种2个rpc。
|
|
||||||
如果修改了config/config.yaml某些配置比如端口,同时需要修改对应deployment端口和ingress端口
|
|
||||||
|
|
||||||
|
|
||||||
### 4. 修改ingress.yaml配置文件
|
|
||||||
需要安装ingress controller 这里使用的是ingress-nginx 其他ingress需要修改配置文件
|
|
||||||
进行域名修改等操作
|
|
||||||
|
|
||||||
### 5. 执行./kubectl_start.sh脚本
|
|
||||||
chmod +x ./kubectl_start.sh ./kubectl_stop.sh
|
|
||||||
./kubectl_start.sh
|
|
||||||
kubectl -n openim apply -f ingress.yaml
|
|
||||||
kubectl 启动所有deployment,services,ingress
|
|
||||||
|
|
||||||
### 6. 查看k8s deployment service ingress状态
|
|
||||||
kubectl -n openim get services
|
|
||||||
kubectl -n openim get deployment
|
|
||||||
kubectl -n openim get ingress
|
|
||||||
kubectl -n openim get pods
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
source ./path_info.cfg
|
|
||||||
|
|
||||||
#mkdir -p /db/sdk #path for jssdk sqlite
|
|
||||||
|
|
||||||
for i in ${service[*]}
|
|
||||||
do
|
|
||||||
kubectl -n openim apply -f ./${i}/deployment.yaml
|
|
||||||
done
|
|
||||||
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
service=(
|
|
||||||
#api service file
|
|
||||||
api
|
|
||||||
cms-api
|
|
||||||
#rpc service file
|
|
||||||
user
|
|
||||||
friend
|
|
||||||
group
|
|
||||||
auth
|
|
||||||
admin-cms
|
|
||||||
message-cms
|
|
||||||
statistics
|
|
||||||
office
|
|
||||||
organization
|
|
||||||
conversation
|
|
||||||
cache
|
|
||||||
msg-gateway
|
|
||||||
msg-transfer
|
|
||||||
msg
|
|
||||||
push
|
|
||||||
sdk-server
|
|
||||||
demo
|
|
||||||
)
|
|
||||||
|
|
||||||
for i in ${service[*]}
|
|
||||||
do
|
|
||||||
kubectl -n openim delete deployment "${i}-deployment"
|
|
||||||
done
|
|
||||||
|
|
||||||
kubectl -n openim delete service api
|
|
||||||
kubectl -n openim delete service cms-api
|
|
||||||
kubectl -n openim delete service sdk-server
|
|
||||||
kubectl -n openim delete service msg-gateway
|
|
||||||
kubectl -n openim delete service demo
|
|
||||||
|
|
||||||
echo done
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: message-cms-deployment
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: message-cms # 选择这个指定标签执行
|
|
||||||
replicas: 2 # 运行pod数量
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: message-cms # 标签
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: message-cms
|
|
||||||
image: openim/message_cms:v2.0.10k
|
|
||||||
# imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 10190
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: config
|
|
||||||
strategy: #更新策略
|
|
||||||
type: RollingUpdate # 滚动更新
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
FROM ubuntu
|
|
||||||
|
|
||||||
# 设置固定的项目路径
|
|
||||||
ENV WORKDIR /Open-IM-Server
|
|
||||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
|
||||||
|
|
||||||
# 将可执行文件复制到目标目录
|
|
||||||
ADD ./open_im_message_cms $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
# 创建用于挂载的几个目录,添加可执行权限
|
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
|
||||||
chmod +x $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
|
||||||
|
|
||||||
|
|
||||||
WORKDIR $WORKDIR
|
|
||||||
CMD ./cmd/main
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: msg-deployment
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: msg # 选择这个指定标签执行
|
|
||||||
replicas: 2 # 运行pod数量
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: msg # 标签
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: msg
|
|
||||||
image: openim/msg:v2.0.10k
|
|
||||||
# imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 10130
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: config
|
|
||||||
strategy: #更新策略
|
|
||||||
type: RollingUpdate # 滚动更新
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
FROM ubuntu
|
|
||||||
|
|
||||||
# 设置固定的项目路径
|
|
||||||
ENV WORKDIR /Open-IM-Server
|
|
||||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
|
||||||
|
|
||||||
|
|
||||||
# 将可执行文件复制到目标目录
|
|
||||||
ADD ./open_im_msg $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
# 创建用于挂载的几个目录,添加可执行权限
|
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
|
||||||
chmod +x $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
|
||||||
|
|
||||||
|
|
||||||
WORKDIR $WORKDIR
|
|
||||||
CMD ./cmd/main
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: msg-gateway-deployment
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: msg-gateway # 选择这个指定标签执行
|
|
||||||
replicas: 2 # 运行pod数量
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: msg-gateway # 标签
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: msg-gateway
|
|
||||||
image: openim/msg_gateway:v2.0.10k
|
|
||||||
# imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- name: rpc-port
|
|
||||||
containerPort: 10140
|
|
||||||
- name: ws-port
|
|
||||||
containerPort: 10001
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: config
|
|
||||||
strategy: #更新策略
|
|
||||||
type: RollingUpdate # 滚动更新
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: msg-gateway
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- name: msg-gateway-port
|
|
||||||
protocol: TCP
|
|
||||||
port: 10001
|
|
||||||
targetPort: ws-port
|
|
||||||
selector:
|
|
||||||
app: msg-gateway
|
|
||||||
type: NodePort
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
FROM ubuntu
|
|
||||||
|
|
||||||
# 设置固定的项目路径
|
|
||||||
ENV WORKDIR /Open-IM-Server
|
|
||||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
|
||||||
|
|
||||||
# 将可执行文件复制到目标目录
|
|
||||||
ADD ./open_im_msg_gateway $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
# 创建用于挂载的几个目录,添加可执行权限
|
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
|
||||||
chmod +x $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
|
||||||
|
|
||||||
|
|
||||||
WORKDIR $WORKDIR
|
|
||||||
CMD ./cmd/main
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: msg-transfer-deployment
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: msg-transfer # 选择这个指定标签执行
|
|
||||||
replicas: 2 # 运行pod数量
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: msg-transfer # 标签
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: msg-transfer
|
|
||||||
image: openim/msg_transfer:v2.0.10k
|
|
||||||
# imagePullPolicy: Always
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: config
|
|
||||||
strategy: #更新策略
|
|
||||||
type: RollingUpdate # 滚动更新
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
FROM ubuntu
|
|
||||||
|
|
||||||
# 设置固定的项目路径
|
|
||||||
ENV WORKDIR /Open-IM-Server
|
|
||||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
|
||||||
|
|
||||||
# 将可执行文件复制到目标目录
|
|
||||||
ADD ./open_im_msg_transfer $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
# 创建用于挂载的几个目录,添加可执行权限
|
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
|
||||||
chmod +x $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
|
||||||
|
|
||||||
|
|
||||||
WORKDIR $WORKDIR
|
|
||||||
CMD ./cmd/main
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: office-deployment
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: office # 选择这个指定标签执行
|
|
||||||
replicas: 2 # 运行pod数量
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: office # 标签
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: office
|
|
||||||
image: openim/office:v2.0.10k
|
|
||||||
# imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 10210
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: config
|
|
||||||
strategy: #更新策略
|
|
||||||
type: RollingUpdate # 滚动更新
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
FROM ubuntu
|
|
||||||
|
|
||||||
# 设置固定的项目路径
|
|
||||||
ENV WORKDIR /Open-IM-Server
|
|
||||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
|
||||||
|
|
||||||
# 将可执行文件复制到目标目录
|
|
||||||
ADD ./open_im_office $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
# 创建用于挂载的几个目录,添加可执行权限
|
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
|
||||||
chmod +x $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
|
||||||
|
|
||||||
|
|
||||||
WORKDIR $WORKDIR
|
|
||||||
CMD ./cmd/main
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: organization-deployment
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: organization # 选择这个指定标签执行
|
|
||||||
replicas: 2 # 运行pod数量
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: organization # 标签
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: organization
|
|
||||||
image: openim/organization:v2.0.10k
|
|
||||||
# imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 10220
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: config
|
|
||||||
strategy: #更新策略
|
|
||||||
type: RollingUpdate # 滚动更新
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
FROM ubuntu
|
|
||||||
|
|
||||||
# 设置固定的项目路径
|
|
||||||
ENV WORKDIR /Open-IM-Server
|
|
||||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
|
||||||
|
|
||||||
# 将可执行文件复制到目标目录
|
|
||||||
ADD ./open_im_organization $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
|
|
||||||
# 创建用于挂载的几个目录,添加可执行权限
|
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
|
||||||
chmod +x $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
|
||||||
|
|
||||||
|
|
||||||
WORKDIR $WORKDIR
|
|
||||||
CMD ./cmd/main
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#/bin/sh
|
|
||||||
service=(
|
|
||||||
#api service file
|
|
||||||
api
|
|
||||||
cms_api
|
|
||||||
#rpc service file
|
|
||||||
user
|
|
||||||
friend
|
|
||||||
group
|
|
||||||
auth
|
|
||||||
admin_cms
|
|
||||||
message_cms
|
|
||||||
statistics
|
|
||||||
office
|
|
||||||
organization
|
|
||||||
conversation
|
|
||||||
cache
|
|
||||||
msg_gateway
|
|
||||||
msg_transfer
|
|
||||||
msg
|
|
||||||
push
|
|
||||||
sdk_server
|
|
||||||
demo
|
|
||||||
)
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: push-deployment
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: push # 选择这个指定标签执行
|
|
||||||
replicas: 2 # 运行pod数量
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: push # 标签
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: push
|
|
||||||
image: openim/push:v2.0.10k
|
|
||||||
# imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 10170
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: config
|
|
||||||
strategy: #更新策略
|
|
||||||
type: RollingUpdate # 滚动更新
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
FROM ubuntu
|
|
||||||
|
|
||||||
# 设置固定的项目路径
|
|
||||||
ENV WORKDIR /Open-IM-Server
|
|
||||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
|
||||||
|
|
||||||
|
|
||||||
# 将可执行文件复制到目标目录
|
|
||||||
ADD ./open_im_push $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
# 创建用于挂载的几个目录,添加可执行权限
|
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
|
||||||
chmod +x $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
|
||||||
|
|
||||||
|
|
||||||
WORKDIR $WORKDIR
|
|
||||||
CMD ./cmd/main
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: sdk-server-deployment
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: sdk-server # 选择这个指定标签执行
|
|
||||||
replicas: 2 # 运行pod数量
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: sdk-server # 标签
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: sdk-server
|
|
||||||
image: openim/sdk_server:v2.0.10k
|
|
||||||
# imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 10003
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
- name: local-db
|
|
||||||
mountPath: /db/sdk
|
|
||||||
command: ["/Open-IM-Server/main"]
|
|
||||||
args: ["-openIM_api_port", "10002", "-openIM_ws_port", "10001", "-sdk_ws_port", "10003", "-openIM_log_level", "6"]
|
|
||||||
volumes:
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: config
|
|
||||||
- name: local-db
|
|
||||||
hostPath:
|
|
||||||
path: /db/sdk
|
|
||||||
strategy: #更新策略
|
|
||||||
type: RollingUpdate # 滚动更新
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: sdk-server
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- name: sdk-server-port
|
|
||||||
protocol: TCP
|
|
||||||
port: 10003
|
|
||||||
targetPort: 10003
|
|
||||||
selector:
|
|
||||||
app: sdk-server
|
|
||||||
type: NodePort
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
FROM ubuntu
|
|
||||||
|
|
||||||
# 设置固定的项目路径
|
|
||||||
ENV WORKDIR /Open-IM-Server
|
|
||||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
|
||||||
|
|
||||||
# 将可执行文件复制到目标目录
|
|
||||||
ADD ./open_im_sdk_server $WORKDIR/main
|
|
||||||
|
|
||||||
# 创建用于挂载的几个目录,添加可执行权限
|
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
|
|
||||||
chmod +x $WORKDIR/main
|
|
||||||
|
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script","/Open-IM-Server/db/sdk"]
|
|
||||||
|
|
||||||
WORKDIR $WORKDIR
|
|
||||||
CMD ./main
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: statistics-deployment
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: statistics # 选择这个指定标签执行
|
|
||||||
replicas: 2 # 运行pod数量
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: statistics # 标签
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: statistics
|
|
||||||
image: openim/statistics:v2.0.10k
|
|
||||||
# imagePullPolicy: Always
|
|
||||||
ports:
|
|
||||||
- containerPort: 10180
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: config
|
|
||||||
strategy: #更新策略
|
|
||||||
type: RollingUpdate # 滚动更新
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
FROM ubuntu
|
|
||||||
|
|
||||||
# 设置固定的项目路径
|
|
||||||
ENV WORKDIR /Open-IM-Server
|
|
||||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
|
||||||
|
|
||||||
# 将可执行文件复制到目标目录
|
|
||||||
ADD ./open_im_statistics $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
# 创建用于挂载的几个目录,添加可执行权限
|
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
|
||||||
chmod +x $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
|
||||||
|
|
||||||
|
|
||||||
WORKDIR $WORKDIR
|
|
||||||
CMD ./cmd/main
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: user-deployment
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: user # 选择这个指定标签执行
|
|
||||||
replicas: 2 # 运行pod数量
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: user # 标签
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: user
|
|
||||||
image: openim/user:v2.0.10k
|
|
||||||
# imagePullPolicy: Always
|
|
||||||
volumeMounts:
|
|
||||||
- name: config
|
|
||||||
mountPath: /Open-IM-Server/config
|
|
||||||
readOnly: true
|
|
||||||
volumes:
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: config
|
|
||||||
strategy: #更新策略
|
|
||||||
type: RollingUpdate # 滚动更新
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
FROM ubuntu
|
|
||||||
|
|
||||||
# 设置固定的项目路径
|
|
||||||
ENV WORKDIR /Open-IM-Server
|
|
||||||
ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
|
||||||
|
|
||||||
# 将可执行文件复制到目标目录
|
|
||||||
ADD ./open_im_user $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
# 创建用于挂载的几个目录,添加可执行权限
|
|
||||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/script && \
|
|
||||||
chmod +x $WORKDIR/cmd/main
|
|
||||||
|
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/script"]
|
|
||||||
|
|
||||||
|
|
||||||
WORKDIR $WORKDIR
|
|
||||||
CMD ./cmd/main
|
|
||||||
@@ -69,17 +69,12 @@ services:
|
|||||||
image: wurstmeister/kafka
|
image: wurstmeister/kafka
|
||||||
container_name: kafka
|
container_name: kafka
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
|
||||||
- 9093:9093
|
|
||||||
environment:
|
environment:
|
||||||
TZ: Asia/Shanghai
|
TZ: Asia/Shanghai
|
||||||
KAFKA_BROKER_ID: 0
|
KAFKA_BROKER_ID: 0
|
||||||
KAFKA_ZOOKEEPER_CONNECT: 127.0.0.1:2181
|
KAFKA_ZOOKEEPER_CONNECT: 127.0.0.1:2181
|
||||||
KAFKA_CREATE_TOPICS: "ws2ms_chat:8:1,ms2ps_chat:8:1,msg_to_mongo:8:1"
|
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9092
|
||||||
KAFKA_ADVERTISED_LISTENERS: INSIDE://127.0.0.1:9092,OUTSIDE://103.116.45.174:9093
|
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
|
||||||
KAFKA_LISTENERS: INSIDE://:9092,OUTSIDE://:9093
|
|
||||||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT"
|
|
||||||
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
|
|
||||||
network_mode: "host"
|
network_mode: "host"
|
||||||
depends_on:
|
depends_on:
|
||||||
- zookeeper
|
- zookeeper
|
||||||
@@ -99,7 +94,7 @@ services:
|
|||||||
command: /usr/local/bin/etcd --name etcd0 --data-dir /etcd-data --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 --listen-peer-urls http://0.0.0.0:2380 --initial-advertise-peer-urls http://0.0.0.0:2380 --initial-cluster etcd0=http://0.0.0.0:2380 --initial-cluster-token tkn --initial-cluster-state new
|
command: /usr/local/bin/etcd --name etcd0 --data-dir /etcd-data --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 --listen-peer-urls http://0.0.0.0:2380 --initial-advertise-peer-urls http://0.0.0.0:2380 --initial-cluster etcd0=http://0.0.0.0:2380 --initial-cluster-token tkn --initial-cluster-state new
|
||||||
|
|
||||||
open_im_server:
|
open_im_server:
|
||||||
image: openim/open_im_server:v2.1.0
|
image: openim/open_im_server:v2.0.8
|
||||||
container_name: open_im_server
|
container_name: open_im_server
|
||||||
volumes:
|
volumes:
|
||||||
- ./logs:/Open-IM-Server/logs
|
- ./logs:/Open-IM-Server/logs
|
||||||
|
|||||||
BIN
docs/Wechat.jpg
BIN
docs/Wechat.jpg
Binary file not shown.
|
Before Width: | Height: | Size: 144 KiB After Width: | Height: | Size: 208 KiB |
29
go.mod
29
go.mod
@@ -3,21 +3,29 @@ module Open_IM
|
|||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Shopify/sarama v1.32.0
|
github.com/Shopify/sarama v1.19.0
|
||||||
|
github.com/Shopify/toxiproxy v2.1.4+incompatible // indirect
|
||||||
github.com/alibabacloud-go/darabonba-openapi v0.1.11
|
github.com/alibabacloud-go/darabonba-openapi v0.1.11
|
||||||
github.com/alibabacloud-go/dysmsapi-20170525/v2 v2.0.8
|
github.com/alibabacloud-go/dysmsapi-20170525/v2 v2.0.8
|
||||||
github.com/alibabacloud-go/sts-20150401 v1.1.0
|
github.com/alibabacloud-go/sts-20150401 v1.1.0
|
||||||
github.com/alibabacloud-go/tea v1.1.17
|
github.com/alibabacloud-go/tea v1.1.17
|
||||||
github.com/antonfisher/nested-logrus-formatter v1.3.0
|
github.com/antonfisher/nested-logrus-formatter v1.3.0
|
||||||
github.com/bwmarrin/snowflake v0.3.0
|
github.com/bwmarrin/snowflake v0.3.0
|
||||||
|
github.com/coreos/etcd v3.3.27+incompatible // indirect
|
||||||
|
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
|
||||||
|
github.com/eapache/go-resiliency v1.2.0 // indirect
|
||||||
|
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
|
||||||
|
github.com/eapache/queue v1.1.0 // indirect
|
||||||
github.com/fatih/structs v1.1.0
|
github.com/fatih/structs v1.1.0
|
||||||
|
github.com/frankban/quicktest v1.14.0 // indirect
|
||||||
|
github.com/garyburd/redigo v1.6.2
|
||||||
github.com/gin-gonic/gin v1.7.0
|
github.com/gin-gonic/gin v1.7.0
|
||||||
github.com/go-playground/validator/v10 v10.4.1
|
github.com/go-playground/validator/v10 v10.4.1
|
||||||
github.com/go-redis/redis/v8 v8.11.5
|
|
||||||
github.com/go-sql-driver/mysql v1.6.0 // indirect
|
github.com/go-sql-driver/mysql v1.6.0 // indirect
|
||||||
github.com/gogo/protobuf v1.3.2
|
github.com/gogo/protobuf v1.3.2
|
||||||
github.com/golang-jwt/jwt/v4 v4.1.0
|
github.com/golang-jwt/jwt/v4 v4.1.0
|
||||||
github.com/golang/protobuf v1.5.2
|
github.com/golang/protobuf v1.5.2
|
||||||
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
github.com/gorilla/websocket v1.4.2
|
github.com/gorilla/websocket v1.4.2
|
||||||
github.com/jinzhu/copier v0.3.4
|
github.com/jinzhu/copier v0.3.4
|
||||||
github.com/jinzhu/gorm v1.9.16
|
github.com/jinzhu/gorm v1.9.16
|
||||||
@@ -26,29 +34,36 @@ require (
|
|||||||
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
|
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
|
||||||
github.com/lestrrat-go/strftime v1.0.4 // indirect
|
github.com/lestrrat-go/strftime v1.0.4 // indirect
|
||||||
github.com/lib/pq v1.2.0 // indirect
|
github.com/lib/pq v1.2.0 // indirect
|
||||||
|
//github.com/livekit/protocol v0.11.14-0.20220223195254-d8c251e13231 // indirect
|
||||||
|
//github.com/livekit/server-sdk-go v0.9.1
|
||||||
github.com/mattn/go-sqlite3 v1.14.6 // indirect
|
github.com/mattn/go-sqlite3 v1.14.6 // indirect
|
||||||
github.com/minio/minio-go/v7 v7.0.22
|
github.com/minio/minio-go/v7 v7.0.22
|
||||||
github.com/mitchellh/mapstructure v1.4.2
|
github.com/mitchellh/mapstructure v1.4.2
|
||||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||||
github.com/olivere/elastic/v7 v7.0.23
|
github.com/olivere/elastic/v7 v7.0.23
|
||||||
|
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
|
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||||
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
|
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
|
||||||
github.com/sirupsen/logrus v1.8.1
|
github.com/sirupsen/logrus v1.8.1
|
||||||
|
github.com/spf13/viper v1.9.0
|
||||||
github.com/stretchr/testify v1.7.0
|
github.com/stretchr/testify v1.7.0
|
||||||
github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca
|
github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca
|
||||||
go.etcd.io/etcd/api/v3 v3.5.4
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
|
||||||
go.etcd.io/etcd/client/v3 v3.5.4
|
//go.etcd.io/etcd v3.3.27+incompatible
|
||||||
|
go.etcd.io/etcd v0.0.0-20200402134248-51bdeb39e698
|
||||||
go.mongodb.org/mongo-driver v1.8.3
|
go.mongodb.org/mongo-driver v1.8.3
|
||||||
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
|
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
|
||||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
|
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
|
||||||
google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71 // indirect
|
google.golang.org/grpc v1.42.0
|
||||||
google.golang.org/grpc v1.45.0
|
google.golang.org/grpc/examples v0.0.0-20220311002955-722367c4a737 // indirect
|
||||||
google.golang.org/protobuf v1.27.1
|
google.golang.org/protobuf v1.27.1
|
||||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
||||||
gopkg.in/ini.v1 v1.66.2 // indirect
|
gopkg.in/ini.v1 v1.66.2 // indirect
|
||||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
|
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
||||||
|
sigs.k8s.io/yaml v1.2.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
replace github.com/Shopify/sarama => github.com/Shopify/sarama v1.29.0
|
replace google.golang.org/grpc => google.golang.org/grpc v1.29.0
|
||||||
|
|||||||
@@ -4,13 +4,11 @@ import (
|
|||||||
api "Open_IM/pkg/base_info"
|
api "Open_IM/pkg/base_info"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
rpc "Open_IM/pkg/proto/auth"
|
rpc "Open_IM/pkg/proto/auth"
|
||||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"github.com/fatih/structs"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -19,9 +17,8 @@ import (
|
|||||||
func UserRegister(c *gin.Context) {
|
func UserRegister(c *gin.Context) {
|
||||||
params := api.UserRegisterReq{}
|
params := api.UserRegisterReq{}
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
errMsg := " BindJSON failed " + err.Error()
|
log.NewError("0", "BindJSON failed ", err.Error())
|
||||||
log.NewError("0", errMsg)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,34 +33,26 @@ func UserRegister(c *gin.Context) {
|
|||||||
//copier.Copy(req.UserInfo, ¶ms)
|
//copier.Copy(req.UserInfo, ¶ms)
|
||||||
req.OperationID = params.OperationID
|
req.OperationID = params.OperationID
|
||||||
log.NewInfo(req.OperationID, "UserRegister args ", req.String())
|
log.NewInfo(req.OperationID, "UserRegister args ", req.String())
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewAuthClient(etcdConn)
|
client := rpc.NewAuthClient(etcdConn)
|
||||||
reply, err := client.UserRegister(context.Background(), req)
|
reply, err := client.UserRegister(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := req.OperationID + " " + "UserRegister failed " + err.Error() + req.String()
|
log.NewError(req.OperationID, "call rpc err ", err.Error())
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "internal service err"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if reply.CommonResp.ErrCode != 0 {
|
if reply.CommonResp.ErrCode != 0 {
|
||||||
errMsg := req.OperationID + " " + " UserRegister failed " + reply.CommonResp.ErrMsg + req.String()
|
log.NewError(req.OperationID, "UserRegister failed ", err)
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": reply.CommonResp.ErrMsg})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pbDataToken := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}
|
pbDataToken := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}
|
||||||
replyToken, err := client.UserToken(context.Background(), pbDataToken)
|
replyToken, err := client.UserToken(context.Background(), pbDataToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := req.OperationID + " " + " client.UserToken failed " + err.Error() + pbDataToken.String()
|
log.NewError(req.OperationID, "UserToken failed ", err.Error(), pbDataToken)
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp := api.UserRegisterResp{CommResp: api.CommResp{ErrCode: replyToken.CommonResp.ErrCode, ErrMsg: replyToken.CommonResp.ErrMsg},
|
resp := api.UserRegisterResp{CommResp: api.CommResp{ErrCode: replyToken.CommonResp.ErrCode, ErrMsg: replyToken.CommonResp.ErrMsg},
|
||||||
@@ -76,33 +65,24 @@ func UserRegister(c *gin.Context) {
|
|||||||
func UserToken(c *gin.Context) {
|
func UserToken(c *gin.Context) {
|
||||||
params := api.UserTokenReq{}
|
params := api.UserTokenReq{}
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
errMsg := " BindJSON failed " + err.Error()
|
log.NewError("0", "BindJSON failed ", err.Error())
|
||||||
log.NewError("0", errMsg)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if params.Secret != config.Config.Secret {
|
if params.Secret != config.Config.Secret {
|
||||||
errMsg := params.OperationID + " params.Secret != config.Config.Secret "
|
|
||||||
log.NewError(params.OperationID, "params.Secret != config.Config.Secret", params.Secret, config.Config.Secret)
|
log.NewError(params.OperationID, "params.Secret != config.Config.Secret", params.Secret, config.Config.Secret)
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": errMsg})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "not authorized"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}
|
req := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}
|
||||||
log.NewInfo(req.OperationID, "UserToken args ", req.String())
|
log.NewInfo(req.OperationID, "UserToken args ", req.String())
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewAuthClient(etcdConn)
|
client := rpc.NewAuthClient(etcdConn)
|
||||||
reply, err := client.UserToken(context.Background(), req)
|
reply, err := client.UserToken(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := req.OperationID + " UserToken failed " + err.Error() + req.String()
|
log.NewError(req.OperationID, "UserToken failed ", err.Error(), req.String())
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp := api.UserTokenResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg},
|
resp := api.UserTokenResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg},
|
||||||
@@ -110,72 +90,3 @@ func UserToken(c *gin.Context) {
|
|||||||
log.NewInfo(req.OperationID, "UserToken return ", resp)
|
log.NewInfo(req.OperationID, "UserToken return ", resp)
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseToken(c *gin.Context) {
|
|
||||||
params := api.ParseTokenReq{}
|
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
|
||||||
errMsg := " BindJSON failed " + err.Error()
|
|
||||||
log.NewError("0", errMsg)
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
var expireTime int64
|
|
||||||
ok, _, errInfo, expireTime = token_verify.GetUserIDFromTokenExpireTime(c.Request.Header.Get("token"), params.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := params.OperationID + " " + "GetUserIDFromTokenExpireTime failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(params.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
resp := api.ParseTokenResp{CommResp: api.CommResp{ErrCode: 0, ErrMsg: ""}, ExpireTime: api.ExpireTime{ExpireTimeSeconds: uint32(expireTime)}}
|
|
||||||
resp.Data = structs.Map(&resp.ExpireTime)
|
|
||||||
log.NewInfo(params.OperationID, "ParseToken return ", resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ForceLogout(c *gin.Context) {
|
|
||||||
params := api.ForceLogoutReq{}
|
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
|
||||||
errMsg := " BindJSON failed " + err.Error()
|
|
||||||
log.NewError("0", errMsg)
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
req := &rpc.ForceLogoutReq{}
|
|
||||||
utils.CopyStructFields(req, ¶ms)
|
|
||||||
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "ForceLogout args ", req.String())
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewAuthClient(etcdConn)
|
|
||||||
reply, err := client.ForceLogout(context.Background(), req)
|
|
||||||
if err != nil {
|
|
||||||
errMsg := req.OperationID + " UserToken failed " + err.Error() + req.String()
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp := api.ForceLogoutResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
|
|
||||||
log.NewInfo(params.OperationID, utils.GetSelfFuncName(), " return ", resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ import (
|
|||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
rpc "Open_IM/pkg/proto/chat"
|
pbChat "Open_IM/pkg/proto/chat"
|
||||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
@@ -26,18 +25,12 @@ func DelMsg(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
|
||||||
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
|
||||||
}
|
}
|
||||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName, req.OperationID)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||||
if grpcConn == nil {
|
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
msgClient := pbChat.NewChatClient(grpcConn)
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
msgClient := rpc.NewChatClient(grpcConn)
|
|
||||||
respPb, err := msgClient.DelMsgList(context.Background(), &reqPb)
|
respPb, err := msgClient.DelMsgList(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsgList failed", err.Error(), reqPb)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsgList failed", err.Error(), reqPb)
|
||||||
@@ -46,50 +39,5 @@ func DelMsg(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp.ErrCode = respPb.ErrCode
|
resp.ErrCode = respPb.ErrCode
|
||||||
resp.ErrMsg = respPb.ErrMsg
|
resp.ErrMsg = respPb.ErrMsg
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ClearMsg(c *gin.Context) {
|
|
||||||
params := api.CleanUpMsgReq{}
|
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
//
|
|
||||||
req := &rpc.ClearMsgReq{}
|
|
||||||
utils.CopyStructFields(req, ¶ms)
|
|
||||||
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + " getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewChatClient(etcdConn)
|
|
||||||
RpcResp, err := client.ClearMsg(context.Background(), req)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, " CleanUpMsg failed ", err.Error(), req.String(), RpcResp.ErrMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": RpcResp.ErrMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
resp := api.CleanUpMsgResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ import (
|
|||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbChat "Open_IM/pkg/proto/chat"
|
pbMsg "Open_IM/pkg/proto/chat"
|
||||||
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -32,18 +31,15 @@ func GetSeq(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err" + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err" + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pbData := sdk_ws.GetMaxAndMinSeqReq{}
|
pbData := pbMsg.GetMaxAndMinSeqReq{}
|
||||||
pbData.UserID = params.SendID
|
pbData.UserID = params.SendID
|
||||||
pbData.OperationID = params.OperationID
|
pbData.OperationID = params.OperationID
|
||||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName, pbData.OperationID)
|
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||||
if grpcConn == nil {
|
|
||||||
errMsg := pbData.OperationID + " getcdv3.GetConn == nil"
|
|
||||||
log.NewError(pbData.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
msgClient := pbChat.NewChatClient(grpcConn)
|
if grpcConn == nil {
|
||||||
|
log.ErrorByKv("get grpcConn err", pbData.OperationID, "args", params)
|
||||||
|
}
|
||||||
|
msgClient := pbMsg.NewChatClient(grpcConn)
|
||||||
reply, err := msgClient.GetMaxAndMinSeq(context.Background(), &pbData)
|
reply, err := msgClient.GetMaxAndMinSeq(context.Background(), &pbData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(params.OperationID, "UserGetSeq rpc failed, ", params, err.Error())
|
log.NewError(params.OperationID, "UserGetSeq rpc failed, ", params, err.Error())
|
||||||
|
|||||||
@@ -51,20 +51,14 @@ func PullMsgBySeqList(c *gin.Context) {
|
|||||||
pbData.OperationID = params.OperationID
|
pbData.OperationID = params.OperationID
|
||||||
pbData.SeqList = params.SeqList
|
pbData.SeqList = params.SeqList
|
||||||
|
|
||||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName, pbData.OperationID)
|
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||||
if grpcConn == nil {
|
|
||||||
errMsg := pbData.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(pbData.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
msgClient := pbChat.NewChatClient(grpcConn)
|
msgClient := pbChat.NewChatClient(grpcConn)
|
||||||
reply, err := msgClient.PullMessageBySeqList(context.Background(), &pbData)
|
reply, err := msgClient.PullMessageBySeqList(context.Background(), &pbData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(pbData.OperationID, "PullMessageBySeqList error", err.Error())
|
log.ErrorByKv("PullMessageBySeqList error", pbData.OperationID, "err", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(pbData.OperationID, "rpc call success to PullMessageBySeqList", reply.String(), len(reply.List))
|
log.InfoByKv("rpc call success to PullMessageBySeqList", pbData.OperationID, "ReplyArgs", reply.String(), len(reply.List))
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"errCode": reply.ErrCode,
|
"errCode": reply.ErrCode,
|
||||||
"errMsg": reply.ErrMsg,
|
"errMsg": reply.ErrMsg,
|
||||||
|
|||||||
@@ -62,22 +62,18 @@ func SendMsg(c *gin.Context) {
|
|||||||
params := paramsUserSendMsg{}
|
params := paramsUserSendMsg{}
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
log.Error("0", "BindJSON failed ", err.Error())
|
log.ErrorByKv("json unmarshal err", "", "err", err.Error(), "data", c.PostForm("data"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
token := c.Request.Header.Get("token")
|
token := c.Request.Header.Get("token")
|
||||||
log.NewInfo(params.OperationID, "api call success to sendMsgReq", params)
|
|
||||||
pbData := newUserSendMsgReq(token, ¶ms)
|
|
||||||
log.Info(params.OperationID, "", "api SendMsg call start..., [data: %s]", pbData.String())
|
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName, params.OperationID)
|
log.InfoByKv("api call success to sendMsgReq", params.OperationID, "Parameters", params)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := params.OperationID + "getcdv3.GetConn == nil"
|
pbData := newUserSendMsgReq(token, ¶ms)
|
||||||
log.NewError(params.OperationID, errMsg)
|
log.Info("", "", "api SendMsg call start..., [data: %s]", pbData.String())
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||||
}
|
|
||||||
client := pbChat.NewChatClient(etcdConn)
|
client := pbChat.NewChatClient(etcdConn)
|
||||||
|
|
||||||
log.Info("", "", "api SendMsg call, api call rpc...")
|
log.Info("", "", "api SendMsg call, api call rpc...")
|
||||||
@@ -88,7 +84,7 @@ func SendMsg(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "SendMsg rpc failed, " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "SendMsg rpc failed, " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Info(params.OperationID, "", "api SendMsg call end..., [data: %s] [reply: %s]", pbData.String(), reply.String())
|
log.Info("", "", "api SendMsg call end..., [data: %s] [reply: %s]", pbData.String(), reply.String())
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"errCode": reply.ErrCode,
|
"errCode": reply.ErrCode,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbConversation "Open_IM/pkg/proto/conversation"
|
|
||||||
pbUser "Open_IM/pkg/proto/user"
|
pbUser "Open_IM/pkg/proto/user"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
@@ -25,20 +24,14 @@ func SetConversation(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.Conversation = &pbUser.Conversation{}
|
reqPb.Conversation = &pbUser.Conversation{}
|
||||||
err := utils.CopyStructFields(&reqPb, req)
|
err := utils.CopyStructFields(&reqPb, req)
|
||||||
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
|
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||||
if etcdConn == nil {
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbUser.NewUserClient(etcdConn)
|
client := pbUser.NewUserClient(etcdConn)
|
||||||
respPb, err := client.SetConversation(context.Background(), &reqPb)
|
respPb, err := client.SetConversation(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -51,43 +44,6 @@ func SetConversation(c *gin.Context) {
|
|||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
func ModifyConversationField(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.ModifyConversationFieldReq
|
|
||||||
resp api.ModifyConversationFieldResp
|
|
||||||
reqPb pbConversation.ModifyConversationFieldReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.Conversation = &pbConversation.Conversation{}
|
|
||||||
err := utils.CopyStructFields(&reqPb, req)
|
|
||||||
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
|
|
||||||
if err != nil {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
|
||||||
}
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbConversation.NewConversationClient(etcdConn)
|
|
||||||
respPb, err := client.ModifyConversationField(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
|
||||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func BatchSetConversations(c *gin.Context) {
|
func BatchSetConversations(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
@@ -100,17 +56,11 @@ func BatchSetConversations(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||||
if etcdConn == nil {
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbUser.NewUserClient(etcdConn)
|
client := pbUser.NewUserClient(etcdConn)
|
||||||
respPb, err := client.BatchSetConversations(context.Background(), &reqPb)
|
respPb, err := client.BatchSetConversations(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -138,17 +88,11 @@ func GetAllConversations(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||||
if etcdConn == nil {
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbUser.NewUserClient(etcdConn)
|
client := pbUser.NewUserClient(etcdConn)
|
||||||
respPb, err := client.GetAllConversations(context.Background(), &reqPb)
|
respPb, err := client.GetAllConversations(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -176,17 +120,11 @@ func GetConversation(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||||
if etcdConn == nil {
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbUser.NewUserClient(etcdConn)
|
client := pbUser.NewUserClient(etcdConn)
|
||||||
respPb, err := client.GetConversation(context.Background(), &reqPb)
|
respPb, err := client.GetConversation(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -214,17 +152,11 @@ func GetConversations(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||||
if etcdConn == nil {
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbUser.NewUserClient(etcdConn)
|
client := pbUser.NewUserClient(etcdConn)
|
||||||
respPb, err := client.GetConversations(context.Background(), &reqPb)
|
respPb, err := client.GetConversations(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -252,17 +184,11 @@ func SetRecvMsgOpt(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||||
if etcdConn == nil {
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbUser.NewUserClient(etcdConn)
|
client := pbUser.NewUserClient(etcdConn)
|
||||||
respPb, err := client.SetRecvMsgOpt(context.Background(), &reqPb)
|
respPb, err := client.SetRecvMsgOpt(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -26,17 +26,15 @@ func AddBlack(c *gin.Context) {
|
|||||||
req := &rpc.AddBlacklistReq{CommID: &rpc.CommID{}}
|
req := &rpc.AddBlacklistReq{CommID: &rpc.CommID{}}
|
||||||
utils.CopyStructFields(req.CommID, ¶ms)
|
utils.CopyStructFields(req.CommID, ¶ms)
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(params.OperationID, "AddBlacklist args ", req.String())
|
log.NewInfo(params.OperationID, "AddBlacklist args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||||
client := rpc.NewFriendClient(etcdConn)
|
client := rpc.NewFriendClient(etcdConn)
|
||||||
RpcResp, err := client.AddBlacklist(context.Background(), req)
|
RpcResp, err := client.AddBlacklist(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -59,24 +57,15 @@ func ImportFriend(c *gin.Context) {
|
|||||||
req := &rpc.ImportFriendReq{}
|
req := &rpc.ImportFriendReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "ImportFriend args ", req.String())
|
log.NewInfo(req.OperationID, "ImportFriend args ", req.String())
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||||
client := rpc.NewFriendClient(etcdConn)
|
client := rpc.NewFriendClient(etcdConn)
|
||||||
RpcResp, err := client.ImportFriend(context.Background(), req)
|
RpcResp, err := client.ImportFriend(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -107,26 +96,16 @@ func AddFriend(c *gin.Context) {
|
|||||||
req := &rpc.AddFriendReq{CommID: &rpc.CommID{}}
|
req := &rpc.AddFriendReq{CommID: &rpc.CommID{}}
|
||||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||||
req.ReqMsg = params.ReqMsg
|
req.ReqMsg = params.ReqMsg
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.CommID.OperationID, "AddFriend args ", req.String())
|
log.NewInfo(req.CommID.OperationID, "AddFriend args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewFriendClient(etcdConn)
|
client := rpc.NewFriendClient(etcdConn)
|
||||||
RpcResp, err := client.AddFriend(context.Background(), req)
|
RpcResp, err := client.AddFriend(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -151,28 +130,17 @@ func AddFriendResponse(c *gin.Context) {
|
|||||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||||
req.HandleMsg = params.HandleMsg
|
req.HandleMsg = params.HandleMsg
|
||||||
req.HandleResult = params.Flag
|
req.HandleResult = params.Flag
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
log.NewInfo(req.CommID.OperationID, "AddFriendResponse args ", req.String())
|
log.NewInfo(req.CommID.OperationID, "AddFriendResponse args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
client := rpc.NewFriendClient(etcdConn)
|
client := rpc.NewFriendClient(etcdConn)
|
||||||
RpcResp, err := client.AddFriendResponse(context.Background(), req)
|
RpcResp, err := client.AddFriendResponse(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -195,26 +163,16 @@ func DeleteFriend(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.DeleteFriendReq{CommID: &rpc.CommID{}}
|
req := &rpc.DeleteFriendReq{CommID: &rpc.CommID{}}
|
||||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.CommID.OperationID, "DeleteFriend args ", req.String())
|
log.NewInfo(req.CommID.OperationID, "DeleteFriend args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewFriendClient(etcdConn)
|
client := rpc.NewFriendClient(etcdConn)
|
||||||
RpcResp, err := client.DeleteFriend(context.Background(), req)
|
RpcResp, err := client.DeleteFriend(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -237,26 +195,16 @@ func GetBlacklist(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.GetBlacklistReq{CommID: &rpc.CommID{}}
|
req := &rpc.GetBlacklistReq{CommID: &rpc.CommID{}}
|
||||||
utils.CopyStructFields(req.CommID, ¶ms)
|
utils.CopyStructFields(req.CommID, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.CommID.OperationID, "GetBlacklist args ", req.String())
|
log.NewInfo(req.CommID.OperationID, "GetBlacklist args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewFriendClient(etcdConn)
|
client := rpc.NewFriendClient(etcdConn)
|
||||||
RpcResp, err := client.GetBlacklist(context.Background(), req)
|
RpcResp, err := client.GetBlacklist(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -286,26 +234,16 @@ func SetFriendRemark(c *gin.Context) {
|
|||||||
req := &rpc.SetFriendRemarkReq{CommID: &rpc.CommID{}}
|
req := &rpc.SetFriendRemarkReq{CommID: &rpc.CommID{}}
|
||||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||||
req.Remark = params.Remark
|
req.Remark = params.Remark
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.CommID.OperationID, "SetFriendComment args ", req.String())
|
log.NewInfo(req.CommID.OperationID, "SetFriendComment args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewFriendClient(etcdConn)
|
client := rpc.NewFriendClient(etcdConn)
|
||||||
RpcResp, err := client.SetFriendRemark(context.Background(), req)
|
RpcResp, err := client.SetFriendRemark(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -328,26 +266,16 @@ func RemoveBlack(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.RemoveBlacklistReq{CommID: &rpc.CommID{}}
|
req := &rpc.RemoveBlacklistReq{CommID: &rpc.CommID{}}
|
||||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.CommID.OperationID, "RemoveBlacklist args ", req.String())
|
log.NewInfo(req.CommID.OperationID, "RemoveBlacklist args ", req.String())
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
client := rpc.NewFriendClient(etcdConn)
|
client := rpc.NewFriendClient(etcdConn)
|
||||||
RpcResp, err := client.RemoveBlacklist(context.Background(), req)
|
RpcResp, err := client.RemoveBlacklist(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -369,26 +297,16 @@ func IsFriend(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.IsFriendReq{CommID: &rpc.CommID{}}
|
req := &rpc.IsFriendReq{CommID: &rpc.CommID{}}
|
||||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.CommID.OperationID, "IsFriend args ", req.String())
|
log.NewInfo(req.CommID.OperationID, "IsFriend args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewFriendClient(etcdConn)
|
client := rpc.NewFriendClient(etcdConn)
|
||||||
RpcResp, err := client.IsFriend(context.Background(), req)
|
RpcResp, err := client.IsFriend(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -403,6 +321,40 @@ func IsFriend(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//func GetFriendsInfo(c *gin.Context) {
|
||||||
|
// params := api.GetFriendsInfoReq{}
|
||||||
|
// if err := c.BindJSON(¶ms); err != nil {
|
||||||
|
// log.NewError("0", "BindJSON failed ", err.Error())
|
||||||
|
// c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// req := &rpc.GetFriendsInfoReq{}
|
||||||
|
// utils.CopyStructFields(req.CommID, params)
|
||||||
|
// var ok bool
|
||||||
|
// ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
||||||
|
// if !ok {
|
||||||
|
// log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
|
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// log.NewInfo(req.CommID.OperationID, "GetFriendsInfo args ", req.String())
|
||||||
|
//
|
||||||
|
// etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||||
|
// client := rpc.NewFriendClient(etcdConn)
|
||||||
|
// RpcResp, err := client.GetFriendsInfo(context.Background(), req)
|
||||||
|
// if err != nil {
|
||||||
|
// log.NewError(req.CommID.OperationID, "GetFriendsInfo failed ", err.Error(), req.String())
|
||||||
|
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call search friend rpc server failed"})
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// resp := api.GetFriendsInfoResp{CommResp:api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||||
|
// utils.CopyStructFields(&resp, RpcResp)
|
||||||
|
// c.JSON(http.StatusOK, resp)
|
||||||
|
// log.NewInfo(req.CommID.OperationID, "GetFriendsInfo api return ", resp)
|
||||||
|
//}
|
||||||
|
|
||||||
func GetFriendList(c *gin.Context) {
|
func GetFriendList(c *gin.Context) {
|
||||||
params := api.GetFriendListReq{}
|
params := api.GetFriendListReq{}
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
@@ -412,26 +364,16 @@ func GetFriendList(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.GetFriendListReq{CommID: &rpc.CommID{}}
|
req := &rpc.GetFriendListReq{CommID: &rpc.CommID{}}
|
||||||
utils.CopyStructFields(req.CommID, ¶ms)
|
utils.CopyStructFields(req.CommID, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.CommID.OperationID, "GetFriendList args ", req.String())
|
log.NewInfo(req.CommID.OperationID, "GetFriendList args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewFriendClient(etcdConn)
|
client := rpc.NewFriendClient(etcdConn)
|
||||||
RpcResp, err := client.GetFriendList(context.Background(), req)
|
RpcResp, err := client.GetFriendList(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -456,26 +398,16 @@ func GetFriendApplyList(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.GetFriendApplyListReq{CommID: &rpc.CommID{}}
|
req := &rpc.GetFriendApplyListReq{CommID: &rpc.CommID{}}
|
||||||
utils.CopyStructFields(req.CommID, ¶ms)
|
utils.CopyStructFields(req.CommID, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.CommID.OperationID, "GetFriendApplyList args ", req.String())
|
log.NewInfo(req.CommID.OperationID, "GetFriendApplyList args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewFriendClient(etcdConn)
|
client := rpc.NewFriendClient(etcdConn)
|
||||||
|
|
||||||
RpcResp, err := client.GetFriendApplyList(context.Background(), req)
|
RpcResp, err := client.GetFriendApplyList(context.Background(), req)
|
||||||
@@ -500,26 +432,16 @@ func GetSelfFriendApplyList(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.GetSelfApplyListReq{CommID: &rpc.CommID{}}
|
req := &rpc.GetSelfApplyListReq{CommID: &rpc.CommID{}}
|
||||||
utils.CopyStructFields(req.CommID, ¶ms)
|
utils.CopyStructFields(req.CommID, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.CommID.OperationID, "GetSelfApplyList args ", req.String())
|
log.NewInfo(req.CommID.OperationID, "GetSelfApplyList args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.CommID.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.CommID.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewFriendClient(etcdConn)
|
client := rpc.NewFriendClient(etcdConn)
|
||||||
RpcResp, err := client.GetSelfApplyList(context.Background(), req)
|
RpcResp, err := client.GetSelfApplyList(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import (
|
|||||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"github.com/golang/protobuf/ptypes/wrappers"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
@@ -30,26 +29,17 @@ func KickGroupMember(c *gin.Context) {
|
|||||||
|
|
||||||
req := &rpc.KickGroupMemberReq{}
|
req := &rpc.KickGroupMemberReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "KickGroupMember args ", req.String())
|
log.NewInfo(req.OperationID, "KickGroupMember args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
RpcResp, err := client.KickGroupMember(context.Background(), req)
|
RpcResp, err := client.KickGroupMember(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -81,26 +71,17 @@ func GetGroupMembersInfo(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.GetGroupMembersInfoReq{}
|
req := &rpc.GetGroupMembersInfoReq{}
|
||||||
utils.CopyStructFields(req, params)
|
utils.CopyStructFields(req, params)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
//c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
api.SetErrCodeMsg(c, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "GetGroupMembersInfo args ", req.String())
|
log.NewInfo(req.OperationID, "GetGroupMembersInfo args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
|
|
||||||
RpcResp, err := client.GetGroupMembersInfo(context.Background(), req)
|
RpcResp, err := client.GetGroupMembersInfo(context.Background(), req)
|
||||||
@@ -125,26 +106,16 @@ func GetGroupMemberList(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.GetGroupMemberListReq{}
|
req := &rpc.GetGroupMemberListReq{}
|
||||||
utils.CopyStructFields(req, params)
|
utils.CopyStructFields(req, params)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "GetGroupMemberList args ", req.String())
|
log.NewInfo(req.OperationID, "GetGroupMemberList args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
|
|
||||||
RpcResp, err := client.GetGroupMemberList(context.Background(), req)
|
RpcResp, err := client.GetGroupMemberList(context.Background(), req)
|
||||||
@@ -170,26 +141,16 @@ func GetGroupAllMemberList(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.GetGroupAllMemberReq{}
|
req := &rpc.GetGroupAllMemberReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "GetGroupAllMember args ", req.String())
|
log.NewInfo(req.OperationID, "GetGroupAllMember args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
RpcResp, err := client.GetGroupAllMember(context.Background(), req)
|
RpcResp, err := client.GetGroupAllMember(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -213,26 +174,16 @@ func GetJoinedGroupList(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.GetJoinedGroupListReq{}
|
req := &rpc.GetJoinedGroupListReq{}
|
||||||
utils.CopyStructFields(req, params)
|
utils.CopyStructFields(req, params)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "GetJoinedGroupList args ", req.String())
|
log.NewInfo(req.OperationID, "GetJoinedGroupList args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
RpcResp, err := client.GetJoinedGroupList(context.Background(), req)
|
RpcResp, err := client.GetJoinedGroupList(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -256,26 +207,16 @@ func InviteUserToGroup(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.InviteUserToGroupReq{}
|
req := &rpc.InviteUserToGroupReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "InviteUserToGroup args ", req.String())
|
log.NewInfo(req.OperationID, "InviteUserToGroup args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
RpcResp, err := client.InviteUserToGroup(context.Background(), req)
|
RpcResp, err := client.InviteUserToGroup(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -311,29 +252,18 @@ func CreateGroup(c *gin.Context) {
|
|||||||
for _, v := range params.MemberList {
|
for _, v := range params.MemberList {
|
||||||
req.InitMemberList = append(req.InitMemberList, &rpc.GroupAddMemberInfo{UserID: v.UserID, RoleLevel: v.RoleLevel})
|
req.InitMemberList = append(req.InitMemberList, &rpc.GroupAddMemberInfo{UserID: v.UserID, RoleLevel: v.RoleLevel})
|
||||||
}
|
}
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
req.OwnerUserID = params.OwnerUserID
|
req.OwnerUserID = params.OwnerUserID
|
||||||
req.OperationID = params.OperationID
|
req.OperationID = params.OperationID
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "CreateGroup args ", req.String())
|
log.NewInfo(req.OperationID, "CreateGroup args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
RpcResp, err := client.CreateGroup(context.Background(), req)
|
RpcResp, err := client.CreateGroup(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -370,13 +300,7 @@ func GetRecvGroupApplicationList(c *gin.Context) {
|
|||||||
//}
|
//}
|
||||||
log.NewInfo(req.OperationID, "GetGroupApplicationList args ", req.String())
|
log.NewInfo(req.OperationID, "GetGroupApplicationList args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
reply, err := client.GetGroupApplicationList(context.Background(), req)
|
reply, err := client.GetGroupApplicationList(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -407,13 +331,7 @@ func GetUserReqGroupApplicationList(c *gin.Context) {
|
|||||||
// return
|
// return
|
||||||
//}
|
//}
|
||||||
log.NewInfo(req.OperationID, "GetGroupsInfo args ", req.String())
|
log.NewInfo(req.OperationID, "GetGroupsInfo args ", req.String())
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
RpcResp, err := client.GetUserReqApplicationList(context.Background(), req)
|
RpcResp, err := client.GetUserReqApplicationList(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -437,25 +355,15 @@ func GetGroupsInfo(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.GetGroupsInfoReq{}
|
req := &rpc.GetGroupsInfoReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "GetGroupsInfo args ", req.String())
|
log.NewInfo(req.OperationID, "GetGroupsInfo args ", req.String())
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
RpcResp, err := client.GetGroupsInfo(context.Background(), req)
|
RpcResp, err := client.GetGroupsInfo(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -480,26 +388,16 @@ func ApplicationGroupResponse(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.GroupApplicationResponseReq{}
|
req := &rpc.GroupApplicationResponseReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "ApplicationGroupResponse args ", req.String())
|
log.NewInfo(req.OperationID, "ApplicationGroupResponse args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
reply, err := client.GroupApplicationResponse(context.Background(), req)
|
reply, err := client.GroupApplicationResponse(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -522,25 +420,15 @@ func JoinGroup(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.JoinGroupReq{}
|
req := &rpc.JoinGroupReq{}
|
||||||
utils.CopyStructFields(req, params)
|
utils.CopyStructFields(req, params)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "JoinGroup args ", req.String())
|
log.NewInfo(req.OperationID, "JoinGroup args ", req.String())
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
|
|
||||||
RpcResp, err := client.JoinGroup(context.Background(), req)
|
RpcResp, err := client.JoinGroup(context.Background(), req)
|
||||||
@@ -563,26 +451,16 @@ func QuitGroup(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.QuitGroupReq{}
|
req := &rpc.QuitGroupReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "QuitGroup args ", req.String())
|
log.NewInfo(req.OperationID, "QuitGroup args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
RpcResp, err := client.QuitGroup(context.Background(), req)
|
RpcResp, err := client.QuitGroup(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -605,26 +483,16 @@ func SetGroupInfo(c *gin.Context) {
|
|||||||
req := &rpc.SetGroupInfoReq{GroupInfo: &open_im_sdk.GroupInfo{}}
|
req := &rpc.SetGroupInfoReq{GroupInfo: &open_im_sdk.GroupInfo{}}
|
||||||
utils.CopyStructFields(req.GroupInfo, ¶ms)
|
utils.CopyStructFields(req.GroupInfo, ¶ms)
|
||||||
req.OperationID = params.OperationID
|
req.OperationID = params.OperationID
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "SetGroupInfo args ", req.String())
|
log.NewInfo(req.OperationID, "SetGroupInfo args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
RpcResp, err := client.SetGroupInfo(context.Background(), req)
|
RpcResp, err := client.SetGroupInfo(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -646,26 +514,16 @@ func TransferGroupOwner(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.TransferGroupOwnerReq{}
|
req := &rpc.TransferGroupOwnerReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "TransferGroupOwner args ", req.String())
|
log.NewInfo(req.OperationID, "TransferGroupOwner args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
reply, err := client.TransferGroupOwner(context.Background(), req)
|
reply, err := client.TransferGroupOwner(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -688,26 +546,16 @@ func DismissGroup(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.DismissGroupReq{}
|
req := &rpc.DismissGroupReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " args ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
reply, err := client.DismissGroup(context.Background(), req)
|
reply, err := client.DismissGroup(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -730,26 +578,16 @@ func MuteGroupMember(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.MuteGroupMemberReq{}
|
req := &rpc.MuteGroupMemberReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
reply, err := client.MuteGroupMember(context.Background(), req)
|
reply, err := client.MuteGroupMember(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -772,26 +610,16 @@ func CancelMuteGroupMember(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.CancelMuteGroupMemberReq{}
|
req := &rpc.CancelMuteGroupMemberReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
reply, err := client.CancelMuteGroupMember(context.Background(), req)
|
reply, err := client.CancelMuteGroupMember(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -814,26 +642,16 @@ func MuteGroup(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.MuteGroupReq{}
|
req := &rpc.MuteGroupReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
reply, err := client.MuteGroup(context.Background(), req)
|
reply, err := client.MuteGroup(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -856,26 +674,16 @@ func CancelMuteGroup(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.CancelMuteGroupReq{}
|
req := &rpc.CancelMuteGroupReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
reply, err := client.CancelMuteGroup(context.Background(), req)
|
reply, err := client.CancelMuteGroup(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -900,26 +708,16 @@ func SetGroupMemberNickname(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.SetGroupMemberNicknameReq{}
|
req := &rpc.SetGroupMemberNicknameReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
reply, err := client.SetGroupMemberNickname(context.Background(), req)
|
reply, err := client.SetGroupMemberNickname(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -932,63 +730,3 @@ func SetGroupMemberNickname(c *gin.Context) {
|
|||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetGroupMemberInfo(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.SetGroupMemberInfoReq
|
|
||||||
resp api.SetGroupMemberInfoResp
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
|
||||||
var opUserID string
|
|
||||||
ok, opUserID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
reqPb := &rpc.SetGroupMemberInfoReq{
|
|
||||||
GroupID: req.GroupID,
|
|
||||||
UserID: req.UserID,
|
|
||||||
OperationID: req.OperationID,
|
|
||||||
OpUserID: opUserID,
|
|
||||||
}
|
|
||||||
if req.Nickname != nil {
|
|
||||||
reqPb.Nickname = &wrappers.StringValue{Value: *req.Nickname}
|
|
||||||
}
|
|
||||||
if req.FaceURL != nil {
|
|
||||||
reqPb.FaceURL = &wrappers.StringValue{Value: *req.FaceURL}
|
|
||||||
}
|
|
||||||
if req.Ex != nil {
|
|
||||||
reqPb.Ex = &wrappers.StringValue{Value: *req.Ex}
|
|
||||||
}
|
|
||||||
if req.RoleLevel != nil {
|
|
||||||
reqPb.RoleLevel = &wrappers.Int32Value{Value: *req.RoleLevel}
|
|
||||||
}
|
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
|
||||||
respPb, err := client.SetGroupMemberInfo(context.Background(), reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", err.Error())
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
|
||||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,88 +0,0 @@
|
|||||||
package group
|
|
||||||
|
|
||||||
import (
|
|
||||||
jsonData "Open_IM/internal/utils"
|
|
||||||
api "Open_IM/pkg/base_info"
|
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"Open_IM/pkg/common/log"
|
|
||||||
"Open_IM/pkg/common/token_verify"
|
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
|
||||||
rpc "Open_IM/pkg/proto/group"
|
|
||||||
"Open_IM/pkg/utils"
|
|
||||||
"context"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"net/http"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func GetJoinedSuperGroupList(c *gin.Context) {
|
|
||||||
req := api.GetJoinedSuperGroupListReq{}
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
ok, opUserID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb := rpc.GetJoinedSuperGroupListReq{OperationID: req.OperationID, OpUserID: opUserID, UserID: req.FromUserID}
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
|
||||||
rpcResp, err := client.GetJoinedSuperGroupList(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, "InviteUserToGroup failed ", err.Error(), reqPb.String())
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
GroupListResp := api.GetJoinedSuperGroupListResp{GetJoinedGroupListResp: api.GetJoinedGroupListResp{CommResp: api.CommResp{ErrCode: rpcResp.CommonResp.ErrCode, ErrMsg: rpcResp.CommonResp.ErrMsg}, GroupInfoList: rpcResp.GroupList}}
|
|
||||||
GroupListResp.Data = jsonData.JsonDataList(GroupListResp.GroupInfoList)
|
|
||||||
log.NewInfo(req.OperationID, "GetJoinedGroupList api return ", GroupListResp)
|
|
||||||
c.JSON(http.StatusOK, GroupListResp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetSuperGroupsInfo(c *gin.Context) {
|
|
||||||
req := api.GetSuperGroupsInfoReq{}
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
ok, opUserID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb := rpc.GetSuperGroupsInfoReq{OperationID: req.OperationID, OpUserID: opUserID, GroupIDList: req.GroupIDList}
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
|
||||||
rpcResp, err := client.GetSuperGroupsInfo(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, "InviteUserToGroup failed ", err.Error(), reqPb.String())
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp := api.GetSuperGroupsInfoResp{GetGroupInfoResp: api.GetGroupInfoResp{CommResp: api.CommResp{ErrCode: rpcResp.CommonResp.ErrCode, ErrMsg: rpcResp.CommonResp.ErrMsg}, GroupInfoList: rpcResp.GroupInfoList}}
|
|
||||||
resp.Data = jsonData.JsonDataList(resp.GroupInfoList)
|
|
||||||
log.NewInfo(req.OperationID, "GetGroupsInfo api return ", resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
@@ -28,7 +28,7 @@ import (
|
|||||||
|
|
||||||
var validate *validator.Validate
|
var validate *validator.Validate
|
||||||
|
|
||||||
func newUserSendMsgReq(params *api.ManagementSendMsgReq) *pbChat.SendMsgReq {
|
func newUserSendMsgReq(params *ManagementSendMsgReq) *pbChat.SendMsgReq {
|
||||||
var newContent string
|
var newContent string
|
||||||
var err error
|
var err error
|
||||||
switch params.ContentType {
|
switch params.ContentType {
|
||||||
@@ -40,16 +40,16 @@ func newUserSendMsgReq(params *api.ManagementSendMsgReq) *pbChat.SendMsgReq {
|
|||||||
fallthrough
|
fallthrough
|
||||||
case constant.Voice:
|
case constant.Voice:
|
||||||
fallthrough
|
fallthrough
|
||||||
case constant.Video:
|
|
||||||
fallthrough
|
|
||||||
case constant.File:
|
case constant.File:
|
||||||
newContent = utils.StructToJsonString(params.Content)
|
newContent = utils.StructToJsonString(params.Content)
|
||||||
case constant.Revoke:
|
case constant.Revoke:
|
||||||
newContent = params.Content["revokeMsgClientID"].(string)
|
newContent = params.Content["revokeMsgClientID"].(string)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
options := make(map[string]bool, 5)
|
var options map[string]bool
|
||||||
if params.IsOnlineOnly {
|
if params.IsOnlineOnly {
|
||||||
|
options = make(map[string]bool, 5)
|
||||||
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
||||||
utils.SetSwitchFromOptions(options, constant.IsHistory, false)
|
utils.SetSwitchFromOptions(options, constant.IsHistory, false)
|
||||||
utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
|
utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
|
||||||
@@ -91,10 +91,10 @@ func init() {
|
|||||||
|
|
||||||
func ManagementSendMsg(c *gin.Context) {
|
func ManagementSendMsg(c *gin.Context) {
|
||||||
var data interface{}
|
var data interface{}
|
||||||
params := api.ManagementSendMsgReq{}
|
params := ManagementSendMsgReq{}
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
log.Error(c.PostForm("operationID"), "json unmarshal err", err.Error(), c.PostForm("content"))
|
log.ErrorByKv("json unmarshal err", c.PostForm("operationID"), "err", err.Error(), "content", c.PostForm("content"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch params.ContentType {
|
switch params.ContentType {
|
||||||
@@ -126,19 +126,19 @@ func ManagementSendMsg(c *gin.Context) {
|
|||||||
//case constant.Quote:
|
//case constant.Quote:
|
||||||
default:
|
default:
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 404, "errMsg": "contentType err"})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 404, "errMsg": "contentType err"})
|
||||||
log.Error(c.PostForm("operationID"), "contentType err", c.PostForm("content"))
|
log.ErrorByKv("contentType err", c.PostForm("operationID"), "content", c.PostForm("content"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := mapstructure.WeakDecode(params.Content, &data); err != nil {
|
if err := mapstructure.WeakDecode(params.Content, &data); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": err.Error()})
|
||||||
log.Error(c.PostForm("operationID"), "content to Data struct err", err.Error())
|
log.ErrorByKv("content to Data struct err", "", "err", err.Error())
|
||||||
return
|
return
|
||||||
} else if err := validate.Struct(data); err != nil {
|
} else if err := validate.Struct(data); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 403, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 403, "errMsg": err.Error()})
|
||||||
log.Error(c.PostForm("operationID"), "data args validate err", err.Error())
|
log.ErrorByKv("data args validate err", "", "err", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(params.OperationID, data, params)
|
log.NewInfo("", data, params)
|
||||||
token := c.Request.Header.Get("token")
|
token := c.Request.Header.Get("token")
|
||||||
claims, err := token_verify.ParseToken(token, params.OperationID)
|
claims, err := token_verify.ParseToken(token, params.OperationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -166,21 +166,15 @@ func ManagementSendMsg(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
log.NewInfo(params.OperationID, "Ws call success to ManagementSendMsgReq", params)
|
log.InfoByKv("Ws call success to ManagementSendMsgReq", params.OperationID, "Parameters", params)
|
||||||
|
|
||||||
pbData := newUserSendMsgReq(¶ms)
|
pbData := newUserSendMsgReq(¶ms)
|
||||||
log.Info(params.OperationID, "", "api ManagementSendMsg call start..., [data: %s]", pbData.String())
|
log.Info("", "", "api ManagementSendMsg call start..., [data: %s]", pbData.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName, params.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := params.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(params.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbChat.NewChatClient(etcdConn)
|
client := pbChat.NewChatClient(etcdConn)
|
||||||
|
|
||||||
log.Info(params.OperationID, "", "api ManagementSendMsg call, api call rpc...")
|
log.Info("", "", "api ManagementSendMsg call, api call rpc...")
|
||||||
|
|
||||||
RpcResp, err := client.SendMsg(context.Background(), pbData)
|
RpcResp, err := client.SendMsg(context.Background(), pbData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -188,109 +182,38 @@ func ManagementSendMsg(c *gin.Context) {
|
|||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call UserSendMsg rpc server failed"})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call UserSendMsg rpc server failed"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Info(params.OperationID, "", "api ManagementSendMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
|
log.Info("", "", "api ManagementSendMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
|
||||||
resp := api.ManagementSendMsgResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, ResultList: server_api_params.UserSendMsgResp{ServerMsgID: RpcResp.ServerMsgID, ClientMsgID: RpcResp.ClientMsgID, SendTime: RpcResp.SendTime}}
|
resp := api.ManagementSendMsgResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, ResultList: server_api_params.UserSendMsgResp{ServerMsgID: RpcResp.ServerMsgID, ClientMsgID: RpcResp.ClientMsgID, SendTime: RpcResp.SendTime}}
|
||||||
log.Info(params.OperationID, "ManagementSendMsg return", resp)
|
log.Info(params.OperationID, "ManagementSendMsg return", resp)
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ManagementBatchSendMsg(c *gin.Context) {
|
//
|
||||||
var data interface{}
|
//type MergeElem struct {
|
||||||
params := api.ManagementBatchSendMsgReq{}
|
// Title string `json:"title"`
|
||||||
resp := api.ManagementBatchSendMsgResp{}
|
// AbstractList []string `json:"abstractList"`
|
||||||
resp.Data.FailedIDList = make([]string, 0)
|
// MultiMessage []*MsgStruct `json:"multiMessage"`
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
//}
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
//
|
||||||
log.Error(c.PostForm("operationID"), "json unmarshal err", err.Error(), c.PostForm("content"))
|
//type QuoteElem struct {
|
||||||
return
|
// Text string `json:"text"`
|
||||||
}
|
// QuoteMessage *MsgStruct `json:"quoteMessage"`
|
||||||
switch params.ContentType {
|
//}
|
||||||
case constant.Text:
|
type ManagementSendMsgReq struct {
|
||||||
data = TextElem{}
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
case constant.Picture:
|
SendID string `json:"sendID" binding:"required"`
|
||||||
data = PictureElem{}
|
RecvID string `json:"recvID" `
|
||||||
case constant.Voice:
|
GroupID string `json:"groupID" `
|
||||||
data = SoundElem{}
|
SenderNickname string `json:"senderNickname" `
|
||||||
case constant.Video:
|
SenderFaceURL string `json:"senderFaceURL" `
|
||||||
data = VideoElem{}
|
SenderPlatformID int32 `json:"senderPlatformID"`
|
||||||
case constant.File:
|
ForceList []string `json:"forceList" `
|
||||||
data = FileElem{}
|
Content map[string]interface{} `json:"content" binding:"required"`
|
||||||
//case constant.AtText:
|
ContentType int32 `json:"contentType" binding:"required"`
|
||||||
// data = AtElem{}
|
SessionType int32 `json:"sessionType" binding:"required"`
|
||||||
//case constant.Merger:
|
IsOnlineOnly bool `json:"isOnlineOnly"`
|
||||||
// data =
|
OfflinePushInfo *open_im_sdk.OfflinePushInfo `json:"offlinePushInfo"`
|
||||||
//case constant.Card:
|
|
||||||
//case constant.Location:
|
|
||||||
case constant.Custom:
|
|
||||||
data = CustomElem{}
|
|
||||||
case constant.Revoke:
|
|
||||||
data = RevokeElem{}
|
|
||||||
case constant.OANotification:
|
|
||||||
data = OANotificationElem{}
|
|
||||||
params.SessionType = constant.NotificationChatType
|
|
||||||
//case constant.HasReadReceipt:
|
|
||||||
//case constant.Typing:
|
|
||||||
//case constant.Quote:
|
|
||||||
default:
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 404, "errMsg": "contentType err"})
|
|
||||||
log.Error(c.PostForm("operationID"), "contentType err", c.PostForm("content"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := mapstructure.WeakDecode(params.Content, &data); err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": err.Error()})
|
|
||||||
log.Error(c.PostForm("operationID"), "content to Data struct err", err.Error())
|
|
||||||
return
|
|
||||||
} else if err := validate.Struct(data); err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 403, "errMsg": err.Error()})
|
|
||||||
log.Error(c.PostForm("operationID"), "data args validate err", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(params.OperationID, data, params)
|
|
||||||
token := c.Request.Header.Get("token")
|
|
||||||
claims, err := token_verify.ParseToken(token, params.OperationID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(params.OperationID, "parse token failed", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "parse token failed", "sendTime": 0, "MsgID": ""})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !utils.IsContain(claims.UID, config.Config.Manager.AppManagerUid) {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "not authorized", "sendTime": 0, "MsgID": ""})
|
|
||||||
return
|
|
||||||
|
|
||||||
}
|
|
||||||
log.NewInfo(params.OperationID, "Ws call success to ManagementSendMsgReq", params)
|
|
||||||
for _, recvID := range params.RecvIDList {
|
|
||||||
pbData := newUserSendMsgReq(¶ms.ManagementSendMsgReq)
|
|
||||||
pbData.MsgData.RecvID = recvID
|
|
||||||
log.Info(params.OperationID, "", "api ManagementSendMsg call start..., ", pbData.String())
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName, params.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := params.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(params.OperationID, errMsg)
|
|
||||||
resp.Data.FailedIDList = append(resp.Data.FailedIDList, recvID)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
client := pbChat.NewChatClient(etcdConn)
|
|
||||||
rpcResp, err := client.SendMsg(context.Background(), pbData)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(params.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
|
||||||
resp.Data.FailedIDList = append(resp.Data.FailedIDList, recvID)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if rpcResp.ErrCode != 0 {
|
|
||||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), "rpc failed", pbData, rpcResp)
|
|
||||||
resp.Data.FailedIDList = append(resp.Data.FailedIDList, recvID)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
resp.Data.ResultList = append(resp.Data.ResultList, server_api_params.UserSendMsgResp{
|
|
||||||
ServerMsgID: rpcResp.ServerMsgID,
|
|
||||||
ClientMsgID: rpcResp.ClientMsgID,
|
|
||||||
SendTime: rpcResp.SendTime,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
log.NewInfo(params.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type PictureBaseInfo struct {
|
type PictureBaseInfo struct {
|
||||||
@@ -359,15 +282,15 @@ type RevokeElem struct {
|
|||||||
RevokeMsgClientID string `mapstructure:"revokeMsgClientID" validate:"required"`
|
RevokeMsgClientID string `mapstructure:"revokeMsgClientID" validate:"required"`
|
||||||
}
|
}
|
||||||
type OANotificationElem struct {
|
type OANotificationElem struct {
|
||||||
NotificationName string `mapstructure:"notificationName" json:"notificationName" validate:"required"`
|
NotificationName string `mapstructure:"notificationName" validate:"required"`
|
||||||
NotificationFaceURL string `mapstructure:"notificationFaceURL" json:"notificationFaceURL" validate:"required"`
|
NotificationFaceURL string `mapstructure:"notificationFaceURL" validate:"required"`
|
||||||
NotificationType int32 `mapstructure:"notificationType" json:"notificationType" validate:"required"`
|
NotificationType int32 `mapstructure:"notificationType" validate:"required"`
|
||||||
Text string `mapstructure:"text" json:"text" validate:"required"`
|
Text string `mapstructure:"text" validate:"required"`
|
||||||
Url string `mapstructure:"url" json:"url"`
|
Url string `mapstructure:"url"`
|
||||||
MixType int32 `mapstructure:"mixType" json:"mixType"`
|
MixType int32 `mapstructure:"mixType"`
|
||||||
PictureElem PictureElem `mapstructure:"pictureElem" json:"pictureElem"`
|
PictureElem PictureElem `mapstructure:"pictureElem"`
|
||||||
SoundElem SoundElem `mapstructure:"soundElem" json:"soundElem"`
|
SoundElem SoundElem `mapstructure:"soundElem"`
|
||||||
VideoElem VideoElem `mapstructure:"videoElem" json:"videoElem"`
|
VideoElem VideoElem `mapstructure:"videoElem"`
|
||||||
FileElem FileElem `mapstructure:"fileElem" json:"fileElem"`
|
FileElem FileElem `mapstructure:"fileElem"`
|
||||||
Ex string `mapstructure:"ex" json:"ex"`
|
Ex string `mapstructure:"ex"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,25 +30,15 @@ func DeleteUser(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.DeleteUsersReq{}
|
req := &rpc.DeleteUsersReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(params.OperationID, "DeleteUser args ", req.String())
|
log.NewInfo(params.OperationID, "DeleteUser args ", req.String())
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewUserClient(etcdConn)
|
client := rpc.NewUserClient(etcdConn)
|
||||||
|
|
||||||
RpcResp, err := client.DeleteUsers(context.Background(), req)
|
RpcResp, err := client.DeleteUsers(context.Background(), req)
|
||||||
@@ -72,25 +62,15 @@ func GetAllUsersUid(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.GetAllUserIDReq{}
|
req := &rpc.GetAllUserIDReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(params.OperationID, "GetAllUsersUid args ", req.String())
|
log.NewInfo(params.OperationID, "GetAllUsersUid args ", req.String())
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewUserClient(etcdConn)
|
client := rpc.NewUserClient(etcdConn)
|
||||||
RpcResp, err := client.GetAllUserID(context.Background(), req)
|
RpcResp, err := client.GetAllUserID(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -114,25 +94,15 @@ func AccountCheck(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.AccountCheckReq{}
|
req := &rpc.AccountCheckReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(params.OperationID, "AccountCheck args ", req.String())
|
log.NewInfo(params.OperationID, "AccountCheck args ", req.String())
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewUserClient(etcdConn)
|
client := rpc.NewUserClient(etcdConn)
|
||||||
|
|
||||||
RpcResp, err := client.AccountCheck(context.Background(), req)
|
RpcResp, err := client.AccountCheck(context.Background(), req)
|
||||||
@@ -157,14 +127,11 @@ func GetUsersOnlineStatus(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &pbRelay.GetUsersOnlineStatusReq{}
|
req := &pbRelay.GetUsersOnlineStatusReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import (
|
|||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"google.golang.org/grpc"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -28,27 +27,15 @@ func GetUserTags(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
var userID string
|
|
||||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
reqPb.UserID = userID
|
reqPb.UserID = userID
|
||||||
reqPb.OperationID = req.OperationID
|
reqPb.OperationID = req.OperationID
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
respPb, err := client.GetUserTags(context.Background(), &reqPb)
|
respPb, err := client.GetUserTags(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -82,26 +69,14 @@ func CreateTag(c *gin.Context) {
|
|||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
var userID string
|
|
||||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
reqPb.UserID = userID
|
reqPb.UserID = userID
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
respPb, err := client.CreateTag(context.Background(), &reqPb)
|
respPb, err := client.CreateTag(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -130,26 +105,14 @@ func DeleteTag(c *gin.Context) {
|
|||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
var userID string
|
|
||||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
reqPb.UserID = userID
|
reqPb.UserID = userID
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
respPb, err := client.DeleteTag(context.Background(), &reqPb)
|
respPb, err := client.DeleteTag(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -178,26 +141,14 @@ func SetTag(c *gin.Context) {
|
|||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
var userID string
|
|
||||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
reqPb.UserID = userID
|
reqPb.UserID = userID
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
respPb, err := client.SetTag(context.Background(), &reqPb)
|
respPb, err := client.SetTag(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -226,26 +177,14 @@ func SendMsg2Tag(c *gin.Context) {
|
|||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
var userID string
|
|
||||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
reqPb.SendID = userID
|
reqPb.SendID = userID
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
respPb, err := client.SendMsg2Tag(context.Background(), &reqPb)
|
respPb, err := client.SendMsg2Tag(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -271,37 +210,24 @@ func GetTagSendLogs(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
var userID string
|
|
||||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
reqPb.UserID = userID
|
reqPb.UserID = userID
|
||||||
reqPb.OperationID = req.OperationID
|
reqPb.OperationID = req.OperationID
|
||||||
reqPb.Pagination = &pbCommon.RequestPagination{
|
reqPb.Pagination = &pbCommon.RequestPagination{
|
||||||
PageNumber: req.PageNumber,
|
PageNumber: req.PageNumber,
|
||||||
ShowNumber: req.ShowNumber,
|
ShowNumber: req.ShowNumber,
|
||||||
}
|
}
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
maxSizeOption := grpc.MaxCallRecvMsgSize(1024 * 1024 * 20)
|
respPb, err := client.GetTagSendLogs(context.Background(), &reqPb)
|
||||||
respPb, err := client.GetTagSendLogs(context.Background(), &reqPb, maxSizeOption)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetTagSendLogs failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error())
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetTagSendLogs rpc server failed" + err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
|
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
|
||||||
@@ -329,28 +255,16 @@ func GetUserTagByID(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
var userID string
|
|
||||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
reqPb.UserID = userID
|
reqPb.UserID = userID
|
||||||
reqPb.OperationID = req.OperationID
|
reqPb.OperationID = req.OperationID
|
||||||
reqPb.TagID = req.TagID
|
reqPb.TagID = req.TagID
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
respPb, err := client.GetUserTagByID(context.Background(), &reqPb)
|
respPb, err := client.GetUserTagByID(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -28,30 +28,17 @@ func CreateOneWorkMoment(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
var userID string
|
|
||||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
reqPb.WorkMoment.UserID = userID
|
reqPb.WorkMoment.UserID = userID
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
respPb, err := client.CreateOneWorkMoment(context.Background(), &reqPb)
|
respPb, err := client.CreateOneWorkMoment(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -80,30 +67,17 @@ func DeleteOneWorkMoment(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
var userID string
|
|
||||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
reqPb.UserID = userID
|
reqPb.UserID = userID
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
respPb, err := client.DeleteOneWorkMoment(context.Background(), &reqPb)
|
respPb, err := client.DeleteOneWorkMoment(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -131,29 +105,17 @@ func LikeOneWorkMoment(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
var userID string
|
|
||||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
reqPb.UserID = userID
|
reqPb.UserID = userID
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
respPb, err := client.LikeOneWorkMoment(context.Background(), &reqPb)
|
respPb, err := client.LikeOneWorkMoment(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -181,29 +143,17 @@ func CommentOneWorkMoment(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
var userID string
|
|
||||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
reqPb.UserID = userID
|
reqPb.UserID = userID
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
respPb, err := client.CommentOneWorkMoment(context.Background(), &reqPb)
|
respPb, err := client.CommentOneWorkMoment(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -218,54 +168,6 @@ func CommentOneWorkMoment(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteComment(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req apiStruct.DeleteCommentReq
|
|
||||||
resp apiStruct.DeleteCommentResp
|
|
||||||
reqPb pbOffice.DeleteCommentReq
|
|
||||||
respPb *pbOffice.DeleteCommentResp
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, reqPb.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
|
||||||
respPb, err := client.DeleteComment(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DeleteComment rpc failed", err.Error())
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "DeleteComment rpc server failed" + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetWorkMomentByID(c *gin.Context) {
|
func GetWorkMomentByID(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req apiStruct.GetWorkMomentByIDReq
|
req apiStruct.GetWorkMomentByIDReq
|
||||||
@@ -279,28 +181,16 @@ func GetWorkMomentByID(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
var userID string
|
|
||||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
reqPb.OperationID = req.OperationID
|
reqPb.OperationID = req.OperationID
|
||||||
reqPb.OpUserID = userID
|
reqPb.OpUserID = userID
|
||||||
reqPb.WorkMomentID = req.WorkMomentID
|
reqPb.WorkMomentID = req.WorkMomentID
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
respPb, err := client.GetWorkMomentByID(context.Background(), &reqPb)
|
respPb, err := client.GetWorkMomentByID(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -311,8 +201,8 @@ func GetWorkMomentByID(c *gin.Context) {
|
|||||||
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
|
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
resp.Data.WorkMoment = &apiStruct.WorkMoment{LikeUserList: []*apiStruct.WorkMomentUser{}, Comments: []*apiStruct.Comment{},
|
//resp.Data.WorkMoment = respPb.WorkMoment
|
||||||
AtUserList: []*apiStruct.WorkMomentUser{}, PermissionUserList: []*apiStruct.WorkMomentUser{}}
|
resp.Data.WorkMoment = &apiStruct.WorkMoment{}
|
||||||
if err := utils.CopyStructFields(&resp.Data.WorkMoment, respPb.WorkMoment); err != nil {
|
if err := utils.CopyStructFields(&resp.Data.WorkMoment, respPb.WorkMoment); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
@@ -333,32 +223,19 @@ func GetUserWorkMoments(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
var opUserID string
|
|
||||||
ok, opUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
reqPb.OperationID = req.OperationID
|
reqPb.OperationID = req.OperationID
|
||||||
reqPb.Pagination = &pbCommon.RequestPagination{
|
reqPb.Pagination = &pbCommon.RequestPagination{
|
||||||
PageNumber: req.PageNumber,
|
PageNumber: req.PageNumber,
|
||||||
ShowNumber: req.ShowNumber,
|
ShowNumber: req.ShowNumber,
|
||||||
}
|
}
|
||||||
reqPb.OpUserID = opUserID
|
reqPb.UserID = userID
|
||||||
reqPb.UserID = req.UserID
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
respPb, err := client.GetUserWorkMoments(context.Background(), &reqPb)
|
respPb, err := client.GetUserWorkMoments(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -366,57 +243,11 @@ func GetUserWorkMoments(c *gin.Context) {
|
|||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserWorkMoments rpc server failed" + err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserWorkMoments rpc server failed" + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp.Data.WorkMoments = []*apiStruct.WorkMoment{}
|
|
||||||
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
|
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
//if err := utils.CopyStructFields(&resp.Data.WorkMoments, respPb.WorkMoments); err != nil {
|
if err := utils.CopyStructFields(&resp.Data.WorkMoments, respPb.WorkMoments); err != nil {
|
||||||
// log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
//}
|
|
||||||
for _, v := range respPb.WorkMoments {
|
|
||||||
workMoment := apiStruct.WorkMoment{
|
|
||||||
WorkMomentID: v.WorkMomentID,
|
|
||||||
UserID: v.UserID,
|
|
||||||
Content: v.Content,
|
|
||||||
FaceURL: v.FaceURL,
|
|
||||||
UserName: v.UserName,
|
|
||||||
CreateTime: v.CreateTime,
|
|
||||||
Comments: make([]*apiStruct.Comment, len(v.Comments)),
|
|
||||||
LikeUserList: make([]*apiStruct.WorkMomentUser, len(v.LikeUserList)),
|
|
||||||
AtUserList: make([]*apiStruct.WorkMomentUser, len(v.AtUserList)),
|
|
||||||
PermissionUserList: make([]*apiStruct.WorkMomentUser, len(v.PermissionUserList)),
|
|
||||||
Permission: v.Permission,
|
|
||||||
}
|
|
||||||
for i, comment := range v.Comments {
|
|
||||||
workMoment.Comments[i] = &apiStruct.Comment{
|
|
||||||
UserID: comment.UserID,
|
|
||||||
UserName: comment.UserName,
|
|
||||||
ReplyUserID: comment.ReplyUserID,
|
|
||||||
ReplyUserName: comment.ReplyUserName,
|
|
||||||
ContentID: comment.ContentID,
|
|
||||||
Content: comment.Content,
|
|
||||||
CreateTime: comment.CreateTime,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for i, likeUser := range v.LikeUserList {
|
|
||||||
workMoment.LikeUserList[i] = &apiStruct.WorkMomentUser{
|
|
||||||
UserID: likeUser.UserID,
|
|
||||||
UserName: likeUser.UserName,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for i, atUser := range v.AtUserList {
|
|
||||||
workMoment.AtUserList[i] = &apiStruct.WorkMomentUser{
|
|
||||||
UserID: atUser.UserID,
|
|
||||||
UserName: atUser.UserName,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for i, permissionUser := range v.PermissionUserList {
|
|
||||||
workMoment.PermissionUserList[i] = &apiStruct.WorkMomentUser{
|
|
||||||
UserID: permissionUser.UserID,
|
|
||||||
UserName: permissionUser.UserName,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
resp.Data.WorkMoments = append(resp.Data.WorkMoments, &workMoment)
|
|
||||||
}
|
}
|
||||||
resp.Data.ShowNumber = respPb.Pagination.ShowNumber
|
resp.Data.ShowNumber = respPb.Pagination.ShowNumber
|
||||||
resp.Data.CurrentPage = respPb.Pagination.CurrentPage
|
resp.Data.CurrentPage = respPb.Pagination.CurrentPage
|
||||||
@@ -437,31 +268,19 @@ func GetUserFriendWorkMoments(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
var userID string
|
|
||||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
reqPb.OperationID = req.OperationID
|
reqPb.OperationID = req.OperationID
|
||||||
reqPb.Pagination = &pbCommon.RequestPagination{
|
reqPb.Pagination = &pbCommon.RequestPagination{
|
||||||
PageNumber: req.PageNumber,
|
PageNumber: req.PageNumber,
|
||||||
ShowNumber: req.ShowNumber,
|
ShowNumber: req.ShowNumber,
|
||||||
}
|
}
|
||||||
reqPb.UserID = userID
|
reqPb.UserID = userID
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
respPb, err := client.GetUserFriendWorkMoments(context.Background(), &reqPb)
|
respPb, err := client.GetUserFriendWorkMoments(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -472,54 +291,8 @@ func GetUserFriendWorkMoments(c *gin.Context) {
|
|||||||
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
|
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
//if err := utils.CopyStructFields(&resp.Data.WorkMoments, respPb.WorkMoments); err != nil {
|
if err := utils.CopyStructFields(&resp.Data.WorkMoments, respPb.WorkMoments); err != nil {
|
||||||
// log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
//}
|
|
||||||
resp.Data.WorkMoments = []*apiStruct.WorkMoment{}
|
|
||||||
for _, v := range respPb.WorkMoments {
|
|
||||||
workMoment := apiStruct.WorkMoment{
|
|
||||||
WorkMomentID: v.WorkMomentID,
|
|
||||||
UserID: v.UserID,
|
|
||||||
Content: v.Content,
|
|
||||||
FaceURL: v.FaceURL,
|
|
||||||
UserName: v.UserName,
|
|
||||||
CreateTime: v.CreateTime,
|
|
||||||
Comments: make([]*apiStruct.Comment, len(v.Comments)),
|
|
||||||
LikeUserList: make([]*apiStruct.WorkMomentUser, len(v.LikeUserList)),
|
|
||||||
AtUserList: make([]*apiStruct.WorkMomentUser, len(v.AtUserList)),
|
|
||||||
PermissionUserList: make([]*apiStruct.WorkMomentUser, len(v.PermissionUserList)),
|
|
||||||
Permission: v.Permission,
|
|
||||||
}
|
|
||||||
for i, comment := range v.Comments {
|
|
||||||
workMoment.Comments[i] = &apiStruct.Comment{
|
|
||||||
UserID: comment.UserID,
|
|
||||||
UserName: comment.UserName,
|
|
||||||
ReplyUserID: comment.ReplyUserID,
|
|
||||||
ReplyUserName: comment.ReplyUserName,
|
|
||||||
ContentID: comment.ContentID,
|
|
||||||
Content: comment.Content,
|
|
||||||
CreateTime: comment.CreateTime,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for i, likeUser := range v.LikeUserList {
|
|
||||||
workMoment.LikeUserList[i] = &apiStruct.WorkMomentUser{
|
|
||||||
UserID: likeUser.UserID,
|
|
||||||
UserName: likeUser.UserName,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for i, atUser := range v.AtUserList {
|
|
||||||
workMoment.AtUserList[i] = &apiStruct.WorkMomentUser{
|
|
||||||
UserID: atUser.UserID,
|
|
||||||
UserName: atUser.UserName,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for i, permissionUser := range v.PermissionUserList {
|
|
||||||
workMoment.PermissionUserList[i] = &apiStruct.WorkMomentUser{
|
|
||||||
UserID: permissionUser.UserID,
|
|
||||||
UserName: permissionUser.UserName,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
resp.Data.WorkMoments = append(resp.Data.WorkMoments, &workMoment)
|
|
||||||
}
|
}
|
||||||
resp.Data.ShowNumber = respPb.Pagination.ShowNumber
|
resp.Data.ShowNumber = respPb.Pagination.ShowNumber
|
||||||
resp.Data.CurrentPage = respPb.Pagination.CurrentPage
|
resp.Data.CurrentPage = respPb.Pagination.CurrentPage
|
||||||
@@ -540,29 +313,17 @@ func SetUserWorkMomentsLevel(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
var userID string
|
|
||||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||||
}
|
}
|
||||||
reqPb.UserID = userID
|
reqPb.UserID = userID
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||||
respPb, err := client.SetUserWorkMomentsLevel(context.Background(), &reqPb)
|
respPb, err := client.SetUserWorkMomentsLevel(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -36,14 +36,7 @@ func CreateDepartment(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
client := rpc.NewOrganizationClient(etcdConn)
|
client := rpc.NewOrganizationClient(etcdConn)
|
||||||
RpcResp, err := client.CreateDepartment(context.Background(), req)
|
RpcResp, err := client.CreateDepartment(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -79,14 +72,7 @@ func UpdateDepartment(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
client := rpc.NewOrganizationClient(etcdConn)
|
client := rpc.NewOrganizationClient(etcdConn)
|
||||||
RpcResp, err := client.UpdateDepartment(context.Background(), req)
|
RpcResp, err := client.UpdateDepartment(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -120,13 +106,7 @@ func GetSubDepartment(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewOrganizationClient(etcdConn)
|
client := rpc.NewOrganizationClient(etcdConn)
|
||||||
RpcResp, err := client.GetSubDepartment(context.Background(), req)
|
RpcResp, err := client.GetSubDepartment(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -164,13 +144,7 @@ func DeleteDepartment(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewOrganizationClient(etcdConn)
|
client := rpc.NewOrganizationClient(etcdConn)
|
||||||
RpcResp, err := client.DeleteDepartment(context.Background(), req)
|
RpcResp, err := client.DeleteDepartment(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -206,13 +180,7 @@ func CreateOrganizationUser(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewOrganizationClient(etcdConn)
|
client := rpc.NewOrganizationClient(etcdConn)
|
||||||
RpcResp, err := client.CreateOrganizationUser(context.Background(), req)
|
RpcResp, err := client.CreateOrganizationUser(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -247,13 +215,7 @@ func UpdateOrganizationUser(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewOrganizationClient(etcdConn)
|
client := rpc.NewOrganizationClient(etcdConn)
|
||||||
RpcResp, err := client.UpdateOrganizationUser(context.Background(), req)
|
RpcResp, err := client.UpdateOrganizationUser(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -289,13 +251,7 @@ func CreateDepartmentMember(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewOrganizationClient(etcdConn)
|
client := rpc.NewOrganizationClient(etcdConn)
|
||||||
RpcResp, err := client.CreateDepartmentMember(context.Background(), req)
|
RpcResp, err := client.CreateDepartmentMember(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -330,13 +286,7 @@ func GetUserInDepartment(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewOrganizationClient(etcdConn)
|
client := rpc.NewOrganizationClient(etcdConn)
|
||||||
RpcResp, err := client.GetUserInDepartment(context.Background(), req)
|
RpcResp, err := client.GetUserInDepartment(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -372,13 +322,7 @@ func UpdateUserInDepartment(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewOrganizationClient(etcdConn)
|
client := rpc.NewOrganizationClient(etcdConn)
|
||||||
RpcResp, err := client.UpdateUserInDepartment(context.Background(), req)
|
RpcResp, err := client.UpdateUserInDepartment(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -413,13 +357,7 @@ func DeleteOrganizationUser(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewOrganizationClient(etcdConn)
|
client := rpc.NewOrganizationClient(etcdConn)
|
||||||
RpcResp, err := client.DeleteOrganizationUser(context.Background(), req)
|
RpcResp, err := client.DeleteOrganizationUser(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -454,13 +392,7 @@ func GetDepartmentMember(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewOrganizationClient(etcdConn)
|
client := rpc.NewOrganizationClient(etcdConn)
|
||||||
RpcResp, err := client.GetDepartmentMember(context.Background(), req)
|
RpcResp, err := client.GetDepartmentMember(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -495,13 +427,7 @@ func DeleteUserInDepartment(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewOrganizationClient(etcdConn)
|
client := rpc.NewOrganizationClient(etcdConn)
|
||||||
RpcResp, err := client.DeleteUserInDepartment(context.Background(), req)
|
RpcResp, err := client.DeleteUserInDepartment(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -54,18 +54,12 @@ func AliOSSCredential(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
var ok bool
|
|
||||||
var userID string
|
|
||||||
var errInfo string
|
|
||||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "AliOSSCredential args ", userID)
|
log.NewInfo(req.OperationID, "AliOSSCredential args ", userID)
|
||||||
|
|
||||||
stsResp, err := getStsClient().AssumeRole(&sts20150401.AssumeRoleRequest{
|
stsResp, err := getStsClient().AssumeRole(&sts20150401.AssumeRoleRequest{
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
MinioClient *minio.Client
|
minioClient *minio.Client
|
||||||
)
|
)
|
||||||
|
|
||||||
func MinioInit() {
|
func MinioInit() {
|
||||||
@@ -29,16 +29,11 @@ func MinioInit() {
|
|||||||
log.NewError(operationID, utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
|
log.NewError(operationID, utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
opts := &minio.Options{
|
|
||||||
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
|
|
||||||
}
|
|
||||||
if minioUrl.Scheme == "http" {
|
|
||||||
opts.Secure = false
|
|
||||||
} else if minioUrl.Scheme == "https" {
|
|
||||||
opts.Secure = true
|
|
||||||
}
|
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "Parse ok ", config.Config.Credential.Minio)
|
log.NewInfo(operationID, utils.GetSelfFuncName(), "Parse ok ", config.Config.Credential.Minio)
|
||||||
MinioClient, err = minio.New(minioUrl.Host, opts)
|
minioClient, err = minio.New(minioUrl.Host, &minio.Options{
|
||||||
|
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
|
||||||
|
Secure: false,
|
||||||
|
})
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "new ok ", config.Config.Credential.Minio)
|
log.NewInfo(operationID, utils.GetSelfFuncName(), "new ok ", config.Config.Credential.Minio)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(operationID, utils.GetSelfFuncName(), "init minio client failed", err.Error())
|
log.NewError(operationID, utils.GetSelfFuncName(), "init minio client failed", err.Error())
|
||||||
@@ -48,25 +43,10 @@ func MinioInit() {
|
|||||||
Region: config.Config.Credential.Minio.Location,
|
Region: config.Config.Credential.Minio.Location,
|
||||||
ObjectLocking: false,
|
ObjectLocking: false,
|
||||||
}
|
}
|
||||||
err = MinioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.Bucket, opt)
|
err = minioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.Bucket, opt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(operationID, utils.GetSelfFuncName(), "MakeBucket failed ", err.Error())
|
log.NewError(operationID, utils.GetSelfFuncName(), "MakeBucket failed ", err.Error())
|
||||||
exists, err := MinioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
|
exists, err := minioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
|
||||||
if err == nil && exists {
|
|
||||||
log.NewWarn(operationID, utils.GetSelfFuncName(), "We already own ", config.Config.Credential.Minio.Bucket)
|
|
||||||
} else {
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
|
|
||||||
}
|
|
||||||
log.NewError(operationID, utils.GetSelfFuncName(), "create bucket failed and bucket not exists")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// make app bucket
|
|
||||||
err = MinioClient.MakeBucket(context.Background(), config.Config.Credential.Minio.AppBucket, opt)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(operationID, utils.GetSelfFuncName(), "MakeBucket failed ", err.Error())
|
|
||||||
exists, err := MinioClient.BucketExists(context.Background(), config.Config.Credential.Minio.Bucket)
|
|
||||||
if err == nil && exists {
|
if err == nil && exists {
|
||||||
log.NewWarn(operationID, utils.GetSelfFuncName(), "We already own ", config.Config.Credential.Minio.Bucket)
|
log.NewWarn(operationID, utils.GetSelfFuncName(), "We already own ", config.Config.Credential.Minio.Bucket)
|
||||||
} else {
|
} else {
|
||||||
@@ -78,10 +58,9 @@ func MinioInit() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 自动化桶public的代码
|
// 自动化桶public的代码
|
||||||
//err = MinioClient.SetBucketPolicy(context.Background(), config.Config.Credential.Minio.Bucket, policy.BucketPolicyReadWrite)
|
//err = minioClient.SetBucketPolicy(context.Background(), config.Config.Credential.Minio.Bucket, policy.BucketPolicyReadWrite)
|
||||||
//err = MinioClient.SetBucketPolicy(context.Background(), config.Config.Credential.Minio.AppBucket, policy.BucketPolicyReadWrite)
|
|
||||||
//if err != nil {
|
//if err != nil {
|
||||||
// log.NewDebug("", utils.GetSelfFuncName(), "SetBucketPolicy failed please set in web", err.Error())
|
// log.NewError("", utils.GetSelfFuncName(), "SetBucketPolicy failed please set in web", err.Error())
|
||||||
// return
|
// return
|
||||||
//}
|
//}
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "minio create and set policy success")
|
log.NewInfo(operationID, utils.GetSelfFuncName(), "minio create and set policy success")
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
apiStruct "Open_IM/pkg/base_info"
|
apiStruct "Open_IM/pkg/base_info"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
_ "Open_IM/pkg/common/token_verify"
|
_ "Open_IM/pkg/common/token_verify"
|
||||||
@@ -34,17 +33,12 @@ func MinioUploadFile(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
ok, _ := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, _, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError("", utils.GetSelfFuncName(), "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
||||||
switch req.FileType {
|
switch req.FileType {
|
||||||
// videoType upload snapShot
|
// videoType upload snapShot
|
||||||
@@ -62,7 +56,7 @@ func MinioUploadFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
snapShotNewName, snapShotNewType := utils.GetNewFileNameAndContentType(snapShotFile.Filename, constant.ImageType)
|
snapShotNewName, snapShotNewType := utils.GetNewFileNameAndContentType(snapShotFile.Filename, constant.ImageType)
|
||||||
log.Debug(req.OperationID, utils.GetSelfFuncName(), snapShotNewName, snapShotNewType)
|
log.Debug(req.OperationID, utils.GetSelfFuncName(), snapShotNewName, snapShotNewType)
|
||||||
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, snapShotNewName, snapShotFileObj, snapShotFile.Size, minio.PutObjectOptions{ContentType: snapShotNewType})
|
_, err = minioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, snapShotNewName, snapShotFileObj, snapShotFile.Size, minio.PutObjectOptions{ContentType: snapShotNewType})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject snapShotFile error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject snapShotFile error", err.Error())
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
@@ -73,7 +67,6 @@ func MinioUploadFile(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
file, err := c.FormFile("file")
|
file, err := c.FormFile("file")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "FormFile failed", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing file arg: " + err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "missing file arg: " + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -84,11 +77,11 @@ func MinioUploadFile(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
newName, newType := utils.GetNewFileNameAndContentType(file.Filename, req.FileType)
|
newName, newType := utils.GetNewFileNameAndContentType(file.Filename, req.FileType)
|
||||||
log.Debug(req.OperationID, utils.GetSelfFuncName(), config.Config.Credential.Minio.Bucket, newName, fileObj, file.Size, newType, MinioClient.EndpointURL())
|
log.Debug(req.OperationID, utils.GetSelfFuncName(), newName, newType)
|
||||||
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, newName, fileObj, file.Size, minio.PutObjectOptions{ContentType: newType})
|
_, err = minioClient.PutObject(context.Background(), config.Config.Credential.Minio.Bucket, newName, fileObj, file.Size, minio.PutObjectOptions{ContentType: newType})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "upload file error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "open file error")
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "upload file error" + err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "invalid file path" + err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp.NewName = newName
|
resp.NewName = newName
|
||||||
@@ -108,17 +101,12 @@ func MinioStorageCredential(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
ok, _ := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, _, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError("", utils.GetSelfFuncName(), "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var stsOpts cr.STSAssumeRoleOptions
|
var stsOpts cr.STSAssumeRoleOptions
|
||||||
stsOpts.AccessKey = config.Config.Credential.Minio.AccessKeyID
|
stsOpts.AccessKey = config.Config.Credential.Minio.AccessKeyID
|
||||||
stsOpts.SecretKey = config.Config.Credential.Minio.SecretAccessKey
|
stsOpts.SecretKey = config.Config.Credential.Minio.SecretAccessKey
|
||||||
@@ -148,98 +136,3 @@ func MinioStorageCredential(c *gin.Context) {
|
|||||||
resp.StsEndpointURL = config.Config.Credential.Minio.Endpoint
|
resp.StsEndpointURL = config.Config.Credential.Minio.Endpoint
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||||
}
|
}
|
||||||
|
|
||||||
func UploadUpdateApp(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req apiStruct.UploadUpdateAppReq
|
|
||||||
resp apiStruct.UploadUpdateAppResp
|
|
||||||
)
|
|
||||||
if err := c.Bind(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
var yamlName string
|
|
||||||
if req.Yaml == nil {
|
|
||||||
yamlName = ""
|
|
||||||
} else {
|
|
||||||
yamlName = req.Yaml.Filename
|
|
||||||
}
|
|
||||||
fileObj, err := req.File.Open()
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "Open file error", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "Open file error" + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, req.File.Filename, fileObj, req.File.Size, minio.PutObjectOptions{})
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject file error")
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "PutObject file error" + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if yamlName != "" {
|
|
||||||
yamlObj, err := req.Yaml.Open()
|
|
||||||
if err == nil {
|
|
||||||
_, err = MinioClient.PutObject(context.Background(), config.Config.Credential.Minio.AppBucket, yamlName, yamlObj, req.Yaml.Size, minio.PutObjectOptions{})
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "PutObject yaml error")
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "PutObject yaml error" + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err := imdb.UpdateAppVersion(req.Type, req.Version, req.ForceUpdate, req.File.Filename, yamlName, req.UpdateLog); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateAppVersion error", err.Error())
|
|
||||||
resp.ErrCode = http.StatusInternalServerError
|
|
||||||
resp.ErrMsg = err.Error()
|
|
||||||
c.JSON(http.StatusInternalServerError, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName())
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetDownloadURL(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req apiStruct.GetDownloadURLReq
|
|
||||||
resp apiStruct.GetDownloadURLResp
|
|
||||||
)
|
|
||||||
defer func() {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
}()
|
|
||||||
if err := c.Bind(&req); err != nil {
|
|
||||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
app, err := imdb.GetNewestVersion(req.Type)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "getNewestVersion failed", err.Error())
|
|
||||||
}
|
|
||||||
log.Debug(req.OperationID, utils.GetSelfFuncName(), "app: ", app)
|
|
||||||
if app != nil {
|
|
||||||
if app.Version != req.Version && app.Version != "" {
|
|
||||||
resp.Data.HasNewVersion = true
|
|
||||||
if app.ForceUpdate == true {
|
|
||||||
resp.Data.ForceUpdate = true
|
|
||||||
}
|
|
||||||
if app.YamlName != "" {
|
|
||||||
resp.Data.YamlURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + app.YamlName
|
|
||||||
}
|
|
||||||
resp.Data.FileURL = config.Config.Credential.Minio.Endpoint + "/" + config.Config.Credential.Minio.AppBucket + "/" + app.FileName
|
|
||||||
resp.Data.Version = app.Version
|
|
||||||
resp.Data.UpdateLog = app.UpdateLog
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
resp.Data.HasNewVersion = false
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 0, "errMsg": "not found app version"})
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,96 +0,0 @@
|
|||||||
package apiThird
|
|
||||||
|
|
||||||
import (
|
|
||||||
api "Open_IM/pkg/base_info"
|
|
||||||
"Open_IM/pkg/common/db"
|
|
||||||
"Open_IM/pkg/common/log"
|
|
||||||
"Open_IM/pkg/common/token_verify"
|
|
||||||
"Open_IM/pkg/utils"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
func GetRTCInvitationInfo(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.GetRTCInvitationInfoReq
|
|
||||||
resp api.GetRTCInvitationInfoResp
|
|
||||||
)
|
|
||||||
if err := c.Bind(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
ok, userID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var err error
|
|
||||||
invitationInfo, err := db.DB.GetSignalInfoFromCacheByClientMsgID(req.ClientMsgID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetSignalInfoFromCache", err.Error(), req)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := db.DB.DelUserSignalList(userID); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelUserSignalList result:", err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
resp.Data.OpUserID = invitationInfo.OpUserID
|
|
||||||
resp.Data.Invitation.RoomID = invitationInfo.Invitation.RoomID
|
|
||||||
resp.Data.Invitation.SessionType = invitationInfo.Invitation.SessionType
|
|
||||||
resp.Data.Invitation.GroupID = invitationInfo.Invitation.GroupID
|
|
||||||
resp.Data.Invitation.InviterUserID = invitationInfo.Invitation.InviterUserID
|
|
||||||
resp.Data.Invitation.InviteeUserIDList = invitationInfo.Invitation.InviteeUserIDList
|
|
||||||
resp.Data.Invitation.MediaType = invitationInfo.Invitation.MediaType
|
|
||||||
resp.Data.Invitation.Timeout = invitationInfo.Invitation.Timeout
|
|
||||||
resp.Data.Invitation.InitiateTime = invitationInfo.Invitation.InitiateTime
|
|
||||||
resp.Data.Invitation.PlatformID = invitationInfo.Invitation.PlatformID
|
|
||||||
resp.Data.Invitation.CustomData = invitationInfo.Invitation.CustomData
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetRTCInvitationInfoStartApp(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.GetRTCInvitationInfoStartAppReq
|
|
||||||
resp api.GetRTCInvitationInfoStartAppResp
|
|
||||||
)
|
|
||||||
if err := c.Bind(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, userID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
invitationInfo, err := db.DB.GetAvailableSignalInvitationInfo(userID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetSignalInfoFromCache", err.Error(), req)
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": err.Error(), "data": struct{}{}})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.Data.OpUserID = invitationInfo.OpUserID
|
|
||||||
resp.Data.Invitation.RoomID = invitationInfo.Invitation.RoomID
|
|
||||||
resp.Data.Invitation.SessionType = invitationInfo.Invitation.SessionType
|
|
||||||
resp.Data.Invitation.GroupID = invitationInfo.Invitation.GroupID
|
|
||||||
resp.Data.Invitation.InviterUserID = invitationInfo.Invitation.InviterUserID
|
|
||||||
resp.Data.Invitation.InviteeUserIDList = invitationInfo.Invitation.InviteeUserIDList
|
|
||||||
resp.Data.Invitation.MediaType = invitationInfo.Invitation.MediaType
|
|
||||||
resp.Data.Invitation.Timeout = invitationInfo.Invitation.Timeout
|
|
||||||
resp.Data.Invitation.InitiateTime = invitationInfo.Invitation.InitiateTime
|
|
||||||
resp.Data.Invitation.PlatformID = invitationInfo.Invitation.PlatformID
|
|
||||||
resp.Data.Invitation.CustomData = invitationInfo.Invitation.CustomData
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -22,18 +22,12 @@ func TencentCloudStorageCredential(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
var ok bool
|
|
||||||
var userID string
|
|
||||||
var errInfo string
|
|
||||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "TencentCloudStorageCredential args ", userID)
|
log.NewInfo(req.OperationID, "TencentCloudStorageCredential args ", userID)
|
||||||
|
|
||||||
cli := sts.NewClient(
|
cli := sts.NewClient(
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
cacheRpc "Open_IM/pkg/proto/cache"
|
|
||||||
pbRelay "Open_IM/pkg/proto/relay"
|
pbRelay "Open_IM/pkg/proto/relay"
|
||||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
rpc "Open_IM/pkg/proto/user"
|
rpc "Open_IM/pkg/proto/user"
|
||||||
@@ -19,134 +18,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetUsersInfoFromCache(c *gin.Context) {
|
|
||||||
params := api.GetUsersInfoReq{}
|
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(params.OperationID, "GetUsersInfoFromCache req: ", params)
|
|
||||||
req := &rpc.GetUserInfoReq{}
|
|
||||||
utils.CopyStructFields(req, ¶ms)
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewUserClient(etcdConn)
|
|
||||||
RpcResp, err := client.GetUserInfo(context.Background(), req)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, "GetUserInfo failed ", err.Error(), req.String())
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var publicUserInfoList []*open_im_sdk.PublicUserInfo
|
|
||||||
for _, v := range RpcResp.UserInfoList {
|
|
||||||
publicUserInfoList = append(publicUserInfoList,
|
|
||||||
&open_im_sdk.PublicUserInfo{UserID: v.UserID, Nickname: v.Nickname, FaceURL: v.FaceURL, Gender: v.Gender, Ex: v.Ex})
|
|
||||||
}
|
|
||||||
resp := api.GetUsersInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, UserInfoList: publicUserInfoList}
|
|
||||||
resp.Data = jsonData.JsonDataList(resp.UserInfoList)
|
|
||||||
log.NewInfo(req.OperationID, "GetUserInfo api return ", resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetFriendIDListFromCache(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.GetFriendIDListFromCacheReq
|
|
||||||
resp api.GetFriendIDListFromCacheResp
|
|
||||||
reqPb cacheRpc.GetFriendIDListFromCacheReq
|
|
||||||
respPb *cacheRpc.GetFriendIDListFromCacheResp
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
|
||||||
reqPb.OperationID = req.OperationID
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, reqPb.UserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := cacheRpc.NewCacheClient(etcdConn)
|
|
||||||
respPb, err := client.GetFriendIDListFromCache(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetFriendIDListFromCache", err.Error())
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed:" + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.UserIDList = respPb.UserIDList
|
|
||||||
resp.CommResp = api.CommResp{ErrMsg: respPb.CommonResp.ErrMsg, ErrCode: respPb.CommonResp.ErrCode}
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetBlackIDListFromCache(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req api.GetBlackIDListFromCacheReq
|
|
||||||
resp api.GetBlackIDListFromCacheResp
|
|
||||||
reqPb cacheRpc.GetBlackIDListFromCacheReq
|
|
||||||
respPb *cacheRpc.GetBlackIDListFromCacheResp
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(req.OperationID, "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.OperationID = req.OperationID
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, reqPb.UserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := cacheRpc.NewCacheClient(etcdConn)
|
|
||||||
respPb, err := client.GetBlackIDListFromCache(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetFriendIDListFromCache", err.Error())
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed:" + err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.UserIDList = respPb.UserIDList
|
|
||||||
resp.CommResp = api.CommResp{ErrMsg: respPb.CommonResp.ErrMsg, ErrCode: respPb.CommonResp.ErrCode}
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetUsersInfo(c *gin.Context) {
|
func GetUsersInfo(c *gin.Context) {
|
||||||
params := api.GetUsersInfoReq{}
|
params := api.GetUsersInfoReq{}
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
@@ -156,26 +27,16 @@ func GetUsersInfo(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.GetUserInfoReq{}
|
req := &rpc.GetUserInfoReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(params.OperationID, "GetUserInfo args ", req.String())
|
log.NewInfo(params.OperationID, "GetUserInfo args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewUserClient(etcdConn)
|
client := rpc.NewUserClient(etcdConn)
|
||||||
RpcResp, err := client.GetUserInfo(context.Background(), req)
|
RpcResp, err := client.GetUserInfo(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -204,24 +65,18 @@ func UpdateUserInfo(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.UpdateUserInfoReq{UserInfo: &open_im_sdk.UserInfo{}}
|
req := &rpc.UpdateUserInfoReq{UserInfo: &open_im_sdk.UserInfo{}}
|
||||||
utils.CopyStructFields(req.UserInfo, ¶ms)
|
utils.CopyStructFields(req.UserInfo, ¶ms)
|
||||||
|
|
||||||
req.OperationID = params.OperationID
|
req.OperationID = params.OperationID
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(params.OperationID, "UpdateUserInfo args ", req.String())
|
log.NewInfo(params.OperationID, "UpdateUserInfo args ", req.String())
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewUserClient(etcdConn)
|
client := rpc.NewUserClient(etcdConn)
|
||||||
RpcResp, err := client.UpdateUserInfo(context.Background(), req)
|
RpcResp, err := client.UpdateUserInfo(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -233,44 +88,6 @@ func UpdateUserInfo(c *gin.Context) {
|
|||||||
log.NewInfo(req.OperationID, "UpdateUserInfo api return ", resp)
|
log.NewInfo(req.OperationID, "UpdateUserInfo api return ", resp)
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
func SetGlobalRecvMessageOpt(c *gin.Context) {
|
|
||||||
params := api.SetGlobalRecvMessageOptReq{}
|
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req := &rpc.SetGlobalRecvMessageOptReq{}
|
|
||||||
utils.CopyStructFields(req, ¶ms)
|
|
||||||
req.OperationID = params.OperationID
|
|
||||||
var ok bool
|
|
||||||
var errInfo string
|
|
||||||
ok, req.UserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo(params.OperationID, "SetGlobalRecvMessageOpt args ", req.String())
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewUserClient(etcdConn)
|
|
||||||
RpcResp, err := client.SetGlobalRecvMessageOpt(context.Background(), req)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, "SetGlobalRecvMessageOpt failed ", err.Error(), req.String())
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp := api.UpdateUserInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
|
||||||
log.NewInfo(req.OperationID, "SetGlobalRecvMessageOpt api return ", resp)
|
|
||||||
c.JSON(http.StatusOK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetSelfUserInfo(c *gin.Context) {
|
func GetSelfUserInfo(c *gin.Context) {
|
||||||
params := api.GetSelfUserInfoReq{}
|
params := api.GetSelfUserInfoReq{}
|
||||||
@@ -282,27 +99,17 @@ func GetSelfUserInfo(c *gin.Context) {
|
|||||||
req := &rpc.GetUserInfoReq{}
|
req := &rpc.GetUserInfoReq{}
|
||||||
|
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
req.UserIDList = append(req.UserIDList, req.OpUserID)
|
req.UserIDList = append(req.UserIDList, req.OpUserID)
|
||||||
log.NewInfo(params.OperationID, "GetUserInfo args ", req.String())
|
log.NewInfo(params.OperationID, "GetUserInfo args ", req.String())
|
||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := rpc.NewUserClient(etcdConn)
|
client := rpc.NewUserClient(etcdConn)
|
||||||
RpcResp, err := client.GetUserInfo(context.Background(), req)
|
RpcResp, err := client.GetUserInfo(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -331,17 +138,13 @@ func GetUsersOnlineStatus(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &pbRelay.GetUsersOnlineStatusReq{}
|
req := &pbRelay.GetUsersOnlineStatusReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
log.NewError(req.OperationID, errMsg)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(config.Config.Manager.AppManagerUid) == 0 {
|
if len(config.Config.Manager.AppManagerUid) == 0 {
|
||||||
log.NewError(req.OperationID, "Manager == 0")
|
log.NewError(req.OperationID, "Manager == 0")
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "Manager == 0"})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "Manager == 0"})
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
apiStruct "Open_IM/pkg/cms_api_struct"
|
"Open_IM/pkg/cms_api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
openIMHttp "Open_IM/pkg/common/http"
|
openIMHttp "Open_IM/pkg/common/http"
|
||||||
@@ -10,56 +10,16 @@ import (
|
|||||||
pbAdmin "Open_IM/pkg/proto/admin_cms"
|
pbAdmin "Open_IM/pkg/proto/admin_cms"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"github.com/minio/minio-go/v7"
|
|
||||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
|
||||||
"net/http"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
url2 "net/url"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
minioClient *minio.Client
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
operationID := utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "minio config: ", config.Config.Credential.Minio)
|
|
||||||
var initUrl string
|
|
||||||
if config.Config.Credential.Minio.EndpointInnerEnable {
|
|
||||||
initUrl = config.Config.Credential.Minio.EndpointInner
|
|
||||||
} else {
|
|
||||||
initUrl = config.Config.Credential.Minio.Endpoint
|
|
||||||
}
|
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "use initUrl: ", initUrl)
|
|
||||||
minioUrl, err := url2.Parse(initUrl)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(operationID, utils.GetSelfFuncName(), "parse failed, please check config/config.yaml", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
opts := &minio.Options{
|
|
||||||
Creds: credentials.NewStaticV4(config.Config.Credential.Minio.AccessKeyID, config.Config.Credential.Minio.SecretAccessKey, ""),
|
|
||||||
}
|
|
||||||
if minioUrl.Scheme == "http" {
|
|
||||||
opts.Secure = false
|
|
||||||
} else if minioUrl.Scheme == "https" {
|
|
||||||
opts.Secure = true
|
|
||||||
}
|
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "Parse ok ", config.Config.Credential.Minio)
|
|
||||||
minioClient, err = minio.New(minioUrl.Host, opts)
|
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "new ok ", config.Config.Credential.Minio)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(operationID, utils.GetSelfFuncName(), "init minio client failed", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// register
|
// register
|
||||||
func AdminLogin(c *gin.Context) {
|
func AdminLogin(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req apiStruct.AdminLoginRequest
|
req cms_api_struct.AdminLoginRequest
|
||||||
resp apiStruct.AdminLoginResponse
|
resp cms_api_struct.AdminLoginResponse
|
||||||
reqPb pbAdmin.AdminLoginReq
|
reqPb pbAdmin.AdminLoginReq
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
@@ -69,14 +29,7 @@ func AdminLogin(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
reqPb.Secret = req.Secret
|
reqPb.Secret = req.Secret
|
||||||
reqPb.AdminID = req.AdminName
|
reqPb.AdminID = req.AdminName
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
||||||
respPb, err := client.AdminLogin(context.Background(), &reqPb)
|
respPb, err := client.AdminLogin(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import (
|
|||||||
commonPb "Open_IM/pkg/proto/sdk_ws"
|
commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
pbGroup "Open_IM/pkg/proto/group"
|
pbGroup "Open_IM/pkg/proto/group"
|
||||||
@@ -29,16 +28,8 @@ func GetGroupById(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
respPb, err := client.GetGroupById(context.Background(), &reqPb)
|
respPb, err := client.GetGroupById(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -53,7 +44,6 @@ func GetGroupById(c *gin.Context) {
|
|||||||
resp.GroupMasterName = respPb.CMSGroup.GroupMasterName
|
resp.GroupMasterName = respPb.CMSGroup.GroupMasterName
|
||||||
resp.GroupMasterId = respPb.CMSGroup.GroupMasterId
|
resp.GroupMasterId = respPb.CMSGroup.GroupMasterId
|
||||||
resp.IsBanChat = constant.GroupIsBanChat(respPb.CMSGroup.GroupInfo.Status)
|
resp.IsBanChat = constant.GroupIsBanChat(respPb.CMSGroup.GroupInfo.Status)
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,17 +58,9 @@ func GetGroups(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
reqPb.Pagination = &commonPb.RequestPagination{}
|
||||||
utils.CopyStructFields(&reqPb.Pagination, req)
|
utils.CopyStructFields(&reqPb.Pagination, req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
respPb, err := client.GetGroups(context.Background(), &reqPb)
|
respPb, err := client.GetGroups(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -101,7 +83,6 @@ func GetGroups(c *gin.Context) {
|
|||||||
resp.GroupNums = int(respPb.GroupNum)
|
resp.GroupNums = int(respPb.GroupNum)
|
||||||
resp.CurrentPage = int(respPb.Pagination.PageNumber)
|
resp.CurrentPage = int(respPb.Pagination.PageNumber)
|
||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,18 +97,10 @@ func GetGroupByName(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.GroupName = req.GroupName
|
reqPb.GroupName = req.GroupName
|
||||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
reqPb.Pagination = &commonPb.RequestPagination{}
|
||||||
utils.CopyStructFields(&reqPb.Pagination, req)
|
utils.CopyStructFields(&reqPb.Pagination, req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
respPb, err := client.GetGroup(context.Background(), &reqPb)
|
respPb, err := client.GetGroup(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -150,7 +123,6 @@ func GetGroupByName(c *gin.Context) {
|
|||||||
resp.CurrentPage = int(respPb.Pagination.PageNumber)
|
resp.CurrentPage = int(respPb.Pagination.PageNumber)
|
||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||||
resp.GroupNums = int(respPb.GroupNums)
|
resp.GroupNums = int(respPb.GroupNums)
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,8 +137,6 @@ func CreateGroup(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.GroupInfo = &commonPb.GroupInfo{}
|
reqPb.GroupInfo = &commonPb.GroupInfo{}
|
||||||
reqPb.GroupInfo.GroupName = req.GroupName
|
reqPb.GroupInfo.GroupName = req.GroupName
|
||||||
reqPb.GroupInfo.CreatorUserID = req.GroupMasterId
|
reqPb.GroupInfo.CreatorUserID = req.GroupMasterId
|
||||||
@@ -178,13 +148,7 @@ func CreateGroup(c *gin.Context) {
|
|||||||
RoleLevel: 1,
|
RoleLevel: 1,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
_, err := client.CreateGroup(context.Background(), &reqPb)
|
_, err := client.CreateGroup(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -205,18 +169,9 @@ func BanGroupChat(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
reqPb.Status = constant.GroupBanChat
|
reqPb.Status = constant.GroupBanChat
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -238,17 +193,9 @@ func BanPrivateChat(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
reqPb.Status = constant.GroupBanPrivateChat
|
reqPb.Status = constant.GroupBanPrivateChat
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -269,17 +216,9 @@ func OpenGroupChat(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
reqPb.Status = constant.GroupOk
|
reqPb.Status = constant.GroupOk
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -300,18 +239,9 @@ func OpenPrivateChat(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
reqPb.Status = constant.GroupOk
|
reqPb.Status = constant.GroupOk
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
_, err := client.OperateGroupStatus(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -333,21 +263,13 @@ func GetGroupMembers(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.Pagination = &commonPb.RequestPagination{
|
reqPb.Pagination = &commonPb.RequestPagination{
|
||||||
PageNumber: int32(req.PageNumber),
|
PageNumber: int32(req.PageNumber),
|
||||||
ShowNumber: int32(req.ShowNumber),
|
ShowNumber: int32(req.ShowNumber),
|
||||||
}
|
}
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
reqPb.UserName = req.UserName
|
reqPb.UserName = req.UserName
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
respPb, err := client.GetGroupMembersCMS(context.Background(), &reqPb)
|
respPb, err := client.GetGroupMembersCMS(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -368,7 +290,6 @@ func GetGroupMembers(c *gin.Context) {
|
|||||||
JoinTime: utils.UnixSecondToTime(int64(groupMembers.JoinTime)).String(),
|
JoinTime: utils.UnixSecondToTime(int64(groupMembers.JoinTime)).String(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -383,17 +304,9 @@ func AddGroupMembers(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationId = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.UserIds = req.Members
|
reqPb.UserIds = req.Members
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationId)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationId + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationId, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
respPb, err := client.AddGroupMembersCMS(context.Background(), &reqPb)
|
respPb, err := client.AddGroupMembersCMS(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -403,7 +316,6 @@ func AddGroupMembers(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp.Success = respPb.Success
|
resp.Success = respPb.Success
|
||||||
resp.Failed = respPb.Failed
|
resp.Failed = respPb.Failed
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,17 +330,9 @@ func RemoveGroupMembers(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.UserIds = req.Members
|
reqPb.UserIds = req.Members
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
respPb, err := client.RemoveGroupMembersCMS(context.Background(), &reqPb)
|
respPb, err := client.RemoveGroupMembersCMS(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -438,7 +342,6 @@ func RemoveGroupMembers(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
resp.Success = respPb.Success
|
resp.Success = respPb.Success
|
||||||
resp.Failed = respPb.Failed
|
resp.Failed = respPb.Failed
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,16 +356,8 @@ func DeleteGroup(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
_, err := client.DeleteGroup(context.Background(), &reqPb)
|
_, err := client.DeleteGroup(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -484,18 +379,10 @@ func SetGroupMaster(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
reqPb.UserId = req.UserId
|
reqPb.UserId = req.UserId
|
||||||
reqPb.RoleLevel = constant.GroupOwner
|
reqPb.RoleLevel = constant.GroupOwner
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
_, err := client.OperateUserRole(context.Background(), &reqPb)
|
_, err := client.OperateUserRole(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -517,18 +404,10 @@ func SetGroupOrdinaryUsers(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.GroupId = req.GroupId
|
reqPb.GroupId = req.GroupId
|
||||||
reqPb.UserId = req.UserId
|
reqPb.UserId = req.UserId
|
||||||
reqPb.RoleLevel = constant.GroupOrdinaryUsers
|
reqPb.RoleLevel = constant.GroupOrdinaryUsers
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
_, err := client.OperateUserRole(context.Background(), &reqPb)
|
_, err := client.OperateUserRole(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -545,8 +424,6 @@ func AlterGroupInfo(c *gin.Context) {
|
|||||||
_ cms_api_struct.SetGroupMasterResponse
|
_ cms_api_struct.SetGroupMasterResponse
|
||||||
reqPb pbGroup.SetGroupInfoReq
|
reqPb pbGroup.SetGroupInfoReq
|
||||||
)
|
)
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
@@ -561,13 +438,7 @@ func AlterGroupInfo(c *gin.Context) {
|
|||||||
FaceURL: req.ProfilePhoto,
|
FaceURL: req.ProfilePhoto,
|
||||||
GroupType: int32(req.GroupType),
|
GroupType: int32(req.GroupType),
|
||||||
}
|
}
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
_, err := client.SetGroupInfo(context.Background(), &reqPb)
|
_, err := client.SetGroupInfo(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import (
|
|||||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
@@ -22,14 +21,7 @@ func BroadcastMessage(c *gin.Context) {
|
|||||||
var (
|
var (
|
||||||
reqPb pbMessage.BoradcastMessageReq
|
reqPb pbMessage.BoradcastMessageReq
|
||||||
)
|
)
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
client := pbMessage.NewMessageCMSClient(etcdConn)
|
||||||
_, err := client.BoradcastMessage(context.Background(), &reqPb)
|
_, err := client.BoradcastMessage(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -44,14 +36,7 @@ func MassSendMassage(c *gin.Context) {
|
|||||||
var (
|
var (
|
||||||
reqPb pbMessage.MassSendMessageReq
|
reqPb pbMessage.MassSendMessageReq
|
||||||
)
|
)
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
client := pbMessage.NewMessageCMSClient(etcdConn)
|
||||||
_, err := client.MassSendMessage(context.Background(), &reqPb)
|
_, err := client.MassSendMessage(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -66,14 +51,7 @@ func WithdrawMessage(c *gin.Context) {
|
|||||||
var (
|
var (
|
||||||
reqPb pbMessage.WithdrawMessageReq
|
reqPb pbMessage.WithdrawMessageReq
|
||||||
)
|
)
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
client := pbMessage.NewMessageCMSClient(etcdConn)
|
||||||
_, err := client.WithdrawMessage(context.Background(), &reqPb)
|
_, err := client.WithdrawMessage(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -100,14 +78,7 @@ func GetChatLogs(c *gin.Context) {
|
|||||||
ShowNumber: int32(req.ShowNumber),
|
ShowNumber: int32(req.ShowNumber),
|
||||||
}
|
}
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
utils.CopyStructFields(&reqPb, &req)
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
client := pbMessage.NewMessageCMSClient(etcdConn)
|
||||||
respPb, err := client.GetChatLogs(context.Background(), &reqPb)
|
respPb, err := client.GetChatLogs(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -134,6 +105,5 @@ func GetChatLogs(c *gin.Context) {
|
|||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||||
resp.ChatLogsNum = int(respPb.ChatLogsNum)
|
resp.ChatLogsNum = int(respPb.ChatLogsNum)
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,16 +11,14 @@ import (
|
|||||||
|
|
||||||
func JWTAuth() gin.HandlerFunc {
|
func JWTAuth() gin.HandlerFunc {
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
ok, userID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), "")
|
ok, userID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), "")
|
||||||
log.NewInfo("0", utils.GetSelfFuncName(), "userID: ", userID)
|
log.NewInfo("0", utils.GetSelfFuncName(), "userID: ", userID)
|
||||||
c.Set("userID", userID)
|
c.Set("userID", userID)
|
||||||
if !ok {
|
if !ok {
|
||||||
log.NewError("", "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
log.NewError("","GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
c.Abort()
|
c.Abort()
|
||||||
http.RespHttp200(c, constant.ErrParseToken, nil)
|
http.RespHttp200(c, constant.ErrParseToken, nil)
|
||||||
return
|
return
|
||||||
} else {
|
|
||||||
log.NewInfo("0", utils.GetSelfFuncName(), "failed: ", errInfo)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
func NewGinRouter() *gin.Engine {
|
func NewGinRouter() *gin.Engine {
|
||||||
gin.SetMode(gin.ReleaseMode)
|
gin.SetMode(gin.ReleaseMode)
|
||||||
baseRouter := gin.Default()
|
baseRouter := gin.Default()
|
||||||
router := baseRouter.Group("/cms")
|
router := baseRouter.Group("/api")
|
||||||
router.Use(middleware.CorsHandler())
|
router.Use(middleware.CorsHandler())
|
||||||
adminRouterGroup := router.Group("/admin")
|
adminRouterGroup := router.Group("/admin")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import (
|
|||||||
pb "Open_IM/pkg/proto/statistics"
|
pb "Open_IM/pkg/proto/statistics"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -28,16 +27,8 @@ func GetMessagesStatistics(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
respPb, err := client.GetMessageStatistics(context.Background(), &reqPb)
|
respPb, err := client.GetMessageStatistics(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -66,7 +57,6 @@ func GetMessagesStatistics(c *gin.Context) {
|
|||||||
MessageNum: int(v.Num),
|
MessageNum: int(v.Num),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,20 +72,12 @@ func GetUserStatistics(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
respPb, err := client.GetUserStatistics(context.Background(), &reqPb)
|
respPb, err := client.GetUserStatistics(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetUserStatistics failed", err.Error())
|
log.NewError("0", utils.GetSelfFuncName(), "GetUserStatistics failed", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
openIMHttp.RespHttp200(c, err, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -130,7 +112,6 @@ func GetUserStatistics(c *gin.Context) {
|
|||||||
TotalUserNum: int(v.Num),
|
TotalUserNum: int(v.Num),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,16 +127,8 @@ func GetGroupStatistics(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
respPb, err := client.GetGroupStatistics(context.Background(), &reqPb)
|
respPb, err := client.GetGroupStatistics(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -187,7 +160,6 @@ func GetGroupStatistics(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,16 +175,8 @@ func GetActiveUser(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb.StatisticsReq, req)
|
utils.CopyStructFields(&reqPb.StatisticsReq, req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
respPb, err := client.GetActiveUser(context.Background(), &reqPb)
|
respPb, err := client.GetActiveUser(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -221,7 +185,6 @@ func GetActiveUser(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
utils.CopyStructFields(&resp.ActiveUserList, respPb.Users)
|
utils.CopyStructFields(&resp.ActiveUserList, respPb.Users)
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,20 +200,12 @@ func GetActiveGroup(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb.StatisticsReq, req)
|
utils.CopyStructFields(&reqPb.StatisticsReq, req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
respPb, err := client.GetActiveGroup(context.Background(), &reqPb)
|
respPb, err := client.GetActiveGroup(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetActiveGroup failed ", err.Error())
|
log.NewError("0", utils.GetSelfFuncName(), "GetActiveGroup failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
openIMHttp.RespHttp200(c, err, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -265,6 +220,5 @@ func GetActiveGroup(c *gin.Context) {
|
|||||||
MessageNum: int(group.MessageNum),
|
MessageNum: int(group.MessageNum),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,17 +29,8 @@ func GetUserById(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
utils.CopyStructFields(&reqPb, &req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
respPb, err := client.GetUserById(context.Background(), &reqPb)
|
respPb, err := client.GetUserById(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -52,18 +43,15 @@ func GetUserById(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
utils.CopyStructFields(&resp, respPb.User)
|
utils.CopyStructFields(&resp, respPb.User)
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUsersByName(c *gin.Context) {
|
func GetUsersByName(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetUsersByNameRequest
|
req cms_api_struct.GetUsersByNameRequest
|
||||||
resp cms_api_struct.GetUsersByNameResponse
|
resp cms_api_struct.GetUsersByNameResponse
|
||||||
reqPb pb.GetUsersByNameReq
|
reqPb pb.GetUsersByNameReq
|
||||||
)
|
)
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.ShouldBindQuery(&req); err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
@@ -74,13 +62,7 @@ func GetUsersByName(c *gin.Context) {
|
|||||||
PageNumber: int32(req.PageNumber),
|
PageNumber: int32(req.PageNumber),
|
||||||
ShowNumber: int32(req.ShowNumber),
|
ShowNumber: int32(req.ShowNumber),
|
||||||
}
|
}
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
respPb, err := client.GetUsersByName(context.Background(), &reqPb)
|
respPb, err := client.GetUsersByName(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -92,7 +74,6 @@ func GetUsersByName(c *gin.Context) {
|
|||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||||
resp.UserNums = respPb.UserNums
|
resp.UserNums = respPb.UserNums
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,16 +89,8 @@ func GetUsers(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb.Pagination, &req)
|
utils.CopyStructFields(&reqPb.Pagination, &req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
respPb, err := client.GetUsers(context.Background(), &reqPb)
|
respPb, err := client.GetUsers(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -128,7 +101,6 @@ func GetUsers(c *gin.Context) {
|
|||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||||
resp.UserNums = respPb.UserNums
|
resp.UserNums = respPb.UserNums
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -144,22 +116,14 @@ func ResignUser(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
utils.CopyStructFields(&reqPb, &req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
fmt.Println(reqPb.UserId)
|
||||||
if etcdConn == nil {
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
_, err := client.ResignUser(context.Background(), &reqPb)
|
_, err := client.ResignUser(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
openIMHttp.RespHttp200(c, err, resp)
|
openIMHttp.RespHttp200(c, err, resp)
|
||||||
}
|
}
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,20 +138,12 @@ func AlterUser(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
utils.CopyStructFields(&reqPb, &req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
_, err := client.AlterUser(context.Background(), &reqPb)
|
_, err := client.AlterUser(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, "microserver failed ", err.Error())
|
log.NewError("0", "microserver failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
openIMHttp.RespHttp200(c, err, nil)
|
||||||
}
|
}
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||||
@@ -203,16 +159,8 @@ func AddUser(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
utils.CopyStructFields(&reqPb, &req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
_, err := client.AddUser(context.Background(), &reqPb)
|
_, err := client.AddUser(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -234,16 +182,8 @@ func BlockUser(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
utils.CopyStructFields(&reqPb, &req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
fmt.Println(reqPb)
|
fmt.Println(reqPb)
|
||||||
_, err := client.BlockUser(context.Background(), &reqPb)
|
_, err := client.BlockUser(context.Background(), &reqPb)
|
||||||
@@ -265,23 +205,14 @@ func UnblockUser(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
utils.CopyStructFields(&reqPb, &req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
_, err := client.UnBlockUser(context.Background(), &reqPb)
|
_, err := client.UnBlockUser(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
openIMHttp.RespHttp200(c, err, resp)
|
openIMHttp.RespHttp200(c, err, resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,17 +229,9 @@ func GetBlockUsers(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb.Pagination, &req)
|
utils.CopyStructFields(&reqPb.Pagination, &req)
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "blockUsers", reqPb.Pagination, req)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "blockUsers", reqPb.Pagination, req)
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
respPb, err := client.GetBlockUsers(context.Background(), &reqPb)
|
respPb, err := client.GetBlockUsers(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -332,7 +255,6 @@ func GetBlockUsers(c *gin.Context) {
|
|||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||||
resp.UserNums = respPb.UserNums
|
resp.UserNums = respPb.UserNums
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,27 +269,18 @@ func GetBlockUserById(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.UserId = req.UserId
|
reqPb.UserId = req.UserId
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
respPb, err := client.GetBlockUserById(context.Background(), &reqPb)
|
respPb, err := client.GetBlockUserById(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, "GetBlockUserById rpc failed ", err.Error())
|
log.NewError("0", "GetBlockUserById rpc failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
openIMHttp.RespHttp200(c, err, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp.EndDisableTime = respPb.BlockUser.EndDisableTime
|
resp.EndDisableTime = respPb.BlockUser.EndDisableTime
|
||||||
resp.BeginDisableTime = respPb.BlockUser.BeginDisableTime
|
resp.BeginDisableTime = respPb.BlockUser.BeginDisableTime
|
||||||
utils.CopyStructFields(&resp, respPb.BlockUser.User)
|
utils.CopyStructFields(&resp, respPb.BlockUser.User)
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,20 +294,12 @@ func DeleteUser(c *gin.Context) {
|
|||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.UserId = req.UserId
|
reqPb.UserId = req.UserId
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
_, err := client.DeleteUser(context.Background(), &reqPb)
|
_, err := client.DeleteUser(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, "DeleteUser rpc failed ", err.Error())
|
log.NewError("0", "DeleteUser rpc failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
openIMHttp.RespHttp200(c, err, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,22 +42,16 @@ func Login(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if r.Password != params.Password {
|
if r.Password != params.Password {
|
||||||
log.NewError(params.OperationID, "password err", params.Password, account, r.Password, r.Account)
|
log.NewError(params.OperationID, "password err", params.Password, account, r.Password, r.Account)
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.PasswordErr, "errMsg": "password err"})
|
c.JSON(http.StatusOK, gin.H{"errCode": constant.PasswordErr, "errMsg": "password err"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var userID string
|
url := fmt.Sprintf("http://%s:10000/auth/user_token", utils.ServerIP)
|
||||||
if r.UserID != "" {
|
|
||||||
userID = r.UserID
|
|
||||||
} else {
|
|
||||||
userID = r.Account
|
|
||||||
}
|
|
||||||
url := fmt.Sprintf("http://%s:%d/auth/user_token", utils.ServerIP, config.Config.Api.GinPort[0])
|
|
||||||
openIMGetUserToken := api.UserTokenReq{}
|
openIMGetUserToken := api.UserTokenReq{}
|
||||||
openIMGetUserToken.OperationID = params.OperationID
|
openIMGetUserToken.OperationID = params.OperationID
|
||||||
openIMGetUserToken.Platform = params.Platform
|
openIMGetUserToken.Platform = params.Platform
|
||||||
openIMGetUserToken.Secret = config.Config.Secret
|
openIMGetUserToken.Secret = config.Config.Secret
|
||||||
openIMGetUserToken.UserID = userID
|
openIMGetUserToken.UserID = account
|
||||||
openIMGetUserTokenResp := api.UserTokenResp{}
|
openIMGetUserTokenResp := api.UserTokenResp{}
|
||||||
bMsg, err := http2.Post(url, openIMGetUserToken, 2)
|
bMsg, err := http2.Post(url, openIMGetUserToken, 2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user