mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-04-29 06:49:19 +08:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8cc4e30bae |
@@ -1,5 +1,4 @@
|
||||
# Open-IM-Server
|
||||

|
||||
|
||||

|
||||
|
||||
|
||||
+1
-1
Submodule cmd/Open-IM-SDK-Core updated: 1667b0f4e2...539290887a
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+27
-84
@@ -1,14 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "Open_IM/cmd/open_im_api/docs"
|
||||
apiAuth "Open_IM/internal/api/auth"
|
||||
clientInit "Open_IM/internal/api/client_init"
|
||||
apiChat "Open_IM/internal/api/chat"
|
||||
"Open_IM/internal/api/conversation"
|
||||
"Open_IM/internal/api/friend"
|
||||
"Open_IM/internal/api/group"
|
||||
"Open_IM/internal/api/manage"
|
||||
apiChat "Open_IM/internal/api/msg"
|
||||
"Open_IM/internal/api/office"
|
||||
"Open_IM/internal/api/organization"
|
||||
apiThird "Open_IM/internal/api/third"
|
||||
@@ -18,61 +16,32 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
//_ "github.com/razeencheng/demo-go/swaggo-gin/docs"
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
swaggerFiles "github.com/swaggo/files"
|
||||
ginSwagger "github.com/swaggo/gin-swagger"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
//"syscall"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
)
|
||||
|
||||
// @title open-IM-Server API
|
||||
// @version 1.0
|
||||
// @description open-IM-Server 的API服务器文档, 文档中所有请求都有一个operationID字段用于链路追踪
|
||||
|
||||
// @license.name Apache 2.0
|
||||
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
// @BasePath /
|
||||
func main() {
|
||||
log.NewPrivateLog(constant.LogFileName)
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
f, _ := os.Create("../logs/api.log")
|
||||
gin.DefaultWriter = io.MultiWriter(f)
|
||||
// gin.SetMode(gin.DebugMode)
|
||||
r := gin.New()
|
||||
r.Use(gin.Recovery())
|
||||
|
||||
r := gin.Default()
|
||||
r.Use(utils.CorsHandler())
|
||||
|
||||
log.Info("load config: ", config.Config)
|
||||
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
if config.Config.Prometheus.Enable {
|
||||
promePkg.NewApiRequestCounter()
|
||||
promePkg.NewApiRequestFailedCounter()
|
||||
promePkg.NewApiRequestSuccessCounter()
|
||||
r.Use(promePkg.PromeTheusMiddleware)
|
||||
r.GET("/metrics", promePkg.PrometheusHandler())
|
||||
}
|
||||
// user routing group, which handles user registration and login services
|
||||
userRouterGroup := r.Group("/user")
|
||||
{
|
||||
userRouterGroup.POST("/update_user_info", user.UpdateUserInfo) //1
|
||||
userRouterGroup.POST("/set_global_msg_recv_opt", user.SetGlobalRecvMessageOpt)
|
||||
userRouterGroup.POST("/get_users_info", user.GetUsersPublicInfo) //1
|
||||
userRouterGroup.POST("/update_user_info", user.UpdateUserInfo) //1
|
||||
userRouterGroup.POST("/get_users_info", user.GetUsersInfo) //1
|
||||
userRouterGroup.POST("/get_self_user_info", user.GetSelfUserInfo) //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)
|
||||
userRouterGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1
|
||||
userRouterGroup.POST("/account_check", manage.AccountCheck) //1
|
||||
// userRouterGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1
|
||||
userRouterGroup.POST("/get_users", user.GetUsers)
|
||||
}
|
||||
//friend routing group
|
||||
friendRouterGroup := r.Group("/friend")
|
||||
@@ -98,41 +67,33 @@ func main() {
|
||||
{
|
||||
groupRouterGroup.POST("/create_group", group.CreateGroup) //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("/group_application_response", group.ApplicationGroupResponse) //1
|
||||
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner) //1
|
||||
groupRouterGroup.POST("/get_recv_group_applicationList", group.GetRecvGroupApplicationList) //1
|
||||
groupRouterGroup.POST("/get_user_req_group_applicationList", group.GetUserReqGroupApplicationList)
|
||||
groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1
|
||||
groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1
|
||||
// groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use
|
||||
groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1
|
||||
groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1
|
||||
groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use
|
||||
groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1
|
||||
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1
|
||||
groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1
|
||||
groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList)
|
||||
groupRouterGroup.POST("/dismiss_group", group.DismissGroup) //
|
||||
groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList) //1
|
||||
groupRouterGroup.POST("/dismiss_group", group.DismissGroup) //
|
||||
groupRouterGroup.POST("/mute_group_member", group.MuteGroupMember)
|
||||
groupRouterGroup.POST("/cancel_mute_group_member", group.CancelMuteGroupMember) //MuteGroup
|
||||
groupRouterGroup.POST("/mute_group", group.MuteGroup)
|
||||
groupRouterGroup.POST("/cancel_mute_group", group.CancelMuteGroup)
|
||||
|
||||
groupRouterGroup.POST("/set_group_member_nickname", group.SetGroupMemberNickname)
|
||||
groupRouterGroup.POST("/set_group_member_info", group.SetGroupMemberInfo)
|
||||
groupRouterGroup.POST("/get_group_abstract_info", group.GetGroupAbstractInfo)
|
||||
//groupRouterGroup.POST("/get_group_all_member_list_by_split", group.GetGroupAllMemberListBySplit)
|
||||
}
|
||||
superGroupRouterGroup := r.Group("/super_group")
|
||||
{
|
||||
superGroupRouterGroup.POST("/get_joined_group_list", group.GetJoinedSuperGroupList)
|
||||
superGroupRouterGroup.POST("/get_groups_info", group.GetSuperGroupsInfo)
|
||||
|
||||
}
|
||||
//certificate
|
||||
authRouterGroup := r.Group("/auth")
|
||||
{
|
||||
authRouterGroup.POST("/user_register", apiAuth.UserRegister) //1
|
||||
authRouterGroup.POST("/user_token", apiAuth.UserToken) //1
|
||||
authRouterGroup.POST("/parse_token", apiAuth.ParseToken) //1
|
||||
authRouterGroup.POST("/force_logout", apiAuth.ForceLogout) //1
|
||||
}
|
||||
//Third service
|
||||
thirdGroup := r.Group("/third")
|
||||
@@ -141,13 +102,6 @@ func main() {
|
||||
thirdGroup.POST("/ali_oss_credential", apiThird.AliOSSCredential)
|
||||
thirdGroup.POST("/minio_storage_credential", apiThird.MinioStorageCredential)
|
||||
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)
|
||||
thirdGroup.POST("/fcm_update_token", apiThird.FcmUpdateToken)
|
||||
thirdGroup.POST("/aws_storage_credential", apiThird.AwsStorageCredential)
|
||||
thirdGroup.POST("/set_app_badge", apiThird.SetAppBadge)
|
||||
}
|
||||
//Message
|
||||
chatGroup := r.Group("/msg")
|
||||
@@ -156,12 +110,15 @@ func main() {
|
||||
chatGroup.POST("/send_msg", apiChat.SendMsg)
|
||||
chatGroup.POST("/pull_msg_by_seq", apiChat.PullMsgBySeqList)
|
||||
chatGroup.POST("/del_msg", apiChat.DelMsg)
|
||||
chatGroup.POST("/del_super_group_msg", apiChat.DelSuperGroupMsg)
|
||||
chatGroup.POST("/clear_msg", apiChat.ClearMsg)
|
||||
chatGroup.POST("/manage_send_msg", manage.ManagementSendMsg)
|
||||
chatGroup.POST("/batch_send_msg", manage.ManagementBatchSendMsg)
|
||||
chatGroup.POST("/check_msg_is_send_success", manage.CheckMsgIsSendSuccess)
|
||||
chatGroup.POST("/set_msg_min_seq", apiChat.SetMsgMinSeq)
|
||||
}
|
||||
//Manager
|
||||
managementGroup := r.Group("/manager")
|
||||
{
|
||||
managementGroup.POST("/delete_user", manage.DeleteUser) //1
|
||||
managementGroup.POST("/send_msg", manage.ManagementSendMsg)
|
||||
managementGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1
|
||||
managementGroup.POST("/account_check", manage.AccountCheck) //1
|
||||
managementGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1
|
||||
}
|
||||
//Conversation
|
||||
conversationGroup := r.Group("/conversation")
|
||||
@@ -172,7 +129,6 @@ func main() {
|
||||
conversationGroup.POST("/set_conversation", conversation.SetConversation)
|
||||
conversationGroup.POST("/batch_set_conversation", conversation.BatchSetConversations)
|
||||
conversationGroup.POST("/set_recv_msg_opt", conversation.SetRecvMsgOpt)
|
||||
conversationGroup.POST("/modify_conversation_field", conversation.ModifyConversationField)
|
||||
}
|
||||
// office
|
||||
officeGroup := r.Group("/office")
|
||||
@@ -193,7 +149,6 @@ func main() {
|
||||
officeGroup.POST("/get_user_work_moments", office.GetUserWorkMoments)
|
||||
officeGroup.POST("/get_user_friend_work_moments", office.GetUserFriendWorkMoments)
|
||||
officeGroup.POST("/set_user_work_moments_level", office.SetUserWorkMomentsLevel)
|
||||
officeGroup.POST("/delete_comment", office.DeleteComment)
|
||||
}
|
||||
|
||||
organizationGroup := r.Group("/organization")
|
||||
@@ -217,24 +172,12 @@ func main() {
|
||||
|
||||
}
|
||||
|
||||
initGroup := r.Group("/init")
|
||||
{
|
||||
initGroup.POST("/set_client_config", clientInit.SetClientInitConfig)
|
||||
initGroup.POST("/get_client_config", clientInit.GetClientInitConfig)
|
||||
}
|
||||
|
||||
go apiThird.MinioInit()
|
||||
defaultPorts := config.Config.Api.GinPort
|
||||
ginPort := flag.Int("port", defaultPorts[0], "get ginServerPort from cmd,default 10002 as port")
|
||||
ginPort := flag.Int("port", 10000, "get ginServerPort from cmd,default 10000 as port")
|
||||
flag.Parse()
|
||||
address := "0.0.0.0:" + strconv.Itoa(*ginPort)
|
||||
if config.Config.Api.ListenIP != "" {
|
||||
address = config.Config.Api.ListenIP + ":" + strconv.Itoa(*ginPort)
|
||||
}
|
||||
fmt.Println("start api server, address: ", address, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
err := r.Run(address)
|
||||
fmt.Println("start api server, port: ", *ginPort)
|
||||
err := r.Run(":" + strconv.Itoa(*ginPort))
|
||||
if err != nil {
|
||||
log.Error("", "api run failed ", address, err.Error())
|
||||
panic("api start failed " + err.Error())
|
||||
log.Error("", "run failed ", *ginPort, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/cms_api"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/utils"
|
||||
"flag"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"Open_IM/pkg/common/config"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -17,14 +12,6 @@ func main() {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
router := cms_api.NewGinRouter()
|
||||
router.Use(utils.CorsHandler())
|
||||
defaultPorts := config.Config.CmsApi.GinPort
|
||||
ginPort := flag.Int("port", defaultPorts[0], "get ginServerPort from cmd,default 10006 as port")
|
||||
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, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
router.Run(address)
|
||||
fmt.Println("start cms api server, port: ", 8000)
|
||||
router.Run(":" + "8000")
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/cron_task"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("start cronTask")
|
||||
cronTask.StartCronTask()
|
||||
}
|
||||
@@ -9,12 +9,8 @@ import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -23,57 +19,23 @@ func main() {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
f, _ := os.Create("../logs/api.log")
|
||||
gin.DefaultWriter = io.MultiWriter(f)
|
||||
|
||||
r := gin.Default()
|
||||
r.Use(utils.CorsHandler())
|
||||
if config.Config.Prometheus.Enable {
|
||||
r.GET("/metrics", promePkg.PrometheusHandler())
|
||||
}
|
||||
authRouterGroup := r.Group("/demo")
|
||||
|
||||
authRouterGroup := r.Group("/auth")
|
||||
{
|
||||
authRouterGroup.POST("/code", register.SendVerificationCode)
|
||||
authRouterGroup.POST("/verify", register.Verify)
|
||||
authRouterGroup.POST("/password", register.SetPassword)
|
||||
authRouterGroup.POST("/login", register.Login)
|
||||
authRouterGroup.POST("/reset_password", register.ResetPassword)
|
||||
authRouterGroup.POST("/check_login", register.CheckLoginLimit)
|
||||
}
|
||||
demoRouterGroup := r.Group("/auth")
|
||||
{
|
||||
demoRouterGroup.POST("/code", register.SendVerificationCode)
|
||||
demoRouterGroup.POST("/verify", register.Verify)
|
||||
demoRouterGroup.POST("/password", register.SetPassword)
|
||||
demoRouterGroup.POST("/login", register.Login)
|
||||
demoRouterGroup.POST("/reset_password", register.ResetPassword)
|
||||
demoRouterGroup.POST("/check_login", register.CheckLoginLimit)
|
||||
}
|
||||
|
||||
//deprecated
|
||||
cmsRouterGroup := r.Group("/cms_admin")
|
||||
{
|
||||
cmsRouterGroup.POST("/generate_invitation_code", register.GenerateInvitationCode)
|
||||
cmsRouterGroup.POST("/query_invitation_code", register.QueryInvitationCode)
|
||||
cmsRouterGroup.POST("/get_invitation_codes", register.GetInvitationCodes)
|
||||
|
||||
cmsRouterGroup.POST("/query_user_ip_limit_login", register.QueryUserIDLimitLogin)
|
||||
cmsRouterGroup.POST("/add_user_ip_limit_login", register.AddUserIPLimitLogin)
|
||||
cmsRouterGroup.POST("/remove_user_ip_limit_login", register.RemoveUserIPLimitLogin)
|
||||
|
||||
cmsRouterGroup.POST("/query_ip_register", register.QueryIPRegister)
|
||||
cmsRouterGroup.POST("/add_ip_limit", register.AddIPLimit)
|
||||
cmsRouterGroup.POST("/remove_ip_Limit", register.RemoveIPLimit)
|
||||
}
|
||||
defaultPorts := config.Config.Demo.Port
|
||||
ginPort := flag.Int("port", defaultPorts[0], "get ginServerPort from cmd,default 10004 as port")
|
||||
ginPort := flag.Int("port", 42233, "get ginServerPort from cmd,default 42233 as port")
|
||||
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 demo api server address: ", address, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
go register.OnboardingProcessRoutine()
|
||||
go register.ImportFriendRoutine()
|
||||
err := r.Run(address)
|
||||
fmt.Println("start demo api server, port: ", *ginPort)
|
||||
err := r.Run(":" + strconv.Itoa(*ginPort))
|
||||
if err != nil {
|
||||
log.Error("", "run failed ", *ginPort, err.Error())
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/msg_gateway/gate"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"flag"
|
||||
@@ -12,17 +11,13 @@ import (
|
||||
|
||||
func main() {
|
||||
log.NewPrivateLog(constant.LogFileName)
|
||||
defaultRpcPorts := config.Config.RpcPort.OpenImMessageGatewayPort
|
||||
defaultWsPorts := config.Config.LongConnSvr.WebsocketPort
|
||||
defaultPromePorts := config.Config.Prometheus.MessageGatewayPrometheusPort
|
||||
rpcPort := flag.Int("rpc_port", defaultRpcPorts[0], "rpc listening port")
|
||||
wsPort := flag.Int("ws_port", defaultWsPorts[0], "ws listening port")
|
||||
prometheusPort := flag.Int("prometheus_port", defaultPromePorts[0], "PushrometheusPort default listen port")
|
||||
rpcPort := flag.Int("rpc_port", 10400, "rpc listening port")
|
||||
wsPort := flag.Int("ws_port", 17778, "ws listening port")
|
||||
flag.Parse()
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
fmt.Println("start rpc/msg_gateway server, port: ", *rpcPort, *wsPort, *prometheusPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
fmt.Println("start rpc/msg_gateway server, port: ", *rpcPort, *wsPort)
|
||||
gate.Init(*rpcPort, *wsPort)
|
||||
gate.Run(*prometheusPort)
|
||||
gate.Run()
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
@@ -2,10 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/msg_transfer/logic"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"flag"
|
||||
"fmt"
|
||||
"sync"
|
||||
)
|
||||
@@ -13,11 +11,9 @@ import (
|
||||
func main() {
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.MessageTransferPrometheusPort[0], "MessageTransferPrometheusPort default listen port")
|
||||
flag.Parse()
|
||||
log.NewPrivateLog(constant.LogFileName)
|
||||
logic.Init()
|
||||
fmt.Println("start msg_transfer server ", "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
logic.Run(*prometheusPort)
|
||||
fmt.Println("start msg_transfer server")
|
||||
logic.Run()
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/push/logic"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"flag"
|
||||
@@ -11,15 +10,13 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImPushPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.MessageTransferPrometheusPort[0], "PushrometheusPort default listen port")
|
||||
rpcPort := flag.Int("port", 10700, "rpc listening port")
|
||||
flag.Parse()
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
log.NewPrivateLog(constant.LogFileName)
|
||||
fmt.Println("start push rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
fmt.Println("start push rpc server, port: ", *rpcPort)
|
||||
logic.Init(*rpcPort)
|
||||
logic.Run(*prometheusPort)
|
||||
logic.Run()
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_cron_task
|
||||
BINARY_NAME=open_im_timer_task
|
||||
BIN_DIR=../../bin/
|
||||
|
||||
all: gotool build
|
||||
@@ -21,3 +21,5 @@ install:
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
||||
|
||||
|
||||
@@ -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,25 +2,14 @@ package main
|
||||
|
||||
import (
|
||||
rpcMessageCMS "Open_IM/internal/rpc/admin_cms"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImAdminCmsPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.AdminCmsPrometheusPort[0], "adminCMSPrometheusPort default listen port")
|
||||
rpcPort := flag.Int("port", 11000, "rpc listening port")
|
||||
flag.Parse()
|
||||
fmt.Println("start cms rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
fmt.Println("start cms rpc server, port: ", *rpcPort)
|
||||
rpcServer := rpcMessageCMS.NewAdminCMSServer(*rpcPort)
|
||||
go func() {
|
||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
rpcServer.Run()
|
||||
}
|
||||
|
||||
@@ -2,25 +2,15 @@ package main
|
||||
|
||||
import (
|
||||
rpcAuth "Open_IM/internal/rpc/auth"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImAuthPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "RpcToken default listen port 10800")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.AuthPrometheusPort[0], "authPrometheusPort default listen port")
|
||||
rpcPort := flag.Int("port", 10600, "RpcToken default listen port 10800")
|
||||
flag.Parse()
|
||||
fmt.Println("start auth rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
fmt.Println("start auth rpc server, port: ", *rpcPort)
|
||||
rpcServer := rpcAuth.NewRpcAuthServer(*rpcPort)
|
||||
go func() {
|
||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
rpcServer.Run()
|
||||
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
rpcCache "Open_IM/internal/rpc/cache"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImCachePort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "RpcToken default listen port 10800")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.CachePrometheusPort[0], "cachePrometheusPort default listen port")
|
||||
flag.Parse()
|
||||
fmt.Println("start cache rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
rpcServer := rpcCache.NewCacheServer(*rpcPort)
|
||||
go func() {
|
||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
rpcServer.Run()
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
rpcConversation "Open_IM/internal/rpc/conversation"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImConversationPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "RpcConversation default listen port 11300")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.ConversationPrometheusPort[0], "conversationPrometheusPort default listen port")
|
||||
flag.Parse()
|
||||
fmt.Println("start conversation rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
rpcServer := rpcConversation.NewRpcConversationServer(*rpcPort)
|
||||
go func() {
|
||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
rpcServer.Run()
|
||||
|
||||
}
|
||||
@@ -2,25 +2,15 @@ package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/rpc/friend"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImFriendPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "get RpcFriendPort from cmd,default 12000 as port")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.FriendPrometheusPort[0], "friendPrometheusPort default listen port")
|
||||
|
||||
rpcPort := flag.Int("port", 10200, "get RpcFriendPort from cmd,default 12000 as port")
|
||||
flag.Parse()
|
||||
fmt.Println("start friend rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
fmt.Println("start friend rpc server, port: ", *rpcPort)
|
||||
rpcServer := friend.NewFriendServer(*rpcPort)
|
||||
go func() {
|
||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
rpcServer.Run()
|
||||
}
|
||||
|
||||
@@ -2,25 +2,14 @@ package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/rpc/group"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImGroupPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "get RpcGroupPort from cmd,default 16000 as port")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.GroupPrometheusPort[0], "groupPrometheusPort default listen port")
|
||||
rpcPort := flag.Int("port", 10500, "get RpcGroupPort from cmd,default 16000 as port")
|
||||
flag.Parse()
|
||||
fmt.Println("start group rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
fmt.Println("start group rpc server, port: ", *rpcPort)
|
||||
rpcServer := group.NewGroupServer(*rpcPort)
|
||||
go func() {
|
||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
rpcServer.Run()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_conversation
|
||||
BINARY_NAME=open_im_message_cms
|
||||
BIN_DIR=../../../bin/
|
||||
|
||||
all: gotool build
|
||||
@@ -21,4 +21,3 @@ install:
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
rpcMessageCMS "Open_IM/internal/rpc/message_cms"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcPort := flag.Int("port", 10900, "rpc listening port")
|
||||
flag.Parse()
|
||||
fmt.Println("start msg cms rpc server, port: ", *rpcPort)
|
||||
rpcServer := rpcMessageCMS.NewMessageCMSServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
}
|
||||
@@ -1,26 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/rpc/msg"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
rpcChat "Open_IM/internal/rpc/msg"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImMessagePort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.MessagePrometheusPort[0], "msgPrometheusPort default listen port")
|
||||
rpcPort := flag.Int("port", 10300, "rpc listening port")
|
||||
flag.Parse()
|
||||
fmt.Println("start msg rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
rpcServer := msg.NewRpcChatServer(*rpcPort)
|
||||
go func() {
|
||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
fmt.Println("start msg rpc server, port: ", *rpcPort)
|
||||
rpcServer := rpcChat.NewRpcChatServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
}
|
||||
|
||||
@@ -2,25 +2,14 @@ package main
|
||||
|
||||
import (
|
||||
rpc "Open_IM/internal/rpc/office"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImOfficePort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.OfficePrometheusPort[0], "officePrometheusPort default listen port")
|
||||
rpcPort := flag.Int("port", 11100, "rpc listening port")
|
||||
flag.Parse()
|
||||
fmt.Println("start office rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
fmt.Println("start office rpc server, port: ", *rpcPort)
|
||||
rpcServer := rpc.NewOfficeServer(*rpcPort)
|
||||
go func() {
|
||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
rpcServer.Run()
|
||||
}
|
||||
|
||||
@@ -2,25 +2,14 @@ package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/rpc/organization"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImOrganizationPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "get RpcOrganizationPort from cmd,default 11200 as port")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.OrganizationPrometheusPort[0], "organizationPrometheusPort default listen port")
|
||||
rpcPort := flag.Int("port", 11200, "get RpcOrganizationPort from cmd,default 11200 as port")
|
||||
flag.Parse()
|
||||
fmt.Println("start organization rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
fmt.Println("start organization rpc server, port: ", *rpcPort)
|
||||
rpcServer := organization.NewServer(*rpcPort)
|
||||
go func() {
|
||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
rpcServer.Run()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_cache
|
||||
BINARY_NAME=open_im_statistics
|
||||
BIN_DIR=../../../bin/
|
||||
|
||||
all: gotool build
|
||||
@@ -21,4 +21,3 @@ install:
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/rpc/statistics"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcPort := flag.Int("port", 10800, "rpc listening port")
|
||||
flag.Parse()
|
||||
fmt.Println("start statistics rpc server, port: ", *rpcPort)
|
||||
rpcServer := statistics.NewStatisticsServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
}
|
||||
@@ -2,25 +2,14 @@ package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/rpc/user"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
promePkg "Open_IM/pkg/common/prometheus"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultPorts := config.Config.RpcPort.OpenImUserPort
|
||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
||||
prometheusPort := flag.Int("prometheus_port", config.Config.Prometheus.UserPrometheusPort[0], "userPrometheusPort default listen port")
|
||||
rpcPort := flag.Int("port", 10100, "rpc listening port")
|
||||
flag.Parse()
|
||||
fmt.Println("start user rpc server, port: ", *rpcPort, "OpenIM version: ", constant.CurrentVersion, "\n")
|
||||
fmt.Println("start user rpc server, port: ", *rpcPort)
|
||||
rpcServer := user.NewUserServer(*rpcPort)
|
||||
go func() {
|
||||
err := promePkg.StartPromeSrv(*prometheusPort)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
rpcServer.Run()
|
||||
}
|
||||
|
||||
+55
-182
@@ -1,16 +1,11 @@
|
||||
# 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,
|
||||
# and it will not be read naturally.
|
||||
serverversion: 2.3.1
|
||||
serverversion: 2.0.0
|
||||
#---------------Infrastructure configuration---------------------#
|
||||
etcd:
|
||||
etcdSchema: openim #默认即可
|
||||
etcdSchema: openIM #默认即可
|
||||
etcdAddr: [ 127.0.0.1:2379 ] #单机部署时,默认即可
|
||||
userName:
|
||||
password:
|
||||
|
||||
k8sMod: false #开启k8s模式 使用pod里面环境变量请求services调用服务 而并非etcd
|
||||
|
||||
mysql:
|
||||
dbMysqlAddress: [ 127.0.0.1:13306 ] #mysql地址 目前仅支持单机,默认即可
|
||||
@@ -19,53 +14,38 @@ mysql:
|
||||
dbMysqlDatabaseName: openIM_v2 #默认即可
|
||||
dbTableName: eMsg #默认即可
|
||||
dbMsgTableNum: 1
|
||||
dbMaxOpenConns: 100
|
||||
dbMaxOpenConns: 20
|
||||
dbMaxIdleConns: 10
|
||||
dbMaxLifeTime: 5
|
||||
logLevel: 1 #1=slient 2=error 3=warn 4=info
|
||||
slowThreshold: 500
|
||||
dbMaxLifeTime: 120
|
||||
|
||||
mongo:
|
||||
dbUri: ""#当dbUri值不为空则直接使用该值
|
||||
#dbAddress: 127.0.0.1:37017 #单机时为mongo地址,使用分片集群时,为mongos地址 默认即可
|
||||
dbAddress: [ 127.0.0.1:37017 ] #单机时为mongo地址,使用分片集群时,为mongos地址 默认即可
|
||||
dbAddress: [ 127.0.0.1:37017 ] #mongo地址 目前仅支持单机,默认即可
|
||||
dbDirect: false
|
||||
dbTimeout: 60
|
||||
dbTimeout: 10
|
||||
dbDatabase: openIM #mongo db 默认即可
|
||||
dbSource: admin
|
||||
dbUserName: #mongo用户名,建议先不设置
|
||||
dbPassword: #mongo密码,建议先不设置
|
||||
dbMaxPoolSize: 100
|
||||
dbUserName: #mongo用户名,建议先不设置
|
||||
dbPassword: #mongo密码,建议先不设置
|
||||
dbMaxPoolSize: 20
|
||||
dbRetainChatRecords: 3650 #mongo保存离线消息时间(天),根据需求修改
|
||||
chatRecordsClearTime: "* * * * *" # 每天凌晨3点清除消息,该配置和linux定时任务一样, 清理操作建议设置在用户活跃少的时候 # 0 3 * * *
|
||||
|
||||
redis:
|
||||
dbAddress: [ 127.0.0.1:16379 ] #redis地址 单机时,填写一个地址即可,使用redis集群时候,填写集群中多个节点地址(主从地址都可以填写,增加容灾能力),默认即可
|
||||
dbAddress: 127.0.0.1:16379 #redis地址 目前仅支持单机,默认即可
|
||||
dbMaxIdle: 128
|
||||
dbMaxActive: 0
|
||||
dbIdleTimeout: 120
|
||||
dbUserName: #only redis version 6.0+ need username
|
||||
dbPassWord: openIM #redis密码 建议修改
|
||||
enableCluster: false #如果外部redis以集群方式启动,需要打开此开关
|
||||
|
||||
kafka:
|
||||
SASLUserName:
|
||||
SASLPassword:
|
||||
ws2mschat:
|
||||
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||
topic: "ws2ms_chat" #用于mongo和mysql保存消息
|
||||
# ws2mschatoffline:
|
||||
# addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||
# topic: "ws2ms_chat_offline" #原为离线用户消息处理,目前暂时弃用
|
||||
msgtomongo:
|
||||
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||
topic: "msg_to_mongo"
|
||||
topic: "ws2ms_chat"
|
||||
ms2pschat:
|
||||
addr: [ 127.0.0.1:9092 ] #kafka配置,默认即可
|
||||
topic: "ms2ps_chat" #消息push
|
||||
topic: "ms2ps_chat"
|
||||
consumergroupid:
|
||||
msgToTransfer: mongo
|
||||
msgToMongo: mongo_ex
|
||||
msgToMongo: mongo
|
||||
msgToMySql: mysql
|
||||
msgToPush: push
|
||||
|
||||
@@ -79,11 +59,6 @@ kafka:
|
||||
#如果是单机模式,用0.0.0.0或者不填,默认即可
|
||||
serverip: 0.0.0.0
|
||||
|
||||
#作为rpc时,注册到etcd的地址,单机默认即可,如果是集群部署,需要修改(具体使用内网地址还是外网地址,要依情况而定,目的是api/gateway能访问到)
|
||||
rpcRegisterIP:
|
||||
#默认即可
|
||||
listenIP: 0.0.0.0
|
||||
|
||||
# endpoints 内部组件间访问的端点host名称,访问时,可以内部直接访问 host:port 来访问
|
||||
endpoints:
|
||||
api: openim_api
|
||||
@@ -95,40 +70,33 @@ endpoints:
|
||||
rpc_group: openim_rpc_group
|
||||
rpc_msg: openim_rpc_msg
|
||||
rpc_user: openim_rpc_user
|
||||
rpc_statistic: openim_rpc_statistic
|
||||
rpc_admin_cms: openim_rpc_admin_cms
|
||||
rpc_message_cms: openim_rpc_admin_cms
|
||||
rpc_office: openim_rpc_office
|
||||
|
||||
api:
|
||||
openImApiPort: [ 10002 ] #api服务端口,默认即可,需要开放此端口或做nginx转发
|
||||
listenIP: 0.0.0.0
|
||||
openImApiPort: [ 10000 ] #api服务端口,默认即可,需要开放此端口或做nginx转发
|
||||
cmsapi:
|
||||
openImCmsApiPort: [ 10006 ] #管理后台api服务端口,默认即可,需要开放此端口或做nginx转发
|
||||
listenIP: 0.0.0.0
|
||||
openImCmsApiPort: [ 8000 ] #管理后台api服务端口,默认即可,需要开放此端口或做nginx转发
|
||||
sdk:
|
||||
openImSdkWsPort: [ 10003 ] #jssdk服务端口,默认即可,项目中使用jssdk才需开放此端口或做nginx转发
|
||||
dataDir: [ ../db/sdk/ ]
|
||||
openImWsAddress: ws://127.0.0.1:10001
|
||||
openImApiAddress: http://127.0.0.1:10002
|
||||
|
||||
openImSdkWsPort: [ 30000 ] #jssdk服务端口,默认即可,项目中使用jssdk才需开放此端口或做nginx转发
|
||||
#对象存储服务,以下配置二选一,目前支持两种,腾讯云和minio,二者配置好其中一种即可(如果使用minio参考https://doc.rentsoft.cn/#/qa/minio搭建minio服务器)
|
||||
credential: #腾讯cos,发送图片、视频、文件时需要,请自行申请后替换,必须修改
|
||||
tencent:
|
||||
appID: 1302656840
|
||||
region: ap-chengdu
|
||||
bucket: echat-1302656840
|
||||
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC1
|
||||
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe1
|
||||
secretID: AKIDGNYVChzIQinu7QEgtNp0hnNgqcV8vZTC
|
||||
secretKey: kz15vW83qM6dBUWIq681eBZA0c0vlIbe
|
||||
minio: #MinIO 发送图片、视频、文件时需要,请自行申请后替换,必须修改。 客户端初始化InitSDK,中 object_storage参数为minio
|
||||
bucket: openim # 存储内容桶
|
||||
appBucket: app # 存储app的桶
|
||||
bucket: openim
|
||||
location: us-east-1
|
||||
endpoint: http://127.0.0.1:10005 #minio外网ip 这个ip是给客户端访问的
|
||||
endpointInner: http://127.0.0.1:10005 #minio内网地址 如果im server 可以通过内网访问到 minio就可以
|
||||
endpoint: http://127.0.0.1:9000 #minio外网ip 这个ip是给客户端访问的
|
||||
endpointInner: http://127.0.0.1:9000 #minio内网地址 如果im server 可以通过内网访问到 minio就可以填写
|
||||
endpointInnerEnable: true #是否启用minio内网地址 启用可以让桶初始化,IM server连接minio走内网地址访问
|
||||
accessKeyID: user12345
|
||||
secretAccessKey: key12345
|
||||
storageTime: 50 #文件在minio中保存的时间
|
||||
isDistributedMod: false # 是否分布式多硬盘部署 默认docker-compose中为false
|
||||
ali: # ali oss
|
||||
regionID: "oss-cn-beijing"
|
||||
accessKeyID: ""
|
||||
@@ -139,33 +107,22 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申
|
||||
finalHost: "http://bucket1.oss-cn-beijing.aliyuncs.com"
|
||||
stsDurationSeconds: 3600
|
||||
OssRoleArn: "acs:ram::xxx:role/xxx"
|
||||
aws:
|
||||
accessKeyID: 1 #AssumeRole用户关联的accessKeyID
|
||||
accessKeySecret: 2 #AssumeRole用户关联的accessKeySecrect
|
||||
region: ap-southeast-1 #分区
|
||||
bucket: ouyang #桶
|
||||
finalHost: ouyang.s3.ap-southeast-1.amazonaws.com #对外Host
|
||||
roleArn: arn:aws:iam::192209831083:role/AWS_S3_FOR_OUYANG #RoleArn
|
||||
externalId: AssumeRoleExtend #角色扩展Id
|
||||
roleSessionName: Required-AWS-ID-OPENIM #角色SESSION名称
|
||||
|
||||
dtm:
|
||||
serverURL: 127.0.0.1:10007
|
||||
|
||||
|
||||
rpcport: #rpc服务端口 默认即可
|
||||
openImUserPort: [ 10110 ]
|
||||
openImFriendPort: [ 10120 ]
|
||||
openImMessagePort: [ 10130 ]
|
||||
openImMessageGatewayPort: [ 10140 ]
|
||||
openImGroupPort: [ 10150 ]
|
||||
openImAuthPort: [ 10160 ]
|
||||
openImPushPort: [ 10170 ]
|
||||
openImAdminCmsPort: [ 10200 ]
|
||||
openImOfficePort: [ 10210 ]
|
||||
openImOrganizationPort: [ 10220 ]
|
||||
openImConversationPort: [ 10230 ]
|
||||
openImCachePort: [ 10240 ]
|
||||
openImRealTimeCommPort: [ 11300 ]
|
||||
openImUserPort: [ 10100 ]
|
||||
openImFriendPort: [ 10200 ]
|
||||
openImOfflineMessagePort: [ 10300 ]
|
||||
openImOnlineRelayPort: [ 10400 ]
|
||||
openImGroupPort: [ 10500 ]
|
||||
openImAuthPort: [ 10600 ]
|
||||
openImPushPort: [ 10700 ]
|
||||
openImStatisticsPort: [ 10800 ]
|
||||
openImMessageCmsPort: [ 10900 ]
|
||||
openImAdminCmsPort: [ 11000 ]
|
||||
openImOfficePort: [ 11100 ]
|
||||
openImOrganizationPort: [ 11200 ]
|
||||
c2c:
|
||||
callbackBeforeSendMsg:
|
||||
switch: false
|
||||
@@ -179,21 +136,21 @@ rpcport: #rpc服务端口 默认即可
|
||||
rpcregistername: #rpc注册服务名,默认即可
|
||||
openImUserName: User
|
||||
openImFriendName: Friend
|
||||
openImMsgName: Msg
|
||||
openImOfflineMessageName: OfflineMessage
|
||||
openImPushName: Push
|
||||
openImRelayName: Relay
|
||||
openImOnlineMessageRelayName: OnlineMessageRelay
|
||||
openImGroupName: Group
|
||||
openImAuthName: Auth
|
||||
OpenImStatisticsName: Statistics
|
||||
OpenImMessageCMSName: MessageCMS
|
||||
openImAdminCMSName: AdminCMS
|
||||
openImOfficeName: Office
|
||||
openImOrganizationName: Organization
|
||||
openImConversationName: Conversation
|
||||
openImCacheName: Cache
|
||||
openImRealTimeCommName: RealTimeComm
|
||||
|
||||
log:
|
||||
storageLocation: ../logs/
|
||||
rotationTime: 24
|
||||
remainRotationCount: 2 #日志数量
|
||||
remainRotationCount: 3 #日志数量
|
||||
#日志级别 6表示全都打印,测试阶段建议设置为6
|
||||
remainLogLevel: 6
|
||||
elasticSearchSwitch: false
|
||||
@@ -207,7 +164,7 @@ modulename: #日志文件按模块命名,默认即可
|
||||
pushName: push
|
||||
|
||||
longconnsvr:
|
||||
openImWsPort: [ 10001 ] # ws服务端口,默认即可,要开放此端口或做nginx转发
|
||||
openImWsPort: [ 17778 ] # ws服务端口,默认即可,要开放此端口或做nginx转发
|
||||
websocketMaxConnNum: 10000
|
||||
websocketMaxMsgLen: 4096
|
||||
websocketTimeOut: 10
|
||||
@@ -228,17 +185,12 @@ push:
|
||||
pushUrl: "https://api.jpush.cn/v3/push"
|
||||
pushIntent: "intent:#Intent;component=io.openim.app.enterprisechat/io.openim.app.enterprisechat.MainActivity;end"
|
||||
enable: true
|
||||
getui: #个推推送
|
||||
getui: #个推推送,暂未测试 暂不要使用
|
||||
pushUrl: "https://restapi.getui.com/v2/$appId"
|
||||
masterSecret: ""
|
||||
appKey: ""
|
||||
intent: ""
|
||||
enable: false
|
||||
channelID: ""
|
||||
channelName: ""
|
||||
fcm: #firebase cloud message 消息推送
|
||||
serviceAccount: "openim-5c6c0-firebase-adminsdk-ppwol-8765884a78.json" #帐号文件,此处需要改修配置,并且这个文件放在 config目录下
|
||||
enable: false
|
||||
|
||||
|
||||
|
||||
@@ -246,29 +198,20 @@ manager:
|
||||
#app管理员userID和对应的secret 建议修改。 用于管理后台登录,也可以用户管理后台对应的api
|
||||
appManagerUid: [ "openIM123456","openIM654321", "openIM333", "openIMAdmin"]
|
||||
secrets: [ "openIM1","openIM2", "openIM333", "openIMAdmin"]
|
||||
appSysNotificationName: "系统通知"
|
||||
|
||||
secret: tuoyun
|
||||
# 多端互踢策略
|
||||
# 1:多平台登录:Android、iOS、Windows、Mac 每种平台只能一个在线,web端可以多个同时在线
|
||||
multiloginpolicy: 1
|
||||
|
||||
#msg log insert to db
|
||||
chatpersistencemysql: true
|
||||
#可靠性存储
|
||||
reliablestorage: false
|
||||
#消息缓存时间
|
||||
msgCacheTimeout: 86400
|
||||
#群聊已读开启
|
||||
groupMessageHasReadReceiptEnable: true
|
||||
#单聊已读开启
|
||||
singleMessageHasReadReceiptEnable: true
|
||||
#chat log insert to db
|
||||
chatPersistenceMysql: true
|
||||
|
||||
#token config
|
||||
tokenpolicy:
|
||||
accessSecret: "open_im_server" #token生成相关,默认即可
|
||||
# Token effective time day as a unit
|
||||
accessExpire: 90 #token过期时间(天) 默认即可
|
||||
accessExpire: 3650 #token过期时间(天) 默认即可
|
||||
messageverify:
|
||||
friendVerify: false
|
||||
|
||||
@@ -285,13 +228,12 @@ messageverify:
|
||||
iospush:
|
||||
pushSound: "xxx"
|
||||
badgeCount: true
|
||||
production: false
|
||||
|
||||
callback:
|
||||
# callback url 需要自行更换callback url
|
||||
callbackUrl : "http://127.0.0.1:8080/callback"
|
||||
# 开启关闭操作前后回调的配置
|
||||
callbackBeforeSendSingleMsg:
|
||||
callbackbeforeSendSingleMsg:
|
||||
enable: false # 回调是否启用
|
||||
callbackTimeOut: 2 # 回调超时时间
|
||||
callbackFailedContinue: true # 回调超时是否继续执行代码
|
||||
@@ -309,27 +251,6 @@ callback:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackFailedContinue: true
|
||||
callbackUserOnline:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackUserOffline:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackUserKickOff:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackOfflinePush:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackFailedContinue: true # 回调超时是否继续离线推送
|
||||
callbackOnlinePush:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackFailedContinue: true # 回调超时是否继续离线推送
|
||||
callbackSuperGroupOnlinePush:
|
||||
enable: false
|
||||
callbackTimeOut: 2
|
||||
callbackFailedContinue: true # 回调超时是否继续离线推送
|
||||
|
||||
|
||||
notification:
|
||||
@@ -379,7 +300,7 @@ notification:
|
||||
desc: "memberQuit desc"
|
||||
ext: "memberQuit ext"
|
||||
defaultTips:
|
||||
tips: "quit group msg" # group info changed by xx
|
||||
tips: "quit group chat" # group info changed by xx
|
||||
|
||||
groupApplicationAccepted:
|
||||
conversation:
|
||||
@@ -667,7 +588,7 @@ notification:
|
||||
#####################conversation#########################
|
||||
conversationOptUpdate:
|
||||
conversation:
|
||||
reliabilityLevel: 1
|
||||
reliabilityLevel: 2
|
||||
unreadCount: false
|
||||
offlinePush:
|
||||
switch: true
|
||||
@@ -704,77 +625,29 @@ notification:
|
||||
openTips: "burn after reading was opened"
|
||||
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---------------------#
|
||||
#The following configuration items are applied to openIM Demo configuration
|
||||
#是否启动demo,如果自身没有账号体系,设置为true
|
||||
demoswitch: true
|
||||
demo:
|
||||
listenIP: 0.0.0.0
|
||||
#demo对外服务端口,默认即可,需要开放此端口或做nginx转发
|
||||
openImDemoPort: [ 10004 ]
|
||||
alismsverify: #阿里云短信配置,在阿里云申请成功后修改以下四项,enable为true则必须修改,阿里云为默认短信验证方式
|
||||
openImDemoPort: [ 42233 ]
|
||||
alismsverify: #阿里云短信配置,在阿里云申请成功后修改以下四项,必须修改
|
||||
accessKeyId: LTAI5tJPkn4HuuePdiLdGqe7
|
||||
accessKeySecret: 4n9OJ7ZCVN1U6KeHDAtOyNeVZcjOuV
|
||||
signName: 托云信息技术
|
||||
verificationCodeTemplateCode: SMS_226810164
|
||||
enable: false
|
||||
tencentsms: #腾讯云短信配置,在腾讯云申请成功后,修改以下选项,enable为true则必须修改
|
||||
appID: 2400000648
|
||||
region: "ap-singapore"
|
||||
secretID: IKIDra4JPGsFMDwQedMq42lESQBgwwgBQQAe
|
||||
secretKey: HI6fz4uUotjJdiX6QUIrAE2buxlKdgU2
|
||||
signName: ""
|
||||
verificationCodeTemplateCode: 2902877
|
||||
enable: true
|
||||
superCode: 666666 #超级验证码,建议修改掉,收不到短信验证码时可以用此替代
|
||||
needInvitationCode: false
|
||||
# second
|
||||
codeTTL: 60
|
||||
useSuperCode: true
|
||||
codeTTL: 300
|
||||
mail: #仅支持qq邮箱,具体操作参考 https://service.mail.qq.com/cgi-bin/help?subtype=1&id=28&no=1001256 必须修改
|
||||
title: "openIM"
|
||||
senderMail: "765567899@qq.com"
|
||||
senderAuthorizationCode: "gxyausfoevlzbfag"
|
||||
smtpAddr: "smtp.qq.com"
|
||||
smtpPort: 25 #需开放此端口 出口方向
|
||||
testDepartMentID: 001
|
||||
imAPIURL: http://127.0.0.1:10002
|
||||
onboardProcess: false # 是否开启注册流程
|
||||
createOrganizationUserAndJoinDepartment: false
|
||||
joinDepartmentIDList: [] # 用户注册进来默认加的部门ID列表 不填就随机
|
||||
joinDepartmentGroups: false # 注册是否加部门群
|
||||
oaNotification: false # 注册是否发送OA通知
|
||||
|
||||
rtc:
|
||||
signalTimeout: 35
|
||||
|
||||
# prometheus每个服务监听的端口数量需要和rpc port保持一致
|
||||
prometheus:
|
||||
enable: false
|
||||
userPrometheusPort: [ 20110 ]
|
||||
friendPrometheusPort: [ 20120 ]
|
||||
messagePrometheusPort: [ 20130 ]
|
||||
messageGatewayPrometheusPort: [ 20140 ]
|
||||
groupPrometheusPort: [ 20150 ]
|
||||
authPrometheusPort: [ 20160 ]
|
||||
pushPrometheusPort: [ 20170 ]
|
||||
adminCmsPrometheusPort: [ 20200 ]
|
||||
officePrometheusPort: [ 20210 ]
|
||||
organizationPrometheusPort: [ 20220 ]
|
||||
conversationPrometheusPort: [ 20230 ]
|
||||
cachePrometheusPort: [ 20240 ]
|
||||
realTimeCommPrometheusPort: [ 21300 ]
|
||||
messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] # 端口数量和 script/path_info.cfg msg_transfer_service_num保持一致
|
||||
port: 11300
|
||||
address: 127.0.0.1
|
||||
@@ -6,7 +6,6 @@ ENV CONFIG_NAME $WORKDIR/config/config.yaml
|
||||
|
||||
# 将可执行文件复制到目标目录
|
||||
ADD ./open_im_api $WORKDIR/main
|
||||
COPY ./start_api.sh $$WORKDIR
|
||||
|
||||
# 创建用于挂载的几个目录,添加可执行权限
|
||||
RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
|
||||
@@ -14,4 +13,4 @@ RUN mkdir $WORKDIR/logs $WORKDIR/config $WORKDIR/db && \
|
||||
|
||||
|
||||
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,35 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: admin-cms-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: admin-cms # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: admin-cms # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: admin-cms
|
||||
image: openim/admin_cms:v2.3.0release
|
||||
# imagePullPolicy: Always #每次启动都重新拉取镜像
|
||||
ports:
|
||||
- containerPort: 10200
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-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,48 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: api-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: api # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: api # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: api
|
||||
image: openim/api:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10002
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-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,19 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
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 $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,34 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: auth-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: auth # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: auth # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: auth
|
||||
image: openim/auth:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10160
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
@@ -1,30 +0,0 @@
|
||||
#/bin/sh
|
||||
source ./path_info.cfg
|
||||
|
||||
# images version
|
||||
version=v2.2.0
|
||||
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
|
||||
|
||||
Vendored
-19
@@ -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_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 $CMDDIR
|
||||
CMD ./main
|
||||
Vendored
-34
@@ -1,34 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: cache-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: cache # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: cache # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: cache
|
||||
image: openim/cache:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10240
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
@@ -1,18 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
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 $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,48 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: cms-api-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: cms-api # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: cms-api # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: cms-api
|
||||
image: openim/cms_api:v2.3.0release
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10006
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-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,18 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
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 $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,36 +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.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10230
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-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_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 $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,48 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: demo-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: demo # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: demo # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: demo
|
||||
image: openim/demo:v2.3.0release
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10004
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-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,35 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: friend-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: friend # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: friend # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: friend
|
||||
image: openim/friend:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10120
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-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_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 $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,34 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: group-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: group # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: group # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: group
|
||||
image: openim/group:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10150
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-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_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 $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,119 +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"
|
||||
nginx.ingress.kubernetes.io/Access-Control-Allow-Origin: '*'
|
||||
nginx.ingress.kubernetes.io/cors-allow-headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,x-auth-token,Pagination
|
||||
nginx.ingress.kubernetes.io/cors-allow-methods: 'PUT, GET, POST, OPTIONS'
|
||||
nginx.ingress.kubernetes.io/cors-allow-origin: '*'
|
||||
nginx.ingress.kubernetes.io/enable-cors: 'true'
|
||||
nginx.ingress.kubernetes.io/service-weight: ''
|
||||
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"
|
||||
nginx.ingress.kubernetes.io/Access-Control-Allow-Origin: '*'
|
||||
nginx.ingress.kubernetes.io/cors-allow-headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,x-auth-token,Pagination
|
||||
nginx.ingress.kubernetes.io/cors-allow-methods: 'PUT, GET, POST, OPTIONS'
|
||||
nginx.ingress.kubernetes.io/cors-allow-origin: '*'
|
||||
nginx.ingress.kubernetes.io/enable-cors: 'true'
|
||||
nginx.ingress.kubernetes.io/service-weight: ''
|
||||
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"
|
||||
nginx.ingress.kubernetes.io/Access-Control-Allow-Origin: '*'
|
||||
nginx.ingress.kubernetes.io/cors-allow-headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,x-auth-token,Pagination
|
||||
nginx.ingress.kubernetes.io/cors-allow-methods: 'PUT, GET, POST, OPTIONS'
|
||||
nginx.ingress.kubernetes.io/cors-allow-origin: '*'
|
||||
nginx.ingress.kubernetes.io/enable-cors: 'true'
|
||||
nginx.ingress.kubernetes.io/service-weight: ''
|
||||
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,99 +0,0 @@
|
||||
#### openIM k8s部署文档
|
||||
### 1. 修改配置文件
|
||||
在Open-IM-SERVER根目录下修改config/config.yaml配置文件, 请确保以下修改的所有地址必须保证k8s pod能够访问
|
||||
1. 修改ETCD配置为自己的ETCD ip地址, 最好和k8s本身使用的ETCD分开
|
||||
2. 修改MySQL配置
|
||||
3. 修改Mongo配置
|
||||
4. 修改Redis配置
|
||||
5. 修改Kafka配置
|
||||
6. 将rpcRegisterIP修改为空, 此地址为每个rpc注册到ETCD的地址, 置空每个rpc将会将pod地址注册到ETCD, 才能正确rpc请求(重要)
|
||||
7. 如果使用minio作为对象存储, 还需要修改minio的地址
|
||||
8. 其他如果使用离线推送,需要修改push离线推送配置
|
||||
9. 修改demo中的imAPIURL字段为openIM api的ingress或者service地址, 需要让demo的pod能正确请求到(重要)
|
||||
10. 其他非必须配置修改, 如短信,推送等
|
||||
|
||||
### 2. 项目根目录创建im configMap到k8s openim namespace
|
||||
1. 为open-IM项目创建单独命名空间
|
||||
```
|
||||
kubectl create namespace openim
|
||||
```
|
||||
2. 在项目根目录通过config/config.yaml
|
||||
```
|
||||
kubectl -n openim create configmap config --from-file=config/config.yaml
|
||||
```
|
||||
查看configmap
|
||||
```
|
||||
kubectl -n openim get configmap
|
||||
```
|
||||
|
||||
### 3(可选). 修改每个deployment.yml
|
||||
每个rpc的deployment在Open-IM-SERVER根目录deploy_k8s下
|
||||
给需要调度的node打上标签
|
||||
```
|
||||
kubectl get nodes
|
||||
kubectl label node k8s-node1 role=openIMworker
|
||||
```
|
||||
在deployment的spec.template.spec加上
|
||||
```
|
||||
nodeSelector:
|
||||
role: openIMworker
|
||||
```
|
||||
创建资源清单时添加上nodeSelector属性对应即可,
|
||||
修改每种服务数量,建议至少每种2个rpc。
|
||||
如果修改了config/config.yaml某些配置比如端口,同时需要修改对应deployment端口和ingress端口
|
||||
|
||||
|
||||
### 4. 修改ingress.yaml配置文件
|
||||
1. 需要安装ingress controller, 这里使用的是ingress-nginx, 使用其他类型的ingress controller需要更改ingress.class, 将host改为自己部署服务的host
|
||||
|
||||
### 5. 执行./kubectl_start.sh脚本
|
||||
1. 脚本给予可执行权限
|
||||
```
|
||||
chmod +x ./kubectl_start.sh ./kubectl_stop.sh
|
||||
```
|
||||
2. 启动k8s service和deployment
|
||||
```
|
||||
./kubectl_start.sh
|
||||
```
|
||||
3. 启动k8s ingress
|
||||
```
|
||||
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
|
||||
```
|
||||
检测服务可达
|
||||
```
|
||||
telnet msg-gateway.openim.xxx.com {{your_ingress_port}}
|
||||
telnet sdk-server.openim.xxx.com {{your_ingress_port}}
|
||||
telnet api.openim.xxx.com {{your_ingress_port}}
|
||||
telnet cms-api.openim.xxx.com {{your_ingress_port}}
|
||||
telnet demo.openim.xxx.com {{your_ingress_port}}
|
||||
```
|
||||
|
||||
#### openIM k8s更新
|
||||
1. 暂存配置文件,拉取代码
|
||||
```
|
||||
git stash push config/config.yaml
|
||||
git pull
|
||||
```
|
||||
2. 合并配置文件, 解决冲突
|
||||
```
|
||||
git stash pop
|
||||
```
|
||||
3. 重新生成configmap
|
||||
```
|
||||
kubectl -n openim create configmap config --from-file=config/config.yaml
|
||||
```
|
||||
4.修改所有deployment文件的spec.template.spec.image 改为新版本后在/deploy_k8s下重新执行
|
||||
```
|
||||
./kubectl_stop.sh
|
||||
./kubectl_start.sh
|
||||
```
|
||||
@@ -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,36 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
service=(
|
||||
#api service file
|
||||
api
|
||||
cms-api
|
||||
#rpc service file
|
||||
user
|
||||
friend
|
||||
group
|
||||
auth
|
||||
admin-cms
|
||||
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,34 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: msg-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: msg # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: msg # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: msg
|
||||
image: openim/msg:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10130
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
@@ -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_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 $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,53 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: msg-gateway-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: msg-gateway # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: msg-gateway # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: msg-gateway
|
||||
image: openim/msg_gateway:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- name: rpc-port
|
||||
containerPort: 10140
|
||||
- name: ws-port
|
||||
containerPort: 10001
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-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,19 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
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 $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,32 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: msg-transfer-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: msg-transfer # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: msg-transfer # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: msg-transfer
|
||||
image: openim/msg_transfer:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-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_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 $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,34 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: office-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: office # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: office # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: office
|
||||
image: openim/office:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10210
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
@@ -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_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 $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,34 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: organization-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: organization # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: organization # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: organization
|
||||
image: openim/organization:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10220
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
@@ -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_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 $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,22 +0,0 @@
|
||||
#/bin/sh
|
||||
service=(
|
||||
#api service file
|
||||
api
|
||||
cms_api
|
||||
#rpc service file
|
||||
user
|
||||
friend
|
||||
group
|
||||
auth
|
||||
admin_cms
|
||||
office
|
||||
organization
|
||||
conversation
|
||||
cache
|
||||
msg_gateway
|
||||
msg_transfer
|
||||
msg
|
||||
push
|
||||
sdk_server
|
||||
demo
|
||||
)
|
||||
@@ -1,34 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: push-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: push # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: push # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: push
|
||||
image: openim/push:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10170
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-config
|
||||
strategy: #更新策略
|
||||
type: RollingUpdate # 滚动更新
|
||||
@@ -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_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 $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,57 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: sdk-server-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: sdk-server # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: sdk-server # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: sdk-server
|
||||
image: openim/sdk_server:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 10003
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
- name: local-db
|
||||
mountPath: /db/sdk
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
command: ["/Open-IM-Server/main"]
|
||||
args: ["-openIM_ws_address", "ws_addr", "-sdk_ws_port", "10001", "-openIM_api_address", "api_address", "-openIM_log_level", "6"]
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-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,18 +0,0 @@
|
||||
FROM ubuntu
|
||||
|
||||
# 设置固定的项目路径
|
||||
ENV WORKDIR /Open-IM-Server
|
||||
ENV CMDDIR $WORKDIR/cmd
|
||||
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 $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,32 +0,0 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: user-deployment
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: user # 选择这个指定标签执行
|
||||
replicas: 1 # 运行pod数量
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: user # 标签
|
||||
spec:
|
||||
containers:
|
||||
- name: user
|
||||
image: openim/user:v2.3.0release
|
||||
# imagePullPolicy: Always
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /Open-IM-Server/config
|
||||
readOnly: true
|
||||
env:
|
||||
- name: CONFIG_NAME
|
||||
value: "/Open-IM-Server"
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: openim-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_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 $CMDDIR
|
||||
CMD ./main
|
||||
@@ -1,139 +0,0 @@
|
||||
version: "3"
|
||||
#fixme Clone openIM Server project before using docker-compose,project address:https://github.com/OpenIMSDK/Open-IM-Server.git
|
||||
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:5.7
|
||||
ports:
|
||||
- 13306:3306
|
||||
- 23306:33060
|
||||
container_name: mysql
|
||||
volumes:
|
||||
- ./components/mysql/data:/var/lib/mysql
|
||||
- /etc/localtime:/etc/localtime
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: openIM
|
||||
restart: always
|
||||
|
||||
mongos:
|
||||
image: mongo:latest
|
||||
ports:
|
||||
- 37017:27017
|
||||
container_name: mongos
|
||||
command: mongos --configdb config/103.116.45.174:27019 --bind_ip_all
|
||||
volumes:
|
||||
- ./components/mongos_mongodb/data/db:/data/db
|
||||
- ./components/mongos_mongodb/data/logs:/data/logs
|
||||
- ./components/mongos_mongodb/data/conf:/etc/mongo
|
||||
- ./components/mongos_mongodb/data/configdb:/data/configdb
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
# cache
|
||||
- wiredTigerCacheSizeGB=1
|
||||
# environment:
|
||||
# - MONGO_INITDB_ROOT_USERNAME=openIM
|
||||
# - MONGO_INITDB_ROOT_PASSWORD=openIM
|
||||
|
||||
|
||||
#TZ: Asia/Shanghai
|
||||
restart: always
|
||||
|
||||
|
||||
redis:
|
||||
image: redis
|
||||
ports:
|
||||
- 16379:6379
|
||||
container_name: redis
|
||||
volumes:
|
||||
- ./components/redis/data:/data
|
||||
#redis config file
|
||||
- ./components/redis/config/redis.conf:/usr/local/redis/config/redis.conf
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
restart: always
|
||||
sysctls:
|
||||
net.core.somaxconn: 1024
|
||||
command: redis-server --requirepass openIM --appendonly yes
|
||||
|
||||
|
||||
zookeeper:
|
||||
image: wurstmeister/zookeeper
|
||||
ports:
|
||||
- 2181:2181
|
||||
container_name: zookeeper
|
||||
volumes:
|
||||
- /etc/localtime:/etc/localtime
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
restart: always
|
||||
|
||||
|
||||
kafka:
|
||||
image: wurstmeister/kafka
|
||||
container_name: kafka
|
||||
restart: always
|
||||
ports:
|
||||
- 9092:9092
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
KAFKA_BROKER_ID: 0
|
||||
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
||||
KAFKA_CREATE_TOPICS: "ws2ms_chat:8:1,ms2ps_chat:8:1,msg_to_mongo:8:1"
|
||||
KAFKA_ADVERTISED_LISTENERS: INSIDE://127.0.0.1:9092,OUTSIDE://103.116.45.174:9092
|
||||
KAFKA_LISTENERS: INSIDE://:9092,OUTSIDE://:9093
|
||||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT"
|
||||
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
|
||||
depends_on:
|
||||
- zookeeper
|
||||
|
||||
etcd:
|
||||
image: quay.io/coreos/etcd
|
||||
ports:
|
||||
- 2379:2379
|
||||
- 2380:2380
|
||||
container_name: etcd
|
||||
volumes:
|
||||
- /etc/timezone:/etc/timezone
|
||||
- /etc/localtime:/etc/localtime
|
||||
environment:
|
||||
ETCDCTL_API: 3
|
||||
restart: always
|
||||
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
|
||||
|
||||
minio:
|
||||
image: minio/minio
|
||||
ports:
|
||||
- 10005:9000
|
||||
- 9090:9090
|
||||
container_name: minio
|
||||
volumes:
|
||||
- /mnt/data:/data
|
||||
- /mnt/config:/root/.minio
|
||||
environment:
|
||||
MINIO_ROOT_USER: user12345
|
||||
MINIO_ROOT_PASSWORD: key12345
|
||||
restart: always
|
||||
command: minio server /data --console-address ':9090'
|
||||
|
||||
open_im_server:
|
||||
image: openim/open_im_server:v2.3.0-rc1
|
||||
container_name: open_im_server
|
||||
volumes:
|
||||
- ./logs:/Open-IM-Server/logs
|
||||
- ./config/config.yaml:/Open-IM-Server/config/config.yaml
|
||||
- ./db/sdk:/Open-IM-Server/db/sdk
|
||||
- ./script:/Open-IM-Server/script
|
||||
restart: always
|
||||
depends_on:
|
||||
- kafka
|
||||
- mysql
|
||||
- mongos
|
||||
- redis
|
||||
- etcd
|
||||
- minio
|
||||
network_mode: "host"
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "1g"
|
||||
max-file: "2"
|
||||
@@ -1,113 +0,0 @@
|
||||
version: '3'
|
||||
networks:
|
||||
mongo-network:
|
||||
external: false
|
||||
services:
|
||||
# 配置服务器configsvr
|
||||
config:
|
||||
image: mongo:latest
|
||||
networks:
|
||||
- mongo-network
|
||||
container_name: config
|
||||
restart: always
|
||||
ports:
|
||||
- 27019:27019
|
||||
command: --configsvr --replSet "config" --bind_ip_all
|
||||
volumes:
|
||||
- ./components/config_mongodb/data/db:/data/db
|
||||
- ./components/config_mongodb/data/logs:/data/logs
|
||||
- ./components/config_mongodb/data/conf:/etc/mongo
|
||||
- ./components/config_mongodb/data/configdb:/data/configdb
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
# cache
|
||||
- wiredTigerCacheSizeGB=1
|
||||
|
||||
# shard分片1
|
||||
shard1:
|
||||
image: mongo:latest
|
||||
networks:
|
||||
- mongo-network
|
||||
container_name: shard1
|
||||
restart: always
|
||||
ports:
|
||||
- 27118:27018
|
||||
command: --shardsvr --replSet "shard1" --bind_ip_all
|
||||
volumes:
|
||||
- /data01/mongo/shard1/db:/data/db
|
||||
- /data01/mongo/shard1/configdb:/data/configdb
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
# cache
|
||||
- wiredTigerCacheSizeGB=1
|
||||
|
||||
# shard分片2
|
||||
shard2:
|
||||
image: mongo:latest
|
||||
networks:
|
||||
- mongo-network
|
||||
container_name: shard2
|
||||
restart: always
|
||||
ports:
|
||||
- 27218:27018
|
||||
command: --shardsvr --replSet "shard2" --bind_ip_all
|
||||
volumes:
|
||||
- /data02/mongo/shard2/db:/data/db
|
||||
- /data02/mongo/shard2/configdb:/data/configdb
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
# cache
|
||||
- wiredTigerCacheSizeGB=1
|
||||
# - ${PWD}/key.file:/data/mongodb/key.file
|
||||
|
||||
# shard分片3
|
||||
shard3:
|
||||
image: mongo:latest
|
||||
networks:
|
||||
- mongo-network
|
||||
container_name: shard3
|
||||
restart: always
|
||||
ports:
|
||||
- 27318:27018
|
||||
command: --shardsvr --replSet "shard3" --bind_ip_all
|
||||
volumes:
|
||||
- /data03/mongo/shard3/db:/data/db
|
||||
- /data03/mongo/shard3/configdb:/data/configdb
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
# cache
|
||||
- wiredTigerCacheSizeGB=1
|
||||
# shard分片4
|
||||
shard4:
|
||||
image: mongo:latest
|
||||
networks:
|
||||
- mongo-network
|
||||
container_name: shard4
|
||||
restart: always
|
||||
ports:
|
||||
- 27418:27018
|
||||
command: --shardsvr --replSet "shard4" --bind_ip_all
|
||||
volumes:
|
||||
- /data04/mongo/shard4/db:/data/db
|
||||
- /data04/mongo/shard4/configdb:/data/configdb
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
# cache
|
||||
- wiredTigerCacheSizeGB=1
|
||||
# shard分片5
|
||||
shard5:
|
||||
image: mongo:latest
|
||||
networks:
|
||||
- mongo-network
|
||||
container_name: shard5
|
||||
restart: always
|
||||
ports:
|
||||
- 27518:27018
|
||||
command: --shardsvr --replSet "shard5" --bind_ip_all
|
||||
volumes:
|
||||
- /data05/mongo/shard5/db:/data/db
|
||||
- /data05/mongo/shard5/configdb:/data/configdb
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
# cache
|
||||
- wiredTigerCacheSizeGB=1
|
||||
+12
-73
@@ -20,21 +20,20 @@ services:
|
||||
ports:
|
||||
- 37017:27017
|
||||
container_name: mongo
|
||||
command: --wiredTigerCacheSizeGB 1
|
||||
volumes:
|
||||
- ./components/mongodb/data/db:/data/db
|
||||
- ./components/mongodb/data/logs:/data/logs
|
||||
- ./components/mongodb/data/conf:/etc/mongo
|
||||
# - ./script/mongo-init.sh:/docker-entrypoint-initdb.d/mongo-init.sh
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
# cache
|
||||
- wiredTigerCacheSizeGB=1
|
||||
# - MONGO_USERNAME=openIM
|
||||
# - MONGO_PASSWORD=openIM
|
||||
# - MONGO_INITDB_ROOT_USERNAME=root
|
||||
# - MONGO_INITDB_ROOT_PASSWORD=root
|
||||
# - MONGO_INITDB_DATABASE=openIM
|
||||
# environment:
|
||||
# - MONGO_INITDB_ROOT_USERNAME=openIM
|
||||
# - MONGO_INITDB_ROOT_PASSWORD=openIM
|
||||
|
||||
|
||||
#TZ: Asia/Shanghai
|
||||
restart: always
|
||||
|
||||
redis:
|
||||
@@ -45,7 +44,7 @@ services:
|
||||
volumes:
|
||||
- ./components/redis/data:/data
|
||||
#redis config file
|
||||
- ./components/redis/config/redis.conf:/usr/local/redis/config/redis.conf
|
||||
#- ./components/redis/config/redis.conf:/usr/local/redis/config/redis.conf
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
restart: always
|
||||
@@ -70,17 +69,13 @@ services:
|
||||
image: wurstmeister/kafka
|
||||
container_name: kafka
|
||||
restart: always
|
||||
ports:
|
||||
- 9092:9092
|
||||
environment:
|
||||
TZ: Asia/Shanghai
|
||||
KAFKA_BROKER_ID: 0
|
||||
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
||||
KAFKA_CREATE_TOPICS: "ws2ms_chat:8:1,ms2ps_chat:8:1,msg_to_mongo:8:1"
|
||||
KAFKA_ADVERTISED_LISTENERS: INSIDE://127.0.0.1:9092,OUTSIDE://103.116.45.174:9092
|
||||
KAFKA_LISTENERS: INSIDE://:9092,OUTSIDE://:9093
|
||||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT"
|
||||
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
|
||||
KAFKA_ZOOKEEPER_CONNECT: 127.0.0.1:2181
|
||||
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9092
|
||||
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
|
||||
network_mode: "host"
|
||||
depends_on:
|
||||
- zookeeper
|
||||
|
||||
@@ -98,24 +93,8 @@ services:
|
||||
restart: always
|
||||
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
|
||||
|
||||
minio:
|
||||
image: minio/minio
|
||||
ports:
|
||||
- 10005:9000
|
||||
- 9090:9090
|
||||
container_name: minio
|
||||
volumes:
|
||||
- /mnt/data:/data
|
||||
- /mnt/config:/root/.minio
|
||||
environment:
|
||||
MINIO_ROOT_USER: user12345
|
||||
MINIO_ROOT_PASSWORD: key12345
|
||||
restart: always
|
||||
command: minio server /data --console-address ':9090'
|
||||
|
||||
|
||||
open_im_server:
|
||||
image: openim/open_im_server:v2.3.2
|
||||
image: openim/open_im_server:v2.0.8
|
||||
container_name: open_im_server
|
||||
volumes:
|
||||
- ./logs:/Open-IM-Server/logs
|
||||
@@ -129,49 +108,9 @@ services:
|
||||
- mongodb
|
||||
- redis
|
||||
- etcd
|
||||
- minio
|
||||
network_mode: "host"
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "1g"
|
||||
max-file: "2"
|
||||
|
||||
prometheus:
|
||||
image: prom/prometheus
|
||||
volumes:
|
||||
- ./docker-compose_cfg/prometheus-compose.yml:/etc/prometheus/prometheus.yml
|
||||
# - ./components/prometheus_data:/prometheus
|
||||
container_name: prometheus
|
||||
ports:
|
||||
- 9091:9091
|
||||
depends_on:
|
||||
- open_im_server
|
||||
command: --web.listen-address=:9091 --config.file="/etc/prometheus/prometheus.yml"
|
||||
network_mode: "host"
|
||||
|
||||
grafana:
|
||||
image: grafana/grafana
|
||||
volumes:
|
||||
- ./docker-compose_cfg/datasource-compose.yaml:/etc/grafana/provisioning/datasources/datasource.yaml
|
||||
- ./docker-compose_cfg/grafana.ini:/etc/grafana/grafana.ini
|
||||
# - ./docker-compose_cfg/node-exporter-full_rev1.json:/var/lib/grafana/dashboards/node-exporter-full_rev1.json
|
||||
# - ./components/grafana:/var/lib/grafana
|
||||
- ./docker-compose_cfg/grafana.db:/var/lib/grafana/grafana.db
|
||||
container_name: grafana
|
||||
ports:
|
||||
- 10007:10007
|
||||
depends_on:
|
||||
- prometheus
|
||||
network_mode: "host"
|
||||
privileged: true
|
||||
user: root
|
||||
# -rw-r-----
|
||||
|
||||
node-exporter:
|
||||
image: quay.io/prometheus/node-exporter
|
||||
container_name: node-exporter
|
||||
restart: always
|
||||
ports:
|
||||
- "9100:9100"
|
||||
# command: --collector.ENTER-THE-NAME-OF-COLLECTOR
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#more datasource-compose.yaml
|
||||
apiVersion: 1
|
||||
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
type: prometheus
|
||||
access: proxy
|
||||
orgId: 1
|
||||
url: http://127.0.0.1:9091
|
||||
basicAuth: false
|
||||
isDefault: true
|
||||
version: 1
|
||||
editable: true
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,90 +0,0 @@
|
||||
#more prometheus-compose.yml
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
evaluation_interval: 15s
|
||||
external_labels:
|
||||
monitor: 'openIM-monitor'
|
||||
|
||||
scrape_configs:
|
||||
- job_name: 'prometheus'
|
||||
static_configs:
|
||||
- targets: ['localhost:9091']
|
||||
|
||||
- job_name: 'openIM-server'
|
||||
metrics_path: /metrics
|
||||
static_configs:
|
||||
- targets: ['localhost:10002']
|
||||
labels:
|
||||
group: 'api'
|
||||
|
||||
- targets: ['localhost:10006']
|
||||
labels:
|
||||
group: 'cms-api'
|
||||
|
||||
|
||||
- targets: ['localhost:20110']
|
||||
labels:
|
||||
group: 'user'
|
||||
|
||||
- targets: ['localhost:20120']
|
||||
labels:
|
||||
group: 'friend'
|
||||
|
||||
- targets: ['localhost:20130']
|
||||
labels:
|
||||
group: 'message'
|
||||
|
||||
- targets: ['localhost:20140']
|
||||
labels:
|
||||
group: 'msg-gateway'
|
||||
|
||||
- targets: ['localhost:20150']
|
||||
labels:
|
||||
group: 'group'
|
||||
|
||||
- targets: ['localhost:20160']
|
||||
labels:
|
||||
group: 'auth'
|
||||
|
||||
- targets: ['localhost:20170']
|
||||
labels:
|
||||
group: 'push'
|
||||
|
||||
- targets: ['localhost:20120']
|
||||
labels:
|
||||
group: 'friend'
|
||||
|
||||
- targets: ['localhost:20200']
|
||||
labels:
|
||||
group: 'admin-cms'
|
||||
|
||||
- targets: ['localhost:20120']
|
||||
labels:
|
||||
group: 'office'
|
||||
|
||||
- targets: ['localhost:20220']
|
||||
labels:
|
||||
group: 'organization'
|
||||
|
||||
- targets: ['localhost:20230']
|
||||
labels:
|
||||
group: 'conversation'
|
||||
|
||||
- targets: ['localhost:20240']
|
||||
labels:
|
||||
group: 'cache'
|
||||
|
||||
- targets: ['localhost:21400', 'localhost:21401', 'localhost:21402', 'localhost:21403']
|
||||
labels:
|
||||
group: 'msg-transfer'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
- job_name: 'node'
|
||||
scrape_interval: 8s
|
||||
static_configs:
|
||||
- targets: ['localhost:9100']
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 144 KiB After Width: | Height: | Size: 208 KiB |
@@ -3,74 +3,67 @@ module Open_IM
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
cloud.google.com/go/firestore v1.6.1 // indirect
|
||||
firebase.google.com/go v3.13.0+incompatible
|
||||
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/dysmsapi-20170525/v2 v2.0.8
|
||||
github.com/alibabacloud-go/sts-20150401 v1.1.0
|
||||
github.com/alibabacloud-go/tea v1.1.17
|
||||
github.com/antonfisher/nested-logrus-formatter v1.3.0
|
||||
github.com/aws/aws-sdk-go-v2 v1.16.7
|
||||
github.com/aws/aws-sdk-go-v2/config v1.15.14
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.12.9
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.16.9
|
||||
github.com/bwmarrin/snowflake v0.3.0
|
||||
github.com/dtm-labs/rockscache v0.0.11
|
||||
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/gin-gonic/gin v1.8.1
|
||||
github.com/go-openapi/spec v0.20.6 // indirect
|
||||
github.com/go-openapi/swag v0.21.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.11.0
|
||||
github.com/go-redis/redis/v8 v8.11.5
|
||||
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/go-playground/validator/v10 v10.4.1
|
||||
github.com/go-sql-driver/mysql v1.6.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2
|
||||
github.com/golang-jwt/jwt/v4 v4.1.0
|
||||
github.com/golang/protobuf v1.5.2
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
|
||||
github.com/jinzhu/copier v0.3.4
|
||||
github.com/jinzhu/gorm v1.9.16
|
||||
github.com/jinzhu/now v1.1.3 // indirect
|
||||
github.com/jonboulle/clockwork v0.2.2 // indirect
|
||||
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
|
||||
github.com/lestrrat-go/strftime v1.0.4 // 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/minio/minio-go/v7 v7.0.22
|
||||
github.com/mitchellh/mapstructure v1.4.2
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||
github.com/olivere/elastic/v7 v7.0.23
|
||||
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
|
||||
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/prometheus/client_golang v1.13.0
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/stretchr/testify v1.7.2
|
||||
github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe
|
||||
github.com/swaggo/gin-swagger v1.5.0
|
||||
github.com/swaggo/swag v1.8.3
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.428
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms v1.0.428
|
||||
github.com/spf13/viper v1.9.0
|
||||
github.com/stretchr/testify v1.7.0
|
||||
github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20210325043845-84a0811633ca
|
||||
go.etcd.io/etcd/api/v3 v3.5.4
|
||||
go.etcd.io/etcd/client/v3 v3.5.4
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
|
||||
//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.uber.org/atomic v1.9.0 // indirect
|
||||
go.uber.org/multierr v1.7.0 // indirect
|
||||
go.uber.org/zap v1.19.1 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
|
||||
golang.org/x/image v0.0.0-20211028202545-6944b10bf410
|
||||
golang.org/x/net v0.0.0-20220622184535-263ec571b305
|
||||
golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664 // indirect
|
||||
golang.org/x/tools v0.1.11 // indirect
|
||||
google.golang.org/api v0.59.0
|
||||
google.golang.org/grpc v1.45.0
|
||||
google.golang.org/protobuf v1.28.1
|
||||
golang.org/x/image v0.0.0-20210220032944-ac19c3e999fb
|
||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
|
||||
google.golang.org/grpc v1.42.0
|
||||
google.golang.org/grpc/examples v0.0.0-20220311002955-722367c4a737 // indirect
|
||||
google.golang.org/protobuf v1.27.1
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
||||
gopkg.in/ini.v1 v1.66.2 // indirect
|
||||
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
gorm.io/driver/mysql v1.3.5
|
||||
gorm.io/gorm v1.23.8
|
||||
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
|
||||
|
||||
+18
-161
@@ -3,38 +3,22 @@ package apiAuth
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
rpc "Open_IM/pkg/proto/auth"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/structs"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Summary 用户注册
|
||||
// @Description 用户注册
|
||||
// @Tags 鉴权认证
|
||||
// @ID UserRegister
|
||||
// @Accept json
|
||||
// @Param req body api.UserRegisterReq true "secret为openIM密钥, 详细见服务端config.yaml secret字段 <br> platform为平台ID <br> ex为拓展字段 <br> gender为性别, 0为女, 1为男"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.UserRegisterResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /auth/user_register [post]
|
||||
func UserRegister(c *gin.Context) {
|
||||
params := api.UserRegisterReq{}
|
||||
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})
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -49,40 +33,26 @@ func UserRegister(c *gin.Context) {
|
||||
//copier.Copy(req.UserInfo, ¶ms)
|
||||
req.OperationID = params.OperationID
|
||||
log.NewInfo(req.OperationID, "UserRegister args ", req.String())
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == 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.OpenImAuthName)
|
||||
client := rpc.NewAuthClient(etcdConn)
|
||||
reply, err := client.UserRegister(context.Background(), req)
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " " + "UserRegister failed " + err.Error() + req.String()
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "call rpc err ", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "internal service err"})
|
||||
return
|
||||
}
|
||||
if reply.CommonResp.ErrCode != 0 {
|
||||
errMsg := req.OperationID + " " + " UserRegister failed " + reply.CommonResp.ErrMsg + req.String()
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
if reply.CommonResp.ErrCode == constant.RegisterLimit {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterLimit, "errMsg": "用户注册被限制"})
|
||||
} else if reply.CommonResp.ErrCode == constant.InvitationError {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.InvitationError, "errMsg": "邀请码错误"})
|
||||
} else {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
}
|
||||
log.NewError(req.OperationID, "UserRegister failed ", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": reply.CommonResp.ErrMsg})
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
pbDataToken := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}
|
||||
replyToken, err := client.UserToken(context.Background(), pbDataToken)
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " " + " client.UserToken failed " + err.Error() + pbDataToken.String()
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "UserToken failed ", err.Error(), pbDataToken)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
resp := api.UserRegisterResp{CommResp: api.CommResp{ErrCode: replyToken.CommonResp.ErrCode, ErrMsg: replyToken.CommonResp.ErrMsg},
|
||||
@@ -92,47 +62,27 @@ func UserRegister(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
// @Summary 用户登录
|
||||
// @Description 获取用户的token
|
||||
// @Tags 鉴权认证
|
||||
// @ID UserToken
|
||||
// @Accept json
|
||||
// @Param req body api.UserTokenReq true "secret为openIM密钥, 详细见服务端config.yaml secret字段 <br> platform为平台ID"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.UserTokenResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /auth/user_token [post]
|
||||
func UserToken(c *gin.Context) {
|
||||
params := api.UserTokenReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
errMsg := " BindJSON failed " + err.Error()
|
||||
log.NewError(params.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
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)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": errMsg})
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "not authorized"})
|
||||
return
|
||||
}
|
||||
req := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID, LoginIp: params.LoginIp}
|
||||
req := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}
|
||||
log.NewInfo(req.OperationID, "UserToken args ", req.String())
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == 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.OpenImAuthName)
|
||||
client := rpc.NewAuthClient(etcdConn)
|
||||
reply, err := client.UserToken(context.Background(), req)
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " UserToken failed " + err.Error() + " req: " + req.String()
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "UserToken failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
resp := api.UserTokenResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg},
|
||||
@@ -140,96 +90,3 @@ func UserToken(c *gin.Context) {
|
||||
log.NewInfo(req.OperationID, "UserToken return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 解析当前用户token
|
||||
// @Description 解析当前用户token(token在请求头中传入)
|
||||
// @Tags 鉴权认证
|
||||
// @ID ParseToken
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.ParseTokenReq true "secret为openIM密钥, 详细见服务端config.yaml secret字段<br>platform为平台ID"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.ParseTokenResp{Data=api.ExpireTime}
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /auth/parse_token [post]
|
||||
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.StatusOK, gin.H{"errCode": 1001, "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
|
||||
log.NewError(params.OperationID, errMsg)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 1001, "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)
|
||||
}
|
||||
|
||||
// @Summary 强制登出
|
||||
// @Description 对应的平台强制登出
|
||||
// @Tags 鉴权认证
|
||||
// @ID ForceLogout
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.ForceLogoutReq true "platform为平台ID <br> fromUserID为要执行强制登出的用户ID"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.ForceLogoutResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /auth/force_logout [post]
|
||||
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.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == 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)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package apiChat
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func DelMsg(c *gin.Context) {
|
||||
var (
|
||||
req api.DelMsgReq
|
||||
resp api.DelMsgResp
|
||||
reqPb pbCommon.DelMsgListReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
msgClient := pbChat.NewChatClient(grpcConn)
|
||||
respPb, err := msgClient.DelMsgList(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsgList failed", err.Error(), reqPb)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.ErrServer.ErrCode, "errMsg": constant.ErrServer.ErrMsg + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.ErrCode = respPb.ErrCode
|
||||
resp.ErrMsg = respPb.ErrMsg
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
package msg
|
||||
package apiChat
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/msg"
|
||||
sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
||||
pbMsg "Open_IM/pkg/proto/chat"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"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()})
|
||||
return
|
||||
}
|
||||
pbData := sdk_ws.GetMaxAndMinSeqReq{}
|
||||
pbData := pbMsg.GetMaxAndMinSeqReq{}
|
||||
pbData.UserID = params.SendID
|
||||
pbData.OperationID = params.OperationID
|
||||
grpcConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, pbData.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := pbData.OperationID + " getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(pbData.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
|
||||
msgClient := pbChat.NewMsgClient(grpcConn)
|
||||
if grpcConn == nil {
|
||||
log.ErrorByKv("get grpcConn err", pbData.OperationID, "args", params)
|
||||
}
|
||||
msgClient := pbMsg.NewChatClient(grpcConn)
|
||||
reply, err := msgClient.GetMaxAndMinSeq(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "UserGetSeq rpc failed, ", params, err.Error())
|
||||
@@ -1,11 +1,11 @@
|
||||
package msg
|
||||
package apiChat
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/pkg/proto/msg"
|
||||
"Open_IM/pkg/proto/chat"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
@@ -51,20 +51,14 @@ func PullMsgBySeqList(c *gin.Context) {
|
||||
pbData.OperationID = params.OperationID
|
||||
pbData.SeqList = params.SeqList
|
||||
|
||||
grpcConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, pbData.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := pbData.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(pbData.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
msgClient := msg.NewMsgClient(grpcConn)
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
msgClient := pbChat.NewChatClient(grpcConn)
|
||||
reply, err := msgClient.PullMessageBySeqList(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
log.Error(pbData.OperationID, "PullMessageBySeqList error", err.Error())
|
||||
log.ErrorByKv("PullMessageBySeqList error", pbData.OperationID, "err", err.Error())
|
||||
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{
|
||||
"errCode": reply.ErrCode,
|
||||
"errMsg": reply.ErrMsg,
|
||||
@@ -1,9 +1,9 @@
|
||||
package msg
|
||||
package apiChat
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbChat "Open_IM/pkg/proto/msg"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"context"
|
||||
|
||||
@@ -62,23 +62,19 @@ func SendMsg(c *gin.Context) {
|
||||
params := paramsUserSendMsg{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
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
|
||||
}
|
||||
|
||||
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.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, params.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := params.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(params.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbChat.NewMsgClient(etcdConn)
|
||||
log.InfoByKv("api call success to sendMsgReq", params.OperationID, "Parameters", params)
|
||||
|
||||
pbData := newUserSendMsgReq(token, ¶ms)
|
||||
log.Info("", "", "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)
|
||||
client := pbChat.NewChatClient(etcdConn)
|
||||
|
||||
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()})
|
||||
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{
|
||||
"errCode": reply.ErrCode,
|
||||
@@ -1,75 +0,0 @@
|
||||
package clientInit
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/utils"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
func SetClientInitConfig(c *gin.Context) {
|
||||
var req api.SetClientInitConfigReq
|
||||
var resp api.SetClientInitConfigResp
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
err, _ := token_verify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID)
|
||||
if err != nil {
|
||||
errMsg := "ParseTokenGetUserID failed " + err.Error() + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
m := make(map[string]interface{})
|
||||
if req.DiscoverPageURL != nil {
|
||||
m["discover_page_url"] = *req.DiscoverPageURL
|
||||
}
|
||||
if len(m) > 0 {
|
||||
err := imdb.SetClientInitConfig(m)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetClientInitConfig(c *gin.Context) {
|
||||
var req api.GetClientInitConfigReq
|
||||
var resp api.GetClientInitConfigResp
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
err, _ := token_verify.ParseTokenGetUserID(c.Request.Header.Get("token"), req.OperationID)
|
||||
if err != nil {
|
||||
errMsg := "ParseTokenGetUserID failed " + err.Error() + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
config, err := imdb.GetClientInitConfig()
|
||||
if err != nil {
|
||||
if !gorm.IsRecordNotFoundError(err) {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
}
|
||||
resp.Data.DiscoverPageURL = config.DiscoverPageURL
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbConversation "Open_IM/pkg/proto/conversation"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
@@ -25,20 +24,14 @@ func SetConversation(c *gin.Context) {
|
||||
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{}
|
||||
reqPb.Conversation = &pbUser.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.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.SetConversation(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -51,43 +44,6 @@ func SetConversation(c *gin.Context) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", 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.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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) {
|
||||
var (
|
||||
@@ -100,17 +56,11 @@ func BatchSetConversations(c *gin.Context) {
|
||||
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(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.BatchSetConversations(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -127,18 +77,6 @@ func BatchSetConversations(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 获取用户所有会话
|
||||
// @Description 获取用户所有会话
|
||||
// @Tags 会话相关
|
||||
// @ID GetAllConversations
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetAllConversationsReq true "ownerUserID为要获取的用户ID"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetAllConversationsResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /msg/get_all_conversations [post]
|
||||
func GetAllConversations(c *gin.Context) {
|
||||
var (
|
||||
req api.GetAllConversationsReq
|
||||
@@ -150,17 +88,11 @@ func GetAllConversations(c *gin.Context) {
|
||||
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(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetAllConversations(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -177,18 +109,6 @@ func GetAllConversations(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 根据会话ID获取会话
|
||||
// @Description 根据会话ID获取会话
|
||||
// @Tags 会话相关
|
||||
// @ID GetConversation
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetConversationReq true "ownerUserID为要获取的用户ID<br>conversationID为要获取的会话ID"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetConversationResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /msg/get_conversation [post]
|
||||
func GetConversation(c *gin.Context) {
|
||||
var (
|
||||
req api.GetConversationReq
|
||||
@@ -200,17 +120,11 @@ func GetConversation(c *gin.Context) {
|
||||
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(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetConversation(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -227,18 +141,6 @@ func GetConversation(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 根据会话ID列表获取会话
|
||||
// @Description 根据会话ID列表获取会话
|
||||
// @Tags 会话相关
|
||||
// @ID GetConversations
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetConversationsReq true "ownerUserID为要获取的用户ID<br>conversationIDs为要获取的会话ID列表"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetConversationsResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /msg/get_conversations [post]
|
||||
func GetConversations(c *gin.Context) {
|
||||
var (
|
||||
req api.GetConversationsReq
|
||||
@@ -250,17 +152,11 @@ func GetConversations(c *gin.Context) {
|
||||
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(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetConversations(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -288,17 +184,11 @@ func SetRecvMsgOpt(c *gin.Context) {
|
||||
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(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.SetRecvMsgOpt(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
|
||||
+82
-304
@@ -16,18 +16,6 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// @Summary 添加黑名单
|
||||
// @Description 添加黑名单
|
||||
// @Tags 好友相关
|
||||
// @ID AddBlack
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.AddBlacklistReq true "fromUserID为设置的用户 <br> toUserID为被设置的用户"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.AddBlacklistResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/add_black [post]
|
||||
func AddBlack(c *gin.Context) {
|
||||
params := api.AddBlacklistReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -38,17 +26,15 @@ func AddBlack(c *gin.Context) {
|
||||
req := &rpc.AddBlacklistReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms)
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
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(params.OperationID, "AddBlacklist args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetDefaultConn(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)
|
||||
RpcResp, err := client.AddBlacklist(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -61,18 +47,6 @@ func AddBlack(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 批量加好友
|
||||
// @Description 批量加好友
|
||||
// @Tags 好友相关
|
||||
// @ID ImportFriend
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.ImportFriendReq true "fromUserID批量加好友的用户ID<br> friendUserIDList为"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.ImportFriendResp "data列表中对象的result-1为添加该用户失败<br>0为成功"
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/import_friend [post]
|
||||
func ImportFriend(c *gin.Context) {
|
||||
params := api.ImportFriendReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -83,24 +57,15 @@ func ImportFriend(c *gin.Context) {
|
||||
req := &rpc.ImportFriendReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, req.OpUserID = 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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, "ImportFriend args ", req.String())
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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)
|
||||
RpcResp, err := client.ImportFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -121,18 +86,6 @@ func ImportFriend(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 添加好友
|
||||
// @Description 添加好友
|
||||
// @Tags 好友相关
|
||||
// @ID AddFriend
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.AddFriendReq true "reqMsg为申请信息 <br> fromUserID为申请用户 <br> toUserID为被添加用户"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.AddFriendResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/add_friend [post]
|
||||
func AddFriend(c *gin.Context) {
|
||||
params := api.AddFriendReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -143,26 +96,16 @@ func AddFriend(c *gin.Context) {
|
||||
req := &rpc.AddFriendReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
req.ReqMsg = params.ReqMsg
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
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, "AddFriend args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.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)
|
||||
RpcResp, err := client.AddFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -176,18 +119,6 @@ func AddFriend(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 同意/拒绝好友请求
|
||||
// @Description 同意/拒绝好友请求
|
||||
// @Tags 好友相关
|
||||
// @ID AddFriendResponse
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.AddFriendResponseReq true "fromUserID同意/拒绝的用户ID<br>toUserID为申请用户D<br>handleMsg为处理信息<br>flag为具体操作, 1为同意, 2为拒绝"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.AddFriendResponseResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/add_friend_response [post]
|
||||
func AddFriendResponse(c *gin.Context) {
|
||||
params := api.AddFriendResponseReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -199,28 +130,17 @@ func AddFriendResponse(c *gin.Context) {
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
req.HandleMsg = params.HandleMsg
|
||||
req.HandleResult = params.Flag
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
log.NewInfo(req.CommID.OperationID, "AddFriendResponse args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.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)
|
||||
RpcResp, err := client.AddFriendResponse(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -234,18 +154,6 @@ func AddFriendResponse(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 删除好友
|
||||
// @Description 删除好友
|
||||
// @Tags 好友相关
|
||||
// @ID DeleteFriend
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.DeleteFriendReq true "fromUserID为操作用户<br>toUserID为被删除用户"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.DeleteFriendResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/delete_friend [post]
|
||||
func DeleteFriend(c *gin.Context) {
|
||||
params := api.DeleteFriendReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -255,26 +163,16 @@ func DeleteFriend(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.DeleteFriendReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
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, "DeleteFriend args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.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)
|
||||
RpcResp, err := client.DeleteFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -288,18 +186,6 @@ func DeleteFriend(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 获取黑名单列表
|
||||
// @Description 获取黑名单列表
|
||||
// @Tags 好友相关
|
||||
// @ID GetBlacklist
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetBlackListReq true "fromUserID要获取黑名单的用户"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetBlackListResp{data=[]open_im_sdk.PublicUserInfo}
|
||||
// @Failure 500 {object} api.Swagger400Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger500Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/get_black_list [post]
|
||||
func GetBlacklist(c *gin.Context) {
|
||||
params := api.GetBlackListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -309,26 +195,16 @@ func GetBlacklist(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.GetBlacklistReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
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, "GetBlacklist args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.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)
|
||||
RpcResp, err := client.GetBlacklist(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -348,18 +224,6 @@ func GetBlacklist(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 设置好友备注
|
||||
// @Description 设置好友备注
|
||||
// @Tags 好友相关
|
||||
// @ID SetFriendRemark
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.SetFriendRemarkReq true "fromUserID为设置的用户<br> toUserID为被设置的用户<br> remark为好友备注"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.SetFriendRemarkResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/set_friend_remark [post]
|
||||
func SetFriendRemark(c *gin.Context) {
|
||||
params := api.SetFriendRemarkReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -370,26 +234,16 @@ func SetFriendRemark(c *gin.Context) {
|
||||
req := &rpc.SetFriendRemarkReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
req.Remark = params.Remark
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
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, "SetFriendComment args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.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)
|
||||
RpcResp, err := client.SetFriendRemark(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -403,18 +257,6 @@ func SetFriendRemark(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 把用户移除黑名单
|
||||
// @Description 把用户移除黑名单
|
||||
// @Tags 好友相关
|
||||
// @ID RemoveBlack
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.RemoveBlackListReq true "fromUserID要获取黑名单的用户"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.RemoveBlackListResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/remove_black [post]
|
||||
func RemoveBlack(c *gin.Context) {
|
||||
params := api.RemoveBlackListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -424,26 +266,16 @@ func RemoveBlack(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.RemoveBlacklistReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
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, "RemoveBlacklist args ", req.String())
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.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)
|
||||
RpcResp, err := client.RemoveBlacklist(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -456,18 +288,6 @@ func RemoveBlack(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 检查用户之间是否为好友
|
||||
// @Description 检查用户之间是否为好友
|
||||
// @Tags 好友相关
|
||||
// @ID IsFriend
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.IsFriendReq true "fromUserID为请求用户<br> toUserID为要检查的用户"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.IsFriendResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/is_friend [post]
|
||||
func IsFriend(c *gin.Context) {
|
||||
params := api.IsFriendReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -477,26 +297,16 @@ func IsFriend(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.IsFriendReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
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, "IsFriend args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.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)
|
||||
RpcResp, err := client.IsFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -511,18 +321,40 @@ func IsFriend(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 获取用户的好友列表
|
||||
// @Description 获取用户的好友列表
|
||||
// @Tags 好友相关
|
||||
// @ID GetFriendList
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetFriendListReq true "fromUserID为要获取好友列表的用户ID"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetFriendListResp{data=[]open_im_sdk.FriendInfo}
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/get_friend_list [post]
|
||||
//
|
||||
//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) {
|
||||
params := api.GetFriendListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -532,26 +364,16 @@ func GetFriendList(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.GetFriendListReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
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, "GetFriendList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.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)
|
||||
RpcResp, err := client.GetFriendList(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -567,18 +389,6 @@ func GetFriendList(c *gin.Context) {
|
||||
//c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 获取好友申请列表
|
||||
// @Description 删除好友
|
||||
// @Tags 好友相关
|
||||
// @ID GetFriendApplyList
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetFriendApplyListReq true "fromUserID为要获取申请列表的用户ID"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetFriendApplyListResp{data=[]open_im_sdk.FriendRequest}
|
||||
// @Failure 500 {object} api.Swagger400Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/get_friend_apply_list [post]
|
||||
func GetFriendApplyList(c *gin.Context) {
|
||||
params := api.GetFriendApplyListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -588,26 +398,16 @@ func GetFriendApplyList(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.GetFriendApplyListReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
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, "GetFriendApplyList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.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)
|
||||
|
||||
RpcResp, err := client.GetFriendApplyList(context.Background(), req)
|
||||
@@ -623,18 +423,6 @@ func GetFriendApplyList(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 获取自己的好友申请列表
|
||||
// @Description 获取自己的好友申请列表
|
||||
// @Tags 好友相关
|
||||
// @ID GetSelfFriendApplyList
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetSelfApplyListReq true "fromUserID为自己的用户ID"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetSelfApplyListResp{data=[]open_im_sdk.FriendRequest}
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /friend/get_self_friend_apply_list [post]
|
||||
func GetSelfFriendApplyList(c *gin.Context) {
|
||||
params := api.GetSelfApplyListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -644,26 +432,16 @@ func GetSelfFriendApplyList(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.GetSelfApplyListReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.CommID.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.CommID.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
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, "GetSelfApplyList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName, req.CommID.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.CommID.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.CommID.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)
|
||||
RpcResp, err := client.GetSelfApplyList(context.Background(), req)
|
||||
if err != nil {
|
||||
|
||||
+101
-701
File diff suppressed because it is too large
Load Diff
@@ -1,89 +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.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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, "GetJoinedSuperGroupList 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.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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)
|
||||
}
|
||||
@@ -10,33 +10,25 @@ import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/msg"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
"Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-playground/validator/v10"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var validate *validator.Validate
|
||||
|
||||
func SetOptions(options map[string]bool, value bool) {
|
||||
utils.SetSwitchFromOptions(options, constant.IsHistory, value)
|
||||
utils.SetSwitchFromOptions(options, constant.IsPersistent, value)
|
||||
utils.SetSwitchFromOptions(options, constant.IsSenderSync, value)
|
||||
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, value)
|
||||
}
|
||||
|
||||
func newUserSendMsgReq(params *api.ManagementSendMsgReq) *pbChat.SendMsgReq {
|
||||
func newUserSendMsgReq(params *ManagementSendMsgReq) *pbChat.SendMsgReq {
|
||||
var newContent string
|
||||
var err error
|
||||
switch params.ContentType {
|
||||
@@ -48,33 +40,26 @@ func newUserSendMsgReq(params *api.ManagementSendMsgReq) *pbChat.SendMsgReq {
|
||||
fallthrough
|
||||
case constant.Voice:
|
||||
fallthrough
|
||||
case constant.Video:
|
||||
fallthrough
|
||||
case constant.File:
|
||||
fallthrough
|
||||
case constant.AdvancedRevoke:
|
||||
newContent = utils.StructToJsonString(params.Content)
|
||||
case constant.Revoke:
|
||||
newContent = params.Content["revokeMsgClientID"].(string)
|
||||
|
||||
default:
|
||||
}
|
||||
options := make(map[string]bool, 5)
|
||||
var options map[string]bool
|
||||
if params.IsOnlineOnly {
|
||||
SetOptions(options, false)
|
||||
}
|
||||
if params.NotOfflinePush {
|
||||
options = make(map[string]bool, 5)
|
||||
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsHistory, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsSenderSync, false)
|
||||
}
|
||||
if params.ContentType == constant.CustomOnlineOnly {
|
||||
SetOptions(options, false)
|
||||
} else if params.ContentType == constant.CustomNotTriggerConversation {
|
||||
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
|
||||
}
|
||||
|
||||
pbData := pbChat.SendMsgReq{
|
||||
OperationID: params.OperationID,
|
||||
MsgData: &open_im_sdk.MsgData{
|
||||
SendID: params.SendID,
|
||||
RecvID: params.RecvID,
|
||||
GroupID: params.GroupID,
|
||||
ClientMsgID: utils.GetMsgID(params.SendID),
|
||||
SenderPlatformID: params.SenderPlatformID,
|
||||
@@ -84,7 +69,6 @@ func newUserSendMsgReq(params *api.ManagementSendMsgReq) *pbChat.SendMsgReq {
|
||||
MsgFrom: constant.SysMsgType,
|
||||
ContentType: params.ContentType,
|
||||
Content: []byte(newContent),
|
||||
RecvID: params.RecvID,
|
||||
// ForceList: params.ForceList,
|
||||
CreateTime: utils.GetCurrentTimestampByMill(),
|
||||
Options: options,
|
||||
@@ -105,26 +89,12 @@ func init() {
|
||||
validate = validator.New()
|
||||
}
|
||||
|
||||
// @Summary 管理员发送/撤回消息
|
||||
// @Description 管理员发送/撤回消息 消息格式详细见<a href="https://doc.rentsoft.cn/#/server_doc/admin?id=%e6%b6%88%e6%81%af%e7%b1%bb%e5%9e%8b%e6%a0%bc%e5%bc%8f%e6%8f%8f%e8%bf%b0">消息格式</href>
|
||||
// @Tags 消息相关
|
||||
// @ID ManagementSendMsg
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param 管理员发送文字消息 body api.ManagementSendMsgReq{content=TextElem{}} true "该请求和消息结构体一样"
|
||||
// @Param 管理员发送OA通知消息 body api.ManagementSendMsgReq{content=OANotificationElem{}} true "该请求和消息结构体一样"
|
||||
// @Param 管理员撤回单聊消息 body api.ManagementSendMsgReq{content=RevokeElem{}} true "该请求和消息结构体一样"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.ManagementSendMsgResp "serverMsgID为服务器消息ID <br> clientMsgID为客户端消息ID <br> sendTime为发送消息时间"
|
||||
// @Failure 500 {object} api.ManagementSendMsgResp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.ManagementSendMsgResp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /msg/manage_send_msg [post]
|
||||
func ManagementSendMsg(c *gin.Context) {
|
||||
var data interface{}
|
||||
params := api.ManagementSendMsgReq{}
|
||||
params := ManagementSendMsgReq{}
|
||||
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"))
|
||||
log.ErrorByKv("json unmarshal err", c.PostForm("operationID"), "err", err.Error(), "content", c.PostForm("content"))
|
||||
return
|
||||
}
|
||||
switch params.ContentType {
|
||||
@@ -148,33 +118,27 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
data = CustomElem{}
|
||||
case constant.Revoke:
|
||||
data = RevokeElem{}
|
||||
case constant.AdvancedRevoke:
|
||||
data = MessageRevoked{}
|
||||
case constant.OANotification:
|
||||
data = OANotificationElem{}
|
||||
params.SessionType = constant.NotificationChatType
|
||||
case constant.CustomNotTriggerConversation:
|
||||
data = CustomElem{}
|
||||
case constant.CustomOnlineOnly:
|
||||
data = CustomElem{}
|
||||
//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"))
|
||||
log.ErrorByKv("contentType err", c.PostForm("operationID"), "content", 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())
|
||||
log.ErrorByKv("content to Data struct err", "", "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())
|
||||
log.ErrorByKv("data args validate err", "", "err", err.Error())
|
||||
return
|
||||
}
|
||||
log.NewInfo(params.OperationID, data, params)
|
||||
log.NewInfo("", data, params)
|
||||
token := c.Request.Header.Get("token")
|
||||
claims, err := token_verify.ParseToken(token, params.OperationID)
|
||||
if err != nil {
|
||||
@@ -194,7 +158,7 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 405, "errMsg": "recvID is a null string", "sendTime": 0, "MsgID": ""})
|
||||
return
|
||||
}
|
||||
case constant.GroupChatType, constant.SuperGroupChatType:
|
||||
case constant.GroupChatType:
|
||||
if len(params.GroupID) == 0 {
|
||||
log.NewError(params.OperationID, "groupID is a null string")
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 405, "errMsg": "groupID is a null string", "sendTime": 0, "MsgID": ""})
|
||||
@@ -202,226 +166,54 @@ 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)
|
||||
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)
|
||||
client := pbChat.NewChatClient(etcdConn)
|
||||
|
||||
log.Info("", "", "api ManagementSendMsg call, api call rpc...")
|
||||
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, params.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := params.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(params.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := pbChat.NewMsgClient(etcdConn)
|
||||
log.Info(params.OperationID, "", "api ManagementSendMsg call, api call rpc...")
|
||||
var status int32
|
||||
RpcResp, err := client.SendMsg(context.Background(), pbData)
|
||||
if err != nil || (RpcResp != nil && RpcResp.ErrCode != 0) {
|
||||
status = constant.MsgSendFailed
|
||||
} else {
|
||||
status = constant.MsgSendSuccessed
|
||||
}
|
||||
|
||||
respSetSendMsgStatus, err2 := client.SetSendMsgStatus(context.Background(), &pbChat.SetSendMsgStatusReq{OperationID: params.OperationID, Status: status})
|
||||
if err2 != nil {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err2.Error())
|
||||
}
|
||||
if respSetSendMsgStatus != nil && respSetSendMsgStatus.ErrCode != 0 {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), respSetSendMsgStatus.ErrCode, respSetSendMsgStatus.ErrMsg)
|
||||
}
|
||||
|
||||
log.Info(params.OperationID, "", "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: open_im_sdk.UserSendMsgResp{ServerMsgID: RpcResp.ServerMsgID, ClientMsgID: RpcResp.ClientMsgID, SendTime: RpcResp.SendTime}}
|
||||
log.Info(params.OperationID, "ManagementSendMsg return", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 管理员批量发送群聊单聊消息
|
||||
// @Description 管理员批量发送群聊单聊消息 消息格式详细见<a href="https://doc.rentsoft.cn/#/server_doc/admin?id=%e6%b6%88%e6%81%af%e7%b1%bb%e5%9e%8b%e6%a0%bc%e5%bc%8f%e6%8f%8f%e8%bf%b0">消息格式</href>
|
||||
// @Tags 消息相关
|
||||
// @ID ManagementBatchSendMsg
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param 管理员批量发送单聊消息 body api.ManagementBatchSendMsgReq{content=TextElem{}} true "该请求和消息结构体一样 <br> recvIDList为接受消息的用户ID列表"
|
||||
// @Param 管理员批量发送OA通知 body api.ManagementSendMsgReq{content=OANotificationElem{}} true "该请求和消息结构体一样 <br> recvIDList为接受消息的用户ID列表"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.ManagementBatchSendMsgReq "serverMsgID为服务器消息ID <br> clientMsgID为客户端消息ID <br> sendTime为发送消息时间"
|
||||
// @Failure 500 {object} api.ManagementBatchSendMsgReq "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.ManagementBatchSendMsgReq "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /msg/batch_send_msg [post]
|
||||
func ManagementBatchSendMsg(c *gin.Context) {
|
||||
var data interface{}
|
||||
params := api.ManagementBatchSendMsgReq{}
|
||||
resp := api.ManagementBatchSendMsgResp{}
|
||||
resp.Data.FailedIDList = make([]string, 0)
|
||||
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"))
|
||||
return
|
||||
}
|
||||
switch params.ContentType {
|
||||
case constant.Text:
|
||||
data = TextElem{}
|
||||
case constant.Picture:
|
||||
data = PictureElem{}
|
||||
case constant.Voice:
|
||||
data = SoundElem{}
|
||||
case constant.Video:
|
||||
data = VideoElem{}
|
||||
case constant.File:
|
||||
data = FileElem{}
|
||||
//case constant.AtText:
|
||||
// data = AtElem{}
|
||||
//case constant.Merger:
|
||||
// data =
|
||||
//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.CustomNotTriggerConversation:
|
||||
data = CustomElem{}
|
||||
case constant.CustomOnlineOnly:
|
||||
data = CustomElem{}
|
||||
//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)
|
||||
var msgSendFailedFlag bool
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, params.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := params.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(params.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "rpc server error: etcdConn == nil"})
|
||||
return
|
||||
}
|
||||
client := pbChat.NewMsgClient(etcdConn)
|
||||
respSetSendMsgStatus, err := client.SetSendMsgStatus(context.Background(), &pbChat.SetSendMsgStatusReq{OperationID: params.OperationID, Status: constant.MsgIsSending})
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call UserSendMsg rpc server failed"})
|
||||
return
|
||||
}
|
||||
if respSetSendMsgStatus.ErrCode != 0 {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), "rpc failed", respSetSendMsgStatus)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": respSetSendMsgStatus.ErrMsg})
|
||||
return
|
||||
}
|
||||
|
||||
req := &api.ManagementSendMsgReq{
|
||||
ManagementSendMsg: params.ManagementSendMsg,
|
||||
}
|
||||
pbData := newUserSendMsgReq(req)
|
||||
var recvList []string
|
||||
if params.IsSendAll {
|
||||
recvList, err = im_mysql_model.SelectAllUserID()
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
}
|
||||
} else {
|
||||
recvList = params.RecvIDList
|
||||
}
|
||||
for _, recvID := range recvList {
|
||||
pbData.MsgData.RecvID = recvID
|
||||
log.Info(params.OperationID, "", "api ManagementSendMsg call start..., ", pbData.String())
|
||||
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)
|
||||
msgSendFailedFlag = true
|
||||
continue
|
||||
}
|
||||
if rpcResp.ErrCode != 0 {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), "rpc failed", pbData, rpcResp)
|
||||
resp.Data.FailedIDList = append(resp.Data.FailedIDList, recvID)
|
||||
msgSendFailedFlag = true
|
||||
continue
|
||||
}
|
||||
resp.Data.ResultList = append(resp.Data.ResultList, &api.SingleReturnResult{
|
||||
ServerMsgID: rpcResp.ServerMsgID,
|
||||
ClientMsgID: rpcResp.ClientMsgID,
|
||||
SendTime: rpcResp.SendTime,
|
||||
RecvID: recvID,
|
||||
})
|
||||
}
|
||||
var status int32
|
||||
if msgSendFailedFlag {
|
||||
status = constant.MsgSendFailed
|
||||
} else {
|
||||
status = constant.MsgSendSuccessed
|
||||
}
|
||||
respSetSendMsgStatus, err2 := client.SetSendMsgStatus(context.Background(), &pbChat.SetSendMsgStatusReq{OperationID: params.OperationID, Status: status})
|
||||
if err2 != nil {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err2.Error())
|
||||
}
|
||||
if respSetSendMsgStatus != nil && resp.ErrCode != 0 {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), resp.ErrCode, resp.ErrMsg)
|
||||
}
|
||||
|
||||
log.NewInfo(params.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
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}}
|
||||
log.Info(params.OperationID, "ManagementSendMsg return", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
|
||||
}
|
||||
|
||||
func CheckMsgIsSendSuccess(c *gin.Context) {
|
||||
var req api.CheckMsgIsSendSuccessReq
|
||||
var resp api.CheckMsgIsSendSuccessResp
|
||||
if err := c.BindJSON(&req); 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"))
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
client := pbChat.NewMsgClient(etcdConn)
|
||||
rpcResp, err := client.GetSendMsgStatus(context.Background(), &pbChat.GetSendMsgStatusReq{OperationID: req.OperationID})
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call GetSendMsgStatus rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp.ErrMsg = rpcResp.ErrMsg
|
||||
resp.ErrCode = rpcResp.ErrCode
|
||||
resp.Status = rpcResp.Status
|
||||
c.JSON(http.StatusOK, resp)
|
||||
//
|
||||
//type MergeElem struct {
|
||||
// Title string `json:"title"`
|
||||
// AbstractList []string `json:"abstractList"`
|
||||
// MultiMessage []*MsgStruct `json:"multiMessage"`
|
||||
//}
|
||||
//
|
||||
//type QuoteElem struct {
|
||||
// Text string `json:"text"`
|
||||
// QuoteMessage *MsgStruct `json:"quoteMessage"`
|
||||
//}
|
||||
type ManagementSendMsgReq struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
SendID string `json:"sendID" binding:"required"`
|
||||
RecvID string `json:"recvID" `
|
||||
GroupID string `json:"groupID" `
|
||||
SenderNickname string `json:"senderNickname" `
|
||||
SenderFaceURL string `json:"senderFaceURL" `
|
||||
SenderPlatformID int32 `json:"senderPlatformID"`
|
||||
ForceList []string `json:"forceList" `
|
||||
Content map[string]interface{} `json:"content" binding:"required"`
|
||||
ContentType int32 `json:"contentType" binding:"required"`
|
||||
SessionType int32 `json:"sessionType" binding:"required"`
|
||||
IsOnlineOnly bool `json:"isOnlineOnly"`
|
||||
OfflinePushInfo *open_im_sdk.OfflinePushInfo `json:"offlinePushInfo"`
|
||||
}
|
||||
|
||||
type PictureBaseInfo struct {
|
||||
@@ -490,22 +282,15 @@ type RevokeElem struct {
|
||||
RevokeMsgClientID string `mapstructure:"revokeMsgClientID" validate:"required"`
|
||||
}
|
||||
type OANotificationElem struct {
|
||||
NotificationName string `mapstructure:"notificationName" json:"notificationName" validate:"required"`
|
||||
NotificationFaceURL string `mapstructure:"notificationFaceURL" json:"notificationFaceURL"`
|
||||
NotificationType int32 `mapstructure:"notificationType" json:"notificationType" validate:"required"`
|
||||
Text string `mapstructure:"text" json:"text" validate:"required"`
|
||||
Url string `mapstructure:"url" json:"url"`
|
||||
MixType int32 `mapstructure:"mixType" json:"mixType"`
|
||||
PictureElem PictureElem `mapstructure:"pictureElem" json:"pictureElem"`
|
||||
SoundElem SoundElem `mapstructure:"soundElem" json:"soundElem"`
|
||||
VideoElem VideoElem `mapstructure:"videoElem" json:"videoElem"`
|
||||
FileElem FileElem `mapstructure:"fileElem" json:"fileElem"`
|
||||
Ex string `mapstructure:"ex" json:"ex"`
|
||||
}
|
||||
type MessageRevoked struct {
|
||||
RevokerID string `mapstructure:"notificationName" json:"revokerID" validate:"required"`
|
||||
RevokerRole int32 `mapstructure:"notificationName" json:"revokerRole" validate:"required"`
|
||||
ClientMsgID string `mapstructure:"notificationName" json:"clientMsgID" validate:"required"`
|
||||
RevokerNickname string `mapstructure:"notificationName" json:"revokerNickname"`
|
||||
SessionType int32 `mapstructure:"notificationName" json:"sessionType" validate:"required"`
|
||||
NotificationName string `mapstructure:"notificationName" validate:"required"`
|
||||
NotificationFaceURL string `mapstructure:"notificationFaceURL" validate:"required"`
|
||||
NotificationType int32 `mapstructure:"notificationType" validate:"required"`
|
||||
Text string `mapstructure:"text" validate:"required"`
|
||||
Url string `mapstructure:"url"`
|
||||
MixType int32 `mapstructure:"mixType"`
|
||||
PictureElem PictureElem `mapstructure:"pictureElem"`
|
||||
SoundElem SoundElem `mapstructure:"soundElem"`
|
||||
VideoElem VideoElem `mapstructure:"videoElem"`
|
||||
FileElem FileElem `mapstructure:"fileElem"`
|
||||
Ex string `mapstructure:"ex"`
|
||||
}
|
||||
|
||||
@@ -17,24 +17,43 @@ import (
|
||||
rpc "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Summary 获取所有用户uid列表
|
||||
// @Description 获取所有用户uid列表
|
||||
// @Tags 用户相关
|
||||
// @ID GetAllUsersUid
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetAllUsersUidReq true "请求体"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetAllUsersUidResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /user/get_all_users_uid [post]
|
||||
func DeleteUser(c *gin.Context) {
|
||||
params := api.DeleteUsersReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.DeleteUsersReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
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)
|
||||
client := rpc.NewUserClient(etcdConn)
|
||||
|
||||
RpcResp, err := client.DeleteUsers(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "call delete users rpc server failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call delete users rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.DeleteUsersResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, FailedUserIDList: RpcResp.FailedUserIDList}
|
||||
if len(RpcResp.FailedUserIDList) == 0 {
|
||||
resp.FailedUserIDList = []string{}
|
||||
}
|
||||
log.NewInfo(req.OperationID, "DeleteUser api return", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
func GetAllUsersUid(c *gin.Context) {
|
||||
params := api.GetAllUsersUidReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -43,25 +62,15 @@ func GetAllUsersUid(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.GetAllUserIDReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, req.OpUserID = 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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(params.OperationID, "GetAllUsersUid args ", req.String())
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImUserName)
|
||||
client := rpc.NewUserClient(etcdConn)
|
||||
RpcResp, err := client.GetAllUserID(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -77,19 +86,6 @@ func GetAllUsersUid(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
|
||||
}
|
||||
|
||||
// @Summary 检查列表账户注册状态,并且返回结果
|
||||
// @Description 传入UserIDList检查列表账户注册状态,并且返回结果
|
||||
// @Tags 用户相关
|
||||
// @ID AccountCheck
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.AccountCheckReq true "请求体"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.AccountCheckResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /user/account_check [post]
|
||||
func AccountCheck(c *gin.Context) {
|
||||
params := api.AccountCheckReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -98,25 +94,15 @@ func AccountCheck(c *gin.Context) {
|
||||
}
|
||||
req := &rpc.AccountCheckReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, req.OpUserID = 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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(params.OperationID, "AccountCheck args ", req.String())
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImUserName)
|
||||
client := rpc.NewUserClient(etcdConn)
|
||||
|
||||
RpcResp, err := client.AccountCheck(context.Background(), req)
|
||||
@@ -141,14 +127,11 @@ func GetUsersOnlineStatus(c *gin.Context) {
|
||||
}
|
||||
req := &pbRelay.GetUsersOnlineStatusReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, req.OpUserID = 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})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -156,9 +139,9 @@ func GetUsersOnlineStatus(c *gin.Context) {
|
||||
var wsResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
||||
var respResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
||||
flag := false
|
||||
grpcCons := getcdv3.GetDefaultGatewayConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), params.OperationID)
|
||||
grpcCons := getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOnlineMessageRelayName)
|
||||
for _, v := range grpcCons {
|
||||
client := pbRelay.NewRelayClient(v)
|
||||
client := pbRelay.NewOnlineMessageRelayServiceClient(v)
|
||||
reply, err := client.GetUsersOnlineStatus(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "GetUsersOnlineStatus rpc err", req.String(), err.Error())
|
||||
|
||||
@@ -1,273 +0,0 @@
|
||||
package msg
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
rpc "Open_IM/pkg/proto/msg"
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// @Summary 根据seq列表删除消息
|
||||
// @Description 根据seq列表删除消息
|
||||
// @Tags 消息相关
|
||||
// @ID DelMsg
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.DelMsgReq true "userID为要删除的用户ID <br> seqList为seq列表"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.DelMsgResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /msg/del_msg [post]
|
||||
func DelMsg(c *gin.Context) {
|
||||
var (
|
||||
req api.DelMsgReq
|
||||
resp api.DelMsgResp
|
||||
reqPb pbCommon.DelMsgListReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": 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(), "CopyStructFields", 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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
grpcConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
msgClient := rpc.NewMsgClient(grpcConn)
|
||||
respPb, err := msgClient.DelMsgList(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsgList failed", err.Error(), reqPb)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.ErrServer.ErrCode, "errMsg": constant.ErrServer.ErrMsg + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.ErrCode = respPb.ErrCode
|
||||
resp.ErrMsg = respPb.ErrMsg
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
func DelSuperGroupMsg(c *gin.Context) {
|
||||
var (
|
||||
req api.DelSuperGroupMsgReq
|
||||
resp api.DelSuperGroupMsgResp
|
||||
)
|
||||
rpcReq := &rpc.DelSuperGroupMsgReq{}
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(rpcReq, &req)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, rpcReq.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
errMsg := req.OperationID + " " + rpcReq.OpUserID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
options := make(map[string]bool, 5)
|
||||
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsSenderConversationUpdate, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsUnreadCount, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
||||
pbData := rpc.SendMsgReq{
|
||||
OperationID: req.OperationID,
|
||||
MsgData: &pbCommon.MsgData{
|
||||
SendID: req.UserID,
|
||||
RecvID: req.UserID,
|
||||
ClientMsgID: utils.GetMsgID(req.UserID),
|
||||
SessionType: constant.SingleChatType,
|
||||
MsgFrom: constant.SysMsgType,
|
||||
ContentType: constant.MsgDeleteNotification,
|
||||
// ForceList: params.ForceList,
|
||||
CreateTime: utils.GetCurrentTimestampByMill(),
|
||||
Options: options,
|
||||
},
|
||||
}
|
||||
var tips pbCommon.TipsComm
|
||||
deleteMsg := api.MsgDeleteNotificationElem{
|
||||
GroupID: req.GroupID,
|
||||
IsAllDelete: req.IsAllDelete,
|
||||
SeqList: req.SeqList,
|
||||
}
|
||||
tips.JsonDetail = utils.StructToJsonString(deleteMsg)
|
||||
var err error
|
||||
pbData.MsgData.Content, err = proto.Marshal(&tips)
|
||||
if err != nil {
|
||||
log.Error(req.OperationID, "Marshal failed ", err.Error(), tips.String())
|
||||
resp.ErrCode = 400
|
||||
resp.ErrMsg = err.Error()
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
log.Info(req.OperationID, "", "api DelSuperGroupMsg call start..., [data: %s]", pbData.String())
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := rpc.NewMsgClient(etcdConn)
|
||||
|
||||
log.Info(req.OperationID, "", "api DelSuperGroupMsg call, api call rpc...")
|
||||
if req.IsAllDelete {
|
||||
RpcResp, err := client.DelSuperGroupMsg(context.Background(), rpcReq)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "call delete DelSuperGroupMsg rpc server failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call DelSuperGroupMsg rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.Info(req.OperationID, "", "api DelSuperGroupMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
|
||||
resp.ErrCode = RpcResp.ErrCode
|
||||
resp.ErrMsg = RpcResp.ErrMsg
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
} else {
|
||||
RpcResp, err := client.SendMsg(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call UserSendMsg rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.Info(req.OperationID, "", "api DelSuperGroupMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
|
||||
resp.ErrCode = RpcResp.ErrCode
|
||||
resp.ErrMsg = RpcResp.ErrMsg
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// @Summary 清空用户消息
|
||||
// @Description 清空用户消息
|
||||
// @Tags 消息相关
|
||||
// @ID ClearMsg
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.CleanUpMsgReq true "userID为要清空的用户ID"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.CleanUpMsgResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /msg/clear_msg [post]
|
||||
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.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := rpc.NewMsgClient(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)
|
||||
}
|
||||
|
||||
// @Summary 设置用户最小seq
|
||||
// @Description 设置用户最小seq,以及用户相关读扩散群组最小seq
|
||||
// @Tags 消息相关
|
||||
// @ID SetMsgMinSeq
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
func SetMsgMinSeq(c *gin.Context) {
|
||||
params := api.SetMsgMinSeqReq{}
|
||||
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.SetMsgMinSeqReq{}
|
||||
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.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
client := rpc.NewMsgClient(etcdConn)
|
||||
RpcResp, err := client.SetMsgMinSeq(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, " SetMsgMinSeq failed ", err.Error(), req.String(), RpcResp.ErrMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": RpcResp.ErrMsg})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.SetMsgMinSeqResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
+46
-216
@@ -1,7 +1,7 @@
|
||||
package office
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
apistruct "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
@@ -11,27 +11,14 @@ import (
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"google.golang.org/grpc"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// @Summary 获取用户标签信息
|
||||
// @Description 用户获取自己的所有的标签
|
||||
// @Tags 标签
|
||||
// @ID GetUserTags
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetUserTagsReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetUserTagsResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/get_user_tags [post]
|
||||
func GetUserTags(c *gin.Context) {
|
||||
var (
|
||||
req api.GetUserTagsReq
|
||||
resp api.GetUserTagsResp
|
||||
req apistruct.GetUserTagsReq
|
||||
resp apistruct.GetUserTagsResp
|
||||
reqPb pbOffice.GetUserTagsReq
|
||||
respPb *pbOffice.GetUserTagsResp
|
||||
)
|
||||
@@ -40,27 +27,15 @@ func GetUserTags(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := 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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb.UserID = userID
|
||||
reqPb.OperationID = req.OperationID
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.GetUserTags(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -79,22 +54,10 @@ func GetUserTags(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 创建标签
|
||||
// @Description 创建标签
|
||||
// @Tags 标签
|
||||
// @ID CreateTag
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.CreateTagReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.CreateTagResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/create_tag [post]
|
||||
func CreateTag(c *gin.Context) {
|
||||
var (
|
||||
req api.CreateTagReq
|
||||
resp api.CreateTagResp
|
||||
req apistruct.CreateTagReq
|
||||
resp apistruct.CreateTagResp
|
||||
reqPb pbOffice.CreateTagReq
|
||||
respPb *pbOffice.CreateTagResp
|
||||
)
|
||||
@@ -106,26 +69,14 @@ func CreateTag(c *gin.Context) {
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := 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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.CreateTag(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -139,22 +90,10 @@ func CreateTag(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 删除标签
|
||||
// @Description 根据标签ID创建标签
|
||||
// @Tags 标签
|
||||
// @ID DeleteTag
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.DeleteTagReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.DeleteTagResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/delete_tag [post]
|
||||
func DeleteTag(c *gin.Context) {
|
||||
var (
|
||||
req api.DeleteTagReq
|
||||
resp api.DeleteTagResp
|
||||
req apistruct.DeleteTagReq
|
||||
resp apistruct.DeleteTagResp
|
||||
reqPb pbOffice.DeleteTagReq
|
||||
respPb *pbOffice.DeleteTagResp
|
||||
)
|
||||
@@ -166,26 +105,14 @@ func DeleteTag(c *gin.Context) {
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := 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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.DeleteTag(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -199,22 +126,10 @@ func DeleteTag(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 修改标签
|
||||
// @Description 根据标签ID修改标签用户列表, 名称
|
||||
// @Tags 标签
|
||||
// @ID SetTag
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.SetTagReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.SetTagResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/set_tag [post]
|
||||
func SetTag(c *gin.Context) {
|
||||
var (
|
||||
req api.SetTagReq
|
||||
resp api.SetTagResp
|
||||
req apistruct.SetTagReq
|
||||
resp apistruct.SetTagResp
|
||||
reqPb pbOffice.SetTagReq
|
||||
respPb *pbOffice.SetTagResp
|
||||
)
|
||||
@@ -226,26 +141,14 @@ func SetTag(c *gin.Context) {
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := 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})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.SetTag(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -259,22 +162,10 @@ func SetTag(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 发送标签消息
|
||||
// @Description 对标签用户发送消息
|
||||
// @Tags 标签
|
||||
// @ID SendMsg2Tag
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.SendMsg2TagReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.SendMsg2TagResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/send_msg_to_tag [post]
|
||||
func SendMsg2Tag(c *gin.Context) {
|
||||
var (
|
||||
req api.SendMsg2TagReq
|
||||
resp api.SendMsg2TagResp
|
||||
req apistruct.SendMsg2TagReq
|
||||
resp apistruct.SendMsg2TagResp
|
||||
reqPb pbOffice.SendMsg2TagReq
|
||||
respPb *pbOffice.SendMsg2TagResp
|
||||
)
|
||||
@@ -286,26 +177,14 @@ func SendMsg2Tag(c *gin.Context) {
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := 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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb.SendID = userID
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.SendMsg2Tag(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -319,22 +198,10 @@ func SendMsg2Tag(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 获取发送历史记录
|
||||
// @Description 分页获取发送历史记录
|
||||
// @Tags 标签
|
||||
// @ID GetTagSendLogs
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetTagSendLogsReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetTagSendLogsResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/get_send_tag_log [post]
|
||||
func GetTagSendLogs(c *gin.Context) {
|
||||
var (
|
||||
req api.GetTagSendLogsReq
|
||||
resp api.GetTagSendLogsResp
|
||||
req apistruct.GetTagSendLogsReq
|
||||
resp apistruct.GetTagSendLogsResp
|
||||
reqPb pbOffice.GetTagSendLogsReq
|
||||
respPb *pbOffice.GetTagSendLogsResp
|
||||
)
|
||||
@@ -343,37 +210,24 @@ func GetTagSendLogs(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := 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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb.UserID = userID
|
||||
reqPb.OperationID = req.OperationID
|
||||
reqPb.Pagination = &pbCommon.RequestPagination{
|
||||
PageNumber: req.PageNumber,
|
||||
ShowNumber: req.ShowNumber,
|
||||
}
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
maxSizeOption := grpc.MaxCallRecvMsgSize(1024 * 1024 * 20)
|
||||
respPb, err := client.GetTagSendLogs(context.Background(), &reqPb, maxSizeOption)
|
||||
respPb, err := client.GetTagSendLogs(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetTagSendLogs failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetTagSendLogs rpc server failed" + err.Error()})
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserTags failed", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateTag rpc server failed" + err.Error()})
|
||||
return
|
||||
}
|
||||
if err := utils.CopyStructFields(&resp.CommResp, respPb.CommonResp); err != nil {
|
||||
@@ -389,22 +243,10 @@ func GetTagSendLogs(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 获取该用户的标签信息
|
||||
// @Description 通过标签id获取该用户的标签信息
|
||||
// @Tags 标签
|
||||
// @ID GetUserTagByID
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetUserTagByIDReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetUserTagByIDResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/get_user_tag_by_id [post]
|
||||
func GetUserTagByID(c *gin.Context) {
|
||||
var (
|
||||
req api.GetUserTagByIDReq
|
||||
resp api.GetUserTagByIDResp
|
||||
req apistruct.GetUserTagByIDReq
|
||||
resp apistruct.GetUserTagByIDResp
|
||||
reqPb pbOffice.GetUserTagByIDReq
|
||||
respPb *pbOffice.GetUserTagByIDResp
|
||||
)
|
||||
@@ -413,28 +255,16 @@ func GetUserTagByID(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := 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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb.UserID = userID
|
||||
reqPb.OperationID = req.OperationID
|
||||
reqPb.TagID = req.TagID
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.GetUserTagByID(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package office
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
apiStruct "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
@@ -15,22 +15,10 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// @Summary 创建一条工作圈
|
||||
// @Description 用户创建一条工作圈
|
||||
// @Tags 工作圈
|
||||
// @ID CreateOneWorkMoment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.CreateOneWorkMomentReq true "请求 atUserList likeUserList permissionGroupList permissionUserList 字段中userName可以不填"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.CreateOneWorkMomentResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/create_one_work_moment [post]
|
||||
func CreateOneWorkMoment(c *gin.Context) {
|
||||
var (
|
||||
req api.CreateOneWorkMomentReq
|
||||
resp api.CreateOneWorkMomentResp
|
||||
req apiStruct.CreateOneWorkMomentReq
|
||||
resp apiStruct.CreateOneWorkMomentResp
|
||||
reqPb pbOffice.CreateOneWorkMomentReq
|
||||
respPb *pbOffice.CreateOneWorkMomentResp
|
||||
)
|
||||
@@ -40,30 +28,17 @@ func CreateOneWorkMoment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := 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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
reqPb.WorkMoment.UserID = userID
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.CreateOneWorkMoment(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -71,7 +46,7 @@ func CreateOneWorkMoment(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateOneWorkMoment rpc server failed" + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.CommResp = api.CommResp{
|
||||
resp.CommResp = apiStruct.CommResp{
|
||||
ErrCode: respPb.CommonResp.ErrCode,
|
||||
ErrMsg: respPb.CommonResp.ErrMsg,
|
||||
}
|
||||
@@ -79,22 +54,10 @@ func CreateOneWorkMoment(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 删除一条工作圈
|
||||
// @Description 根据用户工作圈ID删除一条工作圈
|
||||
// @Tags 工作圈
|
||||
// @ID DeleteOneWorkMoment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.DeleteOneWorkMomentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.DeleteOneWorkMomentResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/delete_one_work_moment [post]
|
||||
func DeleteOneWorkMoment(c *gin.Context) {
|
||||
var (
|
||||
req api.DeleteOneWorkMomentReq
|
||||
resp api.DeleteOneWorkMomentResp
|
||||
req apiStruct.DeleteOneWorkMomentReq
|
||||
resp apiStruct.DeleteOneWorkMomentResp
|
||||
reqPb pbOffice.DeleteOneWorkMomentReq
|
||||
respPb *pbOffice.DeleteOneWorkMomentResp
|
||||
)
|
||||
@@ -104,30 +67,17 @@ func DeleteOneWorkMoment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := 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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.DeleteOneWorkMoment(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -142,22 +92,10 @@ func DeleteOneWorkMoment(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 点赞一条工作圈
|
||||
// @Description 工作圈ID点赞一条工作圈
|
||||
// @Tags 工作圈
|
||||
// @ID LikeOneWorkMoment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.LikeOneWorkMomentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.LikeOneWorkMomentResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/like_one_work_moment [post]
|
||||
func LikeOneWorkMoment(c *gin.Context) {
|
||||
var (
|
||||
req api.LikeOneWorkMomentReq
|
||||
resp api.LikeOneWorkMomentResp
|
||||
req apiStruct.LikeOneWorkMomentReq
|
||||
resp apiStruct.LikeOneWorkMomentResp
|
||||
reqPb pbOffice.LikeOneWorkMomentReq
|
||||
respPb *pbOffice.LikeOneWorkMomentResp
|
||||
)
|
||||
@@ -167,29 +105,17 @@ func LikeOneWorkMoment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := 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})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.LikeOneWorkMoment(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -204,22 +130,10 @@ func LikeOneWorkMoment(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 评论一条工作圈
|
||||
// @Description 评论一条工作圈
|
||||
// @Tags 工作圈
|
||||
// @ID CommentOneWorkMoment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.CommentOneWorkMomentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.CommentOneWorkMomentResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/comment_one_work_moment [post]
|
||||
func CommentOneWorkMoment(c *gin.Context) {
|
||||
var (
|
||||
req api.CommentOneWorkMomentReq
|
||||
resp api.CommentOneWorkMomentResp
|
||||
req apiStruct.CommentOneWorkMomentReq
|
||||
resp apiStruct.CommentOneWorkMomentResp
|
||||
reqPb pbOffice.CommentOneWorkMomentReq
|
||||
respPb *pbOffice.CommentOneWorkMomentResp
|
||||
)
|
||||
@@ -229,29 +143,17 @@ func CommentOneWorkMoment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := 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})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.CommentOneWorkMoment(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -266,82 +168,10 @@ func CommentOneWorkMoment(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 删除一条评论
|
||||
// @Description 删除一条评论
|
||||
// @Tags 工作圈
|
||||
// @ID DeleteComment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.DeleteCommentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.DeleteCommentResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/delete_comment [post]
|
||||
func DeleteComment(c *gin.Context) {
|
||||
var (
|
||||
req api.DeleteCommentReq
|
||||
resp api.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.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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)
|
||||
}
|
||||
|
||||
// @Summary 通过ID获取工作圈
|
||||
// @Description 通过ID获取工作圈
|
||||
// @Tags 工作圈
|
||||
// @ID GetWorkMomentByID
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetWorkMomentByIDReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetWorkMomentByIDResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/get_work_moment_by_id [post]
|
||||
func GetWorkMomentByID(c *gin.Context) {
|
||||
var (
|
||||
req api.GetWorkMomentByIDReq
|
||||
resp api.GetWorkMomentByIDResp
|
||||
req apiStruct.GetWorkMomentByIDReq
|
||||
resp apiStruct.GetWorkMomentByIDResp
|
||||
reqPb pbOffice.GetWorkMomentByIDReq
|
||||
respPb *pbOffice.GetWorkMomentByIDResp
|
||||
)
|
||||
@@ -351,28 +181,16 @@ func GetWorkMomentByID(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := 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})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb.OperationID = req.OperationID
|
||||
reqPb.OpUserID = userID
|
||||
reqPb.WorkMomentID = req.WorkMomentID
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.GetWorkMomentByID(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -383,8 +201,8 @@ func GetWorkMomentByID(c *gin.Context) {
|
||||
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
resp.Data.WorkMoment = &api.WorkMoment{LikeUserList: []*api.WorkMomentUser{}, Comments: []*api.Comment{},
|
||||
AtUserList: []*api.WorkMomentUser{}, PermissionUserList: []*api.WorkMomentUser{}}
|
||||
//resp.Data.WorkMoment = respPb.WorkMoment
|
||||
resp.Data.WorkMoment = &apiStruct.WorkMoment{}
|
||||
if err := utils.CopyStructFields(&resp.Data.WorkMoment, respPb.WorkMoment); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
@@ -392,22 +210,10 @@ func GetWorkMomentByID(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 查询用户工作圈
|
||||
// @Description 查询用户工作圈
|
||||
// @Tags 工作圈
|
||||
// @ID GetUserWorkMoments
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetUserWorkMomentsReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetUserWorkMomentsResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/get_user_work_moments [post]
|
||||
func GetUserWorkMoments(c *gin.Context) {
|
||||
var (
|
||||
req api.GetUserWorkMomentsReq
|
||||
resp api.GetUserWorkMomentsResp
|
||||
req apiStruct.GetUserWorkMomentsReq
|
||||
resp apiStruct.GetUserWorkMomentsResp
|
||||
reqPb pbOffice.GetUserWorkMomentsReq
|
||||
respPb *pbOffice.GetUserWorkMomentsResp
|
||||
)
|
||||
@@ -417,32 +223,19 @@ func GetUserWorkMoments(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var opUserID string
|
||||
ok, opUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := 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})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb.OperationID = req.OperationID
|
||||
reqPb.Pagination = &pbCommon.RequestPagination{
|
||||
PageNumber: req.PageNumber,
|
||||
ShowNumber: req.ShowNumber,
|
||||
}
|
||||
reqPb.OpUserID = opUserID
|
||||
reqPb.UserID = req.UserID
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.GetUserWorkMoments(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -450,54 +243,11 @@ func GetUserWorkMoments(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserWorkMoments rpc server failed" + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.Data.WorkMoments = []*api.WorkMoment{}
|
||||
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
for _, v := range respPb.WorkMoments {
|
||||
workMoment := api.WorkMoment{
|
||||
WorkMomentID: v.WorkMomentID,
|
||||
UserID: v.UserID,
|
||||
Content: v.Content,
|
||||
FaceURL: v.FaceURL,
|
||||
UserName: v.UserName,
|
||||
CreateTime: v.CreateTime,
|
||||
Comments: make([]*api.Comment, len(v.Comments)),
|
||||
LikeUserList: make([]*api.WorkMomentUser, len(v.LikeUserList)),
|
||||
AtUserList: make([]*api.WorkMomentUser, len(v.AtUserList)),
|
||||
PermissionUserList: make([]*api.WorkMomentUser, len(v.PermissionUserList)),
|
||||
Permission: v.Permission,
|
||||
}
|
||||
for i, comment := range v.Comments {
|
||||
workMoment.Comments[i] = &api.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] = &api.WorkMomentUser{
|
||||
UserID: likeUser.UserID,
|
||||
UserName: likeUser.UserName,
|
||||
}
|
||||
}
|
||||
for i, atUser := range v.AtUserList {
|
||||
workMoment.AtUserList[i] = &api.WorkMomentUser{
|
||||
UserID: atUser.UserID,
|
||||
UserName: atUser.UserName,
|
||||
}
|
||||
}
|
||||
for i, permissionUser := range v.PermissionUserList {
|
||||
workMoment.PermissionUserList[i] = &api.WorkMomentUser{
|
||||
UserID: permissionUser.UserID,
|
||||
UserName: permissionUser.UserName,
|
||||
}
|
||||
}
|
||||
resp.Data.WorkMoments = append(resp.Data.WorkMoments, &workMoment)
|
||||
if err := utils.CopyStructFields(&resp.Data.WorkMoments, respPb.WorkMoments); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
resp.Data.ShowNumber = respPb.Pagination.ShowNumber
|
||||
resp.Data.CurrentPage = respPb.Pagination.CurrentPage
|
||||
@@ -505,22 +255,10 @@ func GetUserWorkMoments(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// @Summary 查询自己大工作圈页面
|
||||
// @Description 查询用户工作圈页面
|
||||
// @Tags 工作圈
|
||||
// @ID GetUserFriendWorkMoments
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetUserFriendWorkMomentsReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetUserFriendWorkMomentsResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /office/get_user_friend_work_moments [post]
|
||||
func GetUserFriendWorkMoments(c *gin.Context) {
|
||||
var (
|
||||
req api.GetUserFriendWorkMomentsReq
|
||||
resp api.GetUserFriendWorkMomentsResp
|
||||
req apiStruct.GetUserFriendWorkMomentsReq
|
||||
resp apiStruct.GetUserFriendWorkMomentsResp
|
||||
reqPb pbOffice.GetUserFriendWorkMomentsReq
|
||||
respPb *pbOffice.GetUserFriendWorkMomentsResp
|
||||
)
|
||||
@@ -530,31 +268,19 @@ func GetUserFriendWorkMoments(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := 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})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
reqPb.OperationID = req.OperationID
|
||||
reqPb.Pagination = &pbCommon.RequestPagination{
|
||||
PageNumber: req.PageNumber,
|
||||
ShowNumber: req.ShowNumber,
|
||||
}
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.GetUserFriendWorkMoments(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
@@ -565,54 +291,8 @@ func GetUserFriendWorkMoments(c *gin.Context) {
|
||||
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
//if err := utils.CopyStructFields(&resp.Data.WorkMoments, respPb.WorkMoments); err != nil {
|
||||
// log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
//}
|
||||
resp.Data.WorkMoments = []*api.WorkMoment{}
|
||||
for _, v := range respPb.WorkMoments {
|
||||
workMoment := api.WorkMoment{
|
||||
WorkMomentID: v.WorkMomentID,
|
||||
UserID: v.UserID,
|
||||
Content: v.Content,
|
||||
FaceURL: v.FaceURL,
|
||||
UserName: v.UserName,
|
||||
CreateTime: v.CreateTime,
|
||||
Comments: make([]*api.Comment, len(v.Comments)),
|
||||
LikeUserList: make([]*api.WorkMomentUser, len(v.LikeUserList)),
|
||||
AtUserList: make([]*api.WorkMomentUser, len(v.AtUserList)),
|
||||
PermissionUserList: make([]*api.WorkMomentUser, len(v.PermissionUserList)),
|
||||
Permission: v.Permission,
|
||||
}
|
||||
for i, comment := range v.Comments {
|
||||
workMoment.Comments[i] = &api.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] = &api.WorkMomentUser{
|
||||
UserID: likeUser.UserID,
|
||||
UserName: likeUser.UserName,
|
||||
}
|
||||
}
|
||||
for i, atUser := range v.AtUserList {
|
||||
workMoment.AtUserList[i] = &api.WorkMomentUser{
|
||||
UserID: atUser.UserID,
|
||||
UserName: atUser.UserName,
|
||||
}
|
||||
}
|
||||
for i, permissionUser := range v.PermissionUserList {
|
||||
workMoment.PermissionUserList[i] = &api.WorkMomentUser{
|
||||
UserID: permissionUser.UserID,
|
||||
UserName: permissionUser.UserName,
|
||||
}
|
||||
}
|
||||
resp.Data.WorkMoments = append(resp.Data.WorkMoments, &workMoment)
|
||||
if err := utils.CopyStructFields(&resp.Data.WorkMoments, respPb.WorkMoments); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
resp.Data.ShowNumber = respPb.Pagination.ShowNumber
|
||||
resp.Data.CurrentPage = respPb.Pagination.CurrentPage
|
||||
@@ -622,8 +302,8 @@ func GetUserFriendWorkMoments(c *gin.Context) {
|
||||
|
||||
func SetUserWorkMomentsLevel(c *gin.Context) {
|
||||
var (
|
||||
req api.SetUserWorkMomentsLevelReq
|
||||
resp api.SetUserWorkMomentsLevelResp
|
||||
req apiStruct.SetUserWorkMomentsLevelReq
|
||||
resp apiStruct.SetUserWorkMomentsLevelResp
|
||||
reqPb pbOffice.SetUserWorkMomentsLevelReq
|
||||
respPb *pbOffice.SetUserWorkMomentsLevelResp
|
||||
)
|
||||
@@ -633,29 +313,17 @@ func SetUserWorkMomentsLevel(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||
|
||||
var ok bool
|
||||
var errInfo string
|
||||
var userID string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := 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})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
reqPb.UserID = userID
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfficeName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOfficeName)
|
||||
client := pbOffice.NewOfficeServiceClient(etcdConn)
|
||||
respPb, err := client.SetUserWorkMomentsLevel(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
|
||||
@@ -16,18 +16,6 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// @Summary 创建部门
|
||||
// @Description 创建部门
|
||||
// @Tags 组织架构相关
|
||||
// @ID CreateDepartment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.CreateDepartmentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.CreateDepartmentResp{data=open_im_sdk.Department}
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/create_department [post]
|
||||
func CreateDepartment(c *gin.Context) {
|
||||
params := api.CreateDepartmentReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -48,14 +36,7 @@ func CreateDepartment(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.CreateDepartment(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -71,18 +52,6 @@ func CreateDepartment(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, apiResp)
|
||||
}
|
||||
|
||||
// @Summary 更新部门信息
|
||||
// @Description 更新部门信息
|
||||
// @Tags 组织架构相关
|
||||
// @ID UpdateDepartment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.UpdateDepartmentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.UpdateDepartmentResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/update_department [post]
|
||||
func UpdateDepartment(c *gin.Context) {
|
||||
params := api.UpdateDepartmentReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -103,14 +72,7 @@ func UpdateDepartment(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.UpdateDepartment(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -125,18 +87,6 @@ func UpdateDepartment(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, apiResp)
|
||||
}
|
||||
|
||||
// @Summary 获取子部门列表
|
||||
// @Description 获取子部门列表
|
||||
// @Tags 组织架构相关
|
||||
// @ID GetSubDepartment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetSubDepartmentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetSubDepartmentResp{data=[]open_im_sdk.Department}
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/get_sub_department [post]
|
||||
func GetSubDepartment(c *gin.Context) {
|
||||
params := api.GetSubDepartmentReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -156,13 +106,7 @@ func GetSubDepartment(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.GetSubDepartment(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -182,18 +126,6 @@ func GetAllDepartment(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
// @Summary 删除部门
|
||||
// @Description 删除部门
|
||||
// @Tags 组织架构相关
|
||||
// @ID DeleteDepartment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.DeleteDepartmentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.DeleteDepartmentResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/delete_department [post]
|
||||
func DeleteDepartment(c *gin.Context) {
|
||||
params := api.DeleteDepartmentReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -212,13 +144,7 @@ func DeleteDepartment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.DeleteDepartment(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -233,18 +159,6 @@ func DeleteDepartment(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, apiResp)
|
||||
}
|
||||
|
||||
// @Summary 组织架构导入用户
|
||||
// @Description 组织架构导入用户
|
||||
// @Tags 组织架构相关
|
||||
// @ID CreateOrganizationUser
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.CreateOrganizationUserReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.CreateOrganizationUserResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/create_organization_user [post]
|
||||
func CreateOrganizationUser(c *gin.Context) {
|
||||
params := api.CreateOrganizationUserReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -266,13 +180,7 @@ func CreateOrganizationUser(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.CreateOrganizationUser(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -287,18 +195,6 @@ func CreateOrganizationUser(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, apiResp)
|
||||
}
|
||||
|
||||
// @Summary 更新组织架构中的用户
|
||||
// @Description 更新组织架构中的用户
|
||||
// @Tags 组织架构相关
|
||||
// @ID UpdateOrganizationUser
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.UpdateOrganizationUserReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.UpdateOrganizationUserResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/update_organization_user [post]
|
||||
func UpdateOrganizationUser(c *gin.Context) {
|
||||
params := api.UpdateOrganizationUserReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -319,13 +215,7 @@ func UpdateOrganizationUser(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.UpdateOrganizationUser(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -334,23 +224,12 @@ func UpdateOrganizationUser(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
apiResp := api.UpdateOrganizationUserResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api return ", apiResp)
|
||||
c.JSON(http.StatusOK, apiResp)
|
||||
}
|
||||
|
||||
// @Summary 创建部门用户
|
||||
// @Description 创建部门用户
|
||||
// @Tags 组织架构相关
|
||||
// @ID CreateDepartmentMember
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.CreateDepartmentMemberReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.CreateDepartmentMemberResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/create_department_member [post]
|
||||
func CreateDepartmentMember(c *gin.Context) {
|
||||
params := api.CreateDepartmentMemberReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -372,13 +251,7 @@ func CreateDepartmentMember(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.CreateDepartmentMember(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -393,18 +266,6 @@ func CreateDepartmentMember(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, apiResp)
|
||||
}
|
||||
|
||||
// @Summary 获取部门中的所有用户
|
||||
// @Description 获取部门中的所有用户
|
||||
// @Tags 组织架构相关
|
||||
// @ID GetUserInDepartment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetUserInDepartmentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetUserInDepartmentResp{data=open_im_sdk.UserInDepartment}
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/get_user_in_department [post]
|
||||
func GetUserInDepartment(c *gin.Context) {
|
||||
params := api.GetUserInDepartmentReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -425,13 +286,7 @@ func GetUserInDepartment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.GetUserInDepartment(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -447,18 +302,6 @@ func GetUserInDepartment(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, apiResp)
|
||||
}
|
||||
|
||||
// @Summary 更新部门中某个用户
|
||||
// @Description 更新部门中某个用户
|
||||
// @Tags 组织架构相关
|
||||
// @ID UpdateUserInDepartment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.UpdateUserInDepartmentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.UpdateUserInDepartmentResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/update_user_in_department [post]
|
||||
func UpdateUserInDepartment(c *gin.Context) {
|
||||
params := api.UpdateUserInDepartmentReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -479,13 +322,7 @@ func UpdateUserInDepartment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.UpdateUserInDepartment(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -500,18 +337,6 @@ func UpdateUserInDepartment(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, apiResp)
|
||||
}
|
||||
|
||||
// @Summary 删除组织架构中某个用户
|
||||
// @Description 删除组织架构中某个用户
|
||||
// @Tags 组织架构相关
|
||||
// @ID DeleteOrganizationUser
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.DeleteOrganizationUserReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.DeleteOrganizationUserResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/delete_organization_user [post]
|
||||
func DeleteOrganizationUser(c *gin.Context) {
|
||||
params := api.DeleteOrganizationUserReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -532,13 +357,7 @@ func DeleteOrganizationUser(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.DeleteOrganizationUser(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -553,18 +372,6 @@ func DeleteOrganizationUser(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, apiResp)
|
||||
}
|
||||
|
||||
// @Summary 获取部门中所有成员
|
||||
// @Description 获取部门中所有成员
|
||||
// @Tags 组织架构相关
|
||||
// @ID GetDepartmentMember
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.GetDepartmentMemberReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.GetDepartmentMemberResp{data=[]open_im_sdk.UserDepartmentMember}
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/get_department_member [post]
|
||||
func GetDepartmentMember(c *gin.Context) {
|
||||
params := api.GetDepartmentMemberReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -572,6 +379,7 @@ func GetDepartmentMember(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
req := &rpc.GetDepartmentMemberReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
|
||||
@@ -584,13 +392,7 @@ func GetDepartmentMember(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.GetDepartmentMember(context.Background(), req)
|
||||
if err != nil {
|
||||
@@ -606,18 +408,6 @@ func GetDepartmentMember(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, apiResp)
|
||||
}
|
||||
|
||||
// @Summary 删除部门中某个用户
|
||||
// @Description 删除部门中某个用户
|
||||
// @Tags 组织架构相关
|
||||
// @ID DeleteUserInDepartment
|
||||
// @Accept json
|
||||
// @Param token header string true "im token"
|
||||
// @Param req body api.DeleteUserInDepartmentReq true "请求"
|
||||
// @Produce json
|
||||
// @Success 0 {object} api.DeleteUserInDepartmentResp
|
||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||
// @Router /organization/delete_user_in_department [post]
|
||||
func DeleteUserInDepartment(c *gin.Context) {
|
||||
params := api.DeleteUserInDepartmentReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
@@ -637,13 +427,7 @@ func DeleteUserInDepartment(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "api args ", req.String(), "params", params)
|
||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
||||
if etcdConn == nil {
|
||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == 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.OpenImOrganizationName)
|
||||
client := rpc.NewOrganizationClient(etcdConn)
|
||||
RpcResp, err := client.DeleteUserInDepartment(context.Background(), req)
|
||||
if err != nil {
|
||||
|
||||
@@ -54,18 +54,12 @@ func AliOSSCredential(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var ok bool
|
||||
var userID string
|
||||
var errInfo string
|
||||
ok, userID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
ok, userID := 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})
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, "AliOSSCredential args ", userID)
|
||||
|
||||
stsResp, err := getStsClient().AssumeRole(&sts20150401.AssumeRoleRequest{
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
package apiThird
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
awsConfig "github.com/aws/aws-sdk-go-v2/config"
|
||||
"github.com/aws/aws-sdk-go-v2/credentials"
|
||||
"github.com/aws/aws-sdk-go-v2/service/sts"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func AwsStorageCredential(c *gin.Context) {
|
||||
var (
|
||||
req api.AwsStorageCredentialReq
|
||||
resp api.AwsStorageCredentialResp
|
||||
)
|
||||
if err := c.BindJSON(&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)
|
||||
var ok bool
|
||||
var errInfo string
|
||||
ok, _, 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
|
||||
}
|
||||
//原始帐号信息
|
||||
awsSourceConfig, err := awsConfig.LoadDefaultConfig(context.TODO(), awsConfig.WithRegion(config.Config.Credential.Aws.Region),
|
||||
awsConfig.WithCredentialsProvider(credentials.StaticCredentialsProvider{
|
||||
Value: aws.Credentials{
|
||||
AccessKeyID: config.Config.Credential.Aws.AccessKeyID,
|
||||
SecretAccessKey: config.Config.Credential.Aws.AccessKeySecret,
|
||||
Source: "Open IM OSS",
|
||||
},
|
||||
}))
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " " + "Init AWS S3 Credential failed " + err.Error() + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
//帐号转化
|
||||
awsStsClient := sts.NewFromConfig(awsSourceConfig)
|
||||
StsRole, err := awsStsClient.AssumeRole(context.Background(), &sts.AssumeRoleInput{
|
||||
RoleArn: aws.String(config.Config.Credential.Aws.RoleArn),
|
||||
DurationSeconds: aws.Int32(constant.AwsDurationTimes),
|
||||
RoleSessionName: aws.String(config.Config.Credential.Aws.RoleSessionName),
|
||||
ExternalId: aws.String(config.Config.Credential.Aws.ExternalId),
|
||||
})
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " " + "AWS S3 AssumeRole failed " + err.Error() + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
resp.CosData.AccessKeyId = string(*StsRole.Credentials.AccessKeyId)
|
||||
resp.CosData.SecretAccessKey = string(*StsRole.Credentials.SecretAccessKey)
|
||||
resp.CosData.SessionToken = string(*StsRole.Credentials.SessionToken)
|
||||
resp.CosData.Bucket = config.Config.Credential.Aws.Bucket
|
||||
resp.CosData.RegionID = config.Config.Credential.Aws.Region
|
||||
resp.CosData.FinalHost = config.Config.Credential.Aws.FinalHost
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||
}
|
||||
@@ -1,49 +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"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func FcmUpdateToken(c *gin.Context) {
|
||||
var (
|
||||
req api.FcmUpdateTokenReq
|
||||
resp api.FcmUpdateTokenResp
|
||||
)
|
||||
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)
|
||||
|
||||
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)
|
||||
resp.ErrCode = 500
|
||||
resp.ErrMsg = errMsg
|
||||
c.JSON(http.StatusInternalServerError, resp)
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req, UserId)
|
||||
//逻辑处理开始
|
||||
err := db.DB.SetFcmToken(UserId, req.Platform, req.FcmToken, 0)
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " " + "SetFcmToken failed " + err.Error() + " token:" + c.Request.Header.Get("token")
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
resp.ErrCode = 500
|
||||
resp.ErrMsg = errMsg
|
||||
c.JSON(http.StatusInternalServerError, resp)
|
||||
return
|
||||
}
|
||||
//逻辑处理完毕
|
||||
c.JSON(http.StatusOK, resp)
|
||||
return
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user