mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-08-29 05:10:11 +08:00
Merge remote-tracking branch 'origin/v2.3.0release' into main
This commit is contained in:
commit
6cdb64fb8b
@ -1 +1 @@
|
|||||||
Subproject commit 7ce9f14846f90b42777577774feb869f149da067
|
Subproject commit 1667b0f4e205fc4ed7c690ab55b662087d61c277
|
@ -47,7 +47,6 @@ func main() {
|
|||||||
// gin.SetMode(gin.DebugMode)
|
// gin.SetMode(gin.DebugMode)
|
||||||
r := gin.Default()
|
r := gin.Default()
|
||||||
r.Use(utils.CorsHandler())
|
r.Use(utils.CorsHandler())
|
||||||
|
|
||||||
log.Info("load config: ", config.Config)
|
log.Info("load config: ", config.Config)
|
||||||
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||||
// user routing group, which handles user registration and login services
|
// user routing group, which handles user registration and login services
|
||||||
@ -55,7 +54,7 @@ func main() {
|
|||||||
{
|
{
|
||||||
userRouterGroup.POST("/update_user_info", user.UpdateUserInfo) //1
|
userRouterGroup.POST("/update_user_info", user.UpdateUserInfo) //1
|
||||||
userRouterGroup.POST("/set_global_msg_recv_opt", user.SetGlobalRecvMessageOpt)
|
userRouterGroup.POST("/set_global_msg_recv_opt", user.SetGlobalRecvMessageOpt)
|
||||||
userRouterGroup.POST("/get_users_info", user.GetUsersInfo) //1
|
userRouterGroup.POST("/get_users_info", user.GetUsersPublicInfo) //1
|
||||||
userRouterGroup.POST("/get_self_user_info", user.GetSelfUserInfo) //1
|
userRouterGroup.POST("/get_self_user_info", user.GetSelfUserInfo) //1
|
||||||
userRouterGroup.POST("/get_users_online_status", user.GetUsersOnlineStatus) //1
|
userRouterGroup.POST("/get_users_online_status", user.GetUsersOnlineStatus) //1
|
||||||
userRouterGroup.POST("/get_users_info_from_cache", user.GetUsersInfoFromCache)
|
userRouterGroup.POST("/get_users_info_from_cache", user.GetUsersInfoFromCache)
|
||||||
@ -64,6 +63,7 @@ func main() {
|
|||||||
userRouterGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1
|
userRouterGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1
|
||||||
userRouterGroup.POST("/account_check", manage.AccountCheck) //1
|
userRouterGroup.POST("/account_check", manage.AccountCheck) //1
|
||||||
// userRouterGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1
|
// userRouterGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1
|
||||||
|
userRouterGroup.POST("/get_users", user.GetUsers)
|
||||||
}
|
}
|
||||||
//friend routing group
|
//friend routing group
|
||||||
friendRouterGroup := r.Group("/friend")
|
friendRouterGroup := r.Group("/friend")
|
||||||
@ -97,7 +97,7 @@ func main() {
|
|||||||
groupRouterGroup.POST("/get_user_req_group_applicationList", group.GetUserReqGroupApplicationList)
|
groupRouterGroup.POST("/get_user_req_group_applicationList", group.GetUserReqGroupApplicationList)
|
||||||
groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1
|
groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1
|
||||||
groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1
|
groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1
|
||||||
groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use
|
// groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use
|
||||||
groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1
|
groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1
|
||||||
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1
|
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1
|
||||||
groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1
|
groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1
|
||||||
@ -138,6 +138,7 @@ func main() {
|
|||||||
thirdGroup.POST("/get_rtc_invitation_start_app", apiThird.GetRTCInvitationInfoStartApp)
|
thirdGroup.POST("/get_rtc_invitation_start_app", apiThird.GetRTCInvitationInfoStartApp)
|
||||||
thirdGroup.POST("/fcm_update_token", apiThird.FcmUpdateToken)
|
thirdGroup.POST("/fcm_update_token", apiThird.FcmUpdateToken)
|
||||||
thirdGroup.POST("/aws_storage_credential", apiThird.AwsStorageCredential)
|
thirdGroup.POST("/aws_storage_credential", apiThird.AwsStorageCredential)
|
||||||
|
thirdGroup.POST("/set_app_badge", apiThird.SetAppBadge)
|
||||||
}
|
}
|
||||||
//Message
|
//Message
|
||||||
chatGroup := r.Group("/msg")
|
chatGroup := r.Group("/msg")
|
||||||
@ -225,6 +226,6 @@ func main() {
|
|||||||
fmt.Println("start api server, address: ", address)
|
fmt.Println("start api server, address: ", address)
|
||||||
err := r.Run(address)
|
err := r.Run(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("", "run failed ", *ginPort, err.Error())
|
log.Error("", "api run failed ", *ginPort, err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -31,6 +32,7 @@ func main() {
|
|||||||
authRouterGroup.POST("/password", register.SetPassword)
|
authRouterGroup.POST("/password", register.SetPassword)
|
||||||
authRouterGroup.POST("/login", register.Login)
|
authRouterGroup.POST("/login", register.Login)
|
||||||
authRouterGroup.POST("/reset_password", register.ResetPassword)
|
authRouterGroup.POST("/reset_password", register.ResetPassword)
|
||||||
|
authRouterGroup.POST("/check_login", register.CheckLoginLimit)
|
||||||
}
|
}
|
||||||
demoRouterGroup := r.Group("/auth")
|
demoRouterGroup := r.Group("/auth")
|
||||||
{
|
{
|
||||||
@ -39,7 +41,10 @@ func main() {
|
|||||||
demoRouterGroup.POST("/password", register.SetPassword)
|
demoRouterGroup.POST("/password", register.SetPassword)
|
||||||
demoRouterGroup.POST("/login", register.Login)
|
demoRouterGroup.POST("/login", register.Login)
|
||||||
demoRouterGroup.POST("/reset_password", register.ResetPassword)
|
demoRouterGroup.POST("/reset_password", register.ResetPassword)
|
||||||
|
demoRouterGroup.POST("/check_login", register.CheckLoginLimit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//deprecated
|
||||||
cmsRouterGroup := r.Group("/cms_admin")
|
cmsRouterGroup := r.Group("/cms_admin")
|
||||||
{
|
{
|
||||||
cmsRouterGroup.POST("/generate_invitation_code", register.GenerateInvitationCode)
|
cmsRouterGroup.POST("/generate_invitation_code", register.GenerateInvitationCode)
|
||||||
|
@ -2,8 +2,10 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/internal/msg_transfer/logic"
|
"Open_IM/internal/msg_transfer/logic"
|
||||||
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
@ -11,9 +13,10 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
rpcPort := flag.Int("port", config.Config.Prometheus.MessageTransferPrometheusPort[0], "MessageTransferPrometheusPort default listen port")
|
||||||
log.NewPrivateLog(constant.LogFileName)
|
log.NewPrivateLog(constant.LogFileName)
|
||||||
logic.Init()
|
logic.Init()
|
||||||
fmt.Println("start msg_transfer server")
|
fmt.Println("start msg_transfer server")
|
||||||
logic.Run()
|
logic.Run(*rpcPort)
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
|
||||||
|
|
||||||
BINARY_NAME=open_im_message_cms
|
|
||||||
BIN_DIR=../../../bin/
|
|
||||||
|
|
||||||
all: gotool build
|
|
||||||
|
|
||||||
build:
|
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
|
||||||
|
|
||||||
run:
|
|
||||||
@go run ./
|
|
||||||
|
|
||||||
gotool:
|
|
||||||
go fmt ./
|
|
||||||
go vet ./
|
|
||||||
|
|
||||||
install:
|
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
|
||||||
|
|
||||||
clean:
|
|
||||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
|
@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
rpcMessageCMS "Open_IM/internal/rpc/message_cms"
|
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
defaultPorts := config.Config.RpcPort.OpenImMessageCmsPort[0]
|
|
||||||
rpcPort := flag.Int("port", defaultPorts, "rpc listening port")
|
|
||||||
flag.Parse()
|
|
||||||
fmt.Println("start msg cms rpc server, port: ", *rpcPort)
|
|
||||||
rpcServer := rpcMessageCMS.NewMessageCMSServer(*rpcPort)
|
|
||||||
rpcServer.Run()
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
.PHONY: all build run gotool install clean help
|
|
||||||
|
|
||||||
BINARY_NAME=open_im_statistics
|
|
||||||
BIN_DIR=../../../bin/
|
|
||||||
|
|
||||||
all: gotool build
|
|
||||||
|
|
||||||
build:
|
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
|
||||||
|
|
||||||
run:
|
|
||||||
@go run ./
|
|
||||||
|
|
||||||
gotool:
|
|
||||||
go fmt ./
|
|
||||||
go vet ./
|
|
||||||
|
|
||||||
install:
|
|
||||||
make build
|
|
||||||
mv ${BINARY_NAME} ${BIN_DIR}
|
|
||||||
|
|
||||||
clean:
|
|
||||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
|
@ -1,17 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"Open_IM/internal/rpc/statistics"
|
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
defaultPorts := config.Config.RpcPort.OpenImStatisticsPort
|
|
||||||
rpcPort := flag.Int("port", defaultPorts[0], "rpc listening port")
|
|
||||||
flag.Parse()
|
|
||||||
fmt.Println("start statistics rpc server, port: ", *rpcPort)
|
|
||||||
rpcServer := statistics.NewStatisticsServer(*rpcPort)
|
|
||||||
rpcServer.Run()
|
|
||||||
}
|
|
@ -17,9 +17,9 @@ mysql:
|
|||||||
dbMysqlDatabaseName: openIM_v2 #默认即可
|
dbMysqlDatabaseName: openIM_v2 #默认即可
|
||||||
dbTableName: eMsg #默认即可
|
dbTableName: eMsg #默认即可
|
||||||
dbMsgTableNum: 1
|
dbMsgTableNum: 1
|
||||||
dbMaxOpenConns: 200
|
dbMaxOpenConns: 100
|
||||||
dbMaxIdleConns: 100
|
dbMaxIdleConns: 10
|
||||||
dbMaxLifeTime: 120
|
dbMaxLifeTime: 5
|
||||||
|
|
||||||
mongo:
|
mongo:
|
||||||
dbUri: ""#当dbUri值不为空则直接使用该值
|
dbUri: ""#当dbUri值不为空则直接使用该值
|
||||||
@ -88,9 +88,7 @@ endpoints:
|
|||||||
rpc_group: openim_rpc_group
|
rpc_group: openim_rpc_group
|
||||||
rpc_msg: openim_rpc_msg
|
rpc_msg: openim_rpc_msg
|
||||||
rpc_user: openim_rpc_user
|
rpc_user: openim_rpc_user
|
||||||
rpc_statistic: openim_rpc_statistic
|
|
||||||
rpc_admin_cms: openim_rpc_admin_cms
|
rpc_admin_cms: openim_rpc_admin_cms
|
||||||
rpc_message_cms: openim_rpc_admin_cms
|
|
||||||
rpc_office: openim_rpc_office
|
rpc_office: openim_rpc_office
|
||||||
|
|
||||||
api:
|
api:
|
||||||
@ -155,8 +153,6 @@ rpcport: #rpc服务端口 默认即可
|
|||||||
openImGroupPort: [ 10150 ]
|
openImGroupPort: [ 10150 ]
|
||||||
openImAuthPort: [ 10160 ]
|
openImAuthPort: [ 10160 ]
|
||||||
openImPushPort: [ 10170 ]
|
openImPushPort: [ 10170 ]
|
||||||
openImStatisticsPort: [ 10180 ]
|
|
||||||
openImMessageCmsPort: [ 10190 ]
|
|
||||||
openImAdminCmsPort: [ 10200 ]
|
openImAdminCmsPort: [ 10200 ]
|
||||||
openImOfficePort: [ 10210 ]
|
openImOfficePort: [ 10210 ]
|
||||||
openImOrganizationPort: [ 10220 ]
|
openImOrganizationPort: [ 10220 ]
|
||||||
@ -181,8 +177,6 @@ rpcregistername: #rpc注册服务名,默认即可
|
|||||||
openImRelayName: Relay
|
openImRelayName: Relay
|
||||||
openImGroupName: Group
|
openImGroupName: Group
|
||||||
openImAuthName: Auth
|
openImAuthName: Auth
|
||||||
openImStatisticsName: Statistics
|
|
||||||
openImMessageCMSName: MessageCMS
|
|
||||||
openImAdminCMSName: AdminCMS
|
openImAdminCMSName: AdminCMS
|
||||||
openImOfficeName: Office
|
openImOfficeName: Office
|
||||||
openImOrganizationName: Organization
|
openImOrganizationName: Organization
|
||||||
@ -750,9 +744,27 @@ demo:
|
|||||||
testDepartMentID: 001
|
testDepartMentID: 001
|
||||||
imAPIURL: http://127.0.0.1:10002
|
imAPIURL: http://127.0.0.1:10002
|
||||||
onboardProcess: false # 是否开启注册流程
|
onboardProcess: false # 是否开启注册流程
|
||||||
|
createOrganizationUserAndJoinDepartment: false
|
||||||
joinDepartmentIDList: [] # 用户注册进来默认加的部门ID列表 不填就随机
|
joinDepartmentIDList: [] # 用户注册进来默认加的部门ID列表 不填就随机
|
||||||
joinDepartmentGroups: false # 注册是否加部门群
|
joinDepartmentGroups: false # 注册是否加部门群
|
||||||
oaNotification: false # 注册是否发送OA通知
|
oaNotification: false # 注册是否发送OA通知
|
||||||
|
|
||||||
rtc:
|
rtc:
|
||||||
signalTimeout: 35
|
signalTimeout: 35
|
||||||
|
|
||||||
|
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 ]
|
@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: admin-cms
|
- name: admin-cms
|
||||||
image: openim/admin_cms:v2.2.0
|
image: openim/admin_cms:v2.3.0release
|
||||||
# imagePullPolicy: Always #每次启动都重新拉取镜像
|
# imagePullPolicy: Always #每次启动都重新拉取镜像
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10200
|
- containerPort: 10200
|
||||||
@ -23,6 +23,9 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
env:
|
||||||
|
- name: CONFIG_NAME
|
||||||
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
configMap:
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: api
|
- name: api
|
||||||
image: openim/api:v2.2.0
|
image: openim/api:v2.3.0release
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10002
|
- containerPort: 10002
|
||||||
@ -23,6 +23,9 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
env:
|
||||||
|
- name: CONFIG_NAME
|
||||||
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
configMap:
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: auth
|
- name: auth
|
||||||
image: openim/auth:v2.2.0
|
image: openim/auth:v2.3.0release
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10160
|
- containerPort: 10160
|
||||||
@ -23,6 +23,9 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
env:
|
||||||
|
- name: CONFIG_NAME
|
||||||
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
configMap:
|
||||||
|
5
deploy_k8s/cache/deployment.yaml
vendored
5
deploy_k8s/cache/deployment.yaml
vendored
@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: cache
|
- name: cache
|
||||||
image: openim/cache:v2.2.0
|
image: openim/cache:v2.3.0release
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10240
|
- containerPort: 10240
|
||||||
@ -23,6 +23,9 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
env:
|
||||||
|
- name: CONFIG_NAME
|
||||||
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
configMap:
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: cms-api
|
- name: cms-api
|
||||||
image: openim/cms_api:v2.2.0
|
image: openim/cms_api:v2.3.0release
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10006
|
- containerPort: 10006
|
||||||
@ -23,6 +23,9 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
env:
|
||||||
|
- name: CONFIG_NAME
|
||||||
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
configMap:
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: conversation
|
- name: conversation
|
||||||
image: openim/conversation:v2.2.0
|
image: openim/conversation:v2.3.0release
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10230
|
- containerPort: 10230
|
||||||
@ -23,6 +23,10 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
env:
|
||||||
|
- name: CONFIG_NAME
|
||||||
|
value: "/Open-IM-Server"
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
configMap:
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: demo
|
- name: demo
|
||||||
image: openim/demo:v2.2.0
|
image: openim/demo:v2.3.0release
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10004
|
- containerPort: 10004
|
||||||
@ -23,6 +23,9 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
env:
|
||||||
|
- name: CONFIG_NAME
|
||||||
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
configMap:
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: friend
|
- name: friend
|
||||||
image: openim/friend:v2.2.0
|
image: openim/friend:v2.3.0release
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10120
|
- containerPort: 10120
|
||||||
@ -23,6 +23,9 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
env:
|
||||||
|
- name: CONFIG_NAME
|
||||||
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
configMap:
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: group
|
- name: group
|
||||||
image: openim/group:v2.2.0
|
image: openim/group:v2.3.0release
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10150
|
- containerPort: 10150
|
||||||
@ -23,6 +23,9 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
env:
|
||||||
|
- name: CONFIG_NAME
|
||||||
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
configMap:
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: message-cms
|
- name: message-cms
|
||||||
image: openim/message_cms:v2.2.0
|
image: openim/message_cms:v2.3.0release
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10190
|
- containerPort: 10190
|
||||||
@ -23,6 +23,9 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
env:
|
||||||
|
- name: CONFIG_NAME
|
||||||
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
configMap:
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: msg
|
- name: msg
|
||||||
image: openim/msg:v2.2.0
|
image: openim/msg:v2.3.0release
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10130
|
- containerPort: 10130
|
||||||
@ -23,6 +23,9 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
env:
|
||||||
|
- name: CONFIG_NAME
|
||||||
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
configMap:
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: msg-gateway
|
- name: msg-gateway
|
||||||
image: openim/msg_gateway:v2.2.0
|
image: openim/msg_gateway:v2.3.0release
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- name: rpc-port
|
- name: rpc-port
|
||||||
@ -26,6 +26,9 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
env:
|
||||||
|
- name: CONFIG_NAME
|
||||||
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
configMap:
|
||||||
|
@ -15,12 +15,15 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: msg-transfer
|
- name: msg-transfer
|
||||||
image: openim/msg_transfer:v2.2.0
|
image: openim/msg_transfer:v2.3.0release
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
env:
|
||||||
|
- name: CONFIG_NAME
|
||||||
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
configMap:
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: office
|
- name: office
|
||||||
image: openim/office:v2.2.0
|
image: openim/office:v2.3.0release
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10210
|
- containerPort: 10210
|
||||||
@ -23,6 +23,9 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
env:
|
||||||
|
- name: CONFIG_NAME
|
||||||
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
configMap:
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: organization
|
- name: organization
|
||||||
image: openim/organization:v2.2.0
|
image: openim/organization:v2.3.0release
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10220
|
- containerPort: 10220
|
||||||
@ -23,6 +23,9 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
env:
|
||||||
|
- name: CONFIG_NAME
|
||||||
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
configMap:
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: push
|
- name: push
|
||||||
image: openim/push:v2.2.0
|
image: openim/push:v2.3.0release
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10170
|
- containerPort: 10170
|
||||||
@ -23,6 +23,9 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
env:
|
||||||
|
- name: CONFIG_NAME
|
||||||
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
configMap:
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: sdk-server
|
- name: sdk-server
|
||||||
image: openim/sdk_server:v2.2.0
|
image: openim/sdk_server:v2.3.0release
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10003
|
- containerPort: 10003
|
||||||
@ -25,8 +25,11 @@ spec:
|
|||||||
readOnly: true
|
readOnly: true
|
||||||
- name: local-db
|
- name: local-db
|
||||||
mountPath: /db/sdk
|
mountPath: /db/sdk
|
||||||
|
env:
|
||||||
|
- name: CONFIG_NAME
|
||||||
|
value: "/Open-IM-Server"
|
||||||
command: ["/Open-IM-Server/main"]
|
command: ["/Open-IM-Server/main"]
|
||||||
args: ["-openIM_api_port", "10002", "-openIM_ws_port", "10001", "-sdk_ws_port", "10003", "-openIM_log_level", "6"]
|
args: ["-openIM_ws_address", "ws_addr", "-sdk_ws_port", "10001", "-openIM_api_address", "api_address", "-openIM_log_level", "6"]
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
configMap:
|
||||||
|
@ -15,7 +15,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: statistics
|
- name: statistics
|
||||||
image: openim/statistics:v2.2.0
|
image: openim/statistics:v2.3.0release
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 10180
|
- containerPort: 10180
|
||||||
@ -23,6 +23,9 @@ spec:
|
|||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
env:
|
||||||
|
- name: CONFIG_NAME
|
||||||
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
configMap:
|
||||||
|
@ -15,12 +15,15 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: user
|
- name: user
|
||||||
image: openim/user:v2.2.0
|
image: openim/user:v2.3.0release
|
||||||
# imagePullPolicy: Always
|
# imagePullPolicy: Always
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: config
|
- name: config
|
||||||
mountPath: /Open-IM-Server/config
|
mountPath: /Open-IM-Server/config
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
env:
|
||||||
|
- name: CONFIG_NAME
|
||||||
|
value: "/Open-IM-Server"
|
||||||
volumes:
|
volumes:
|
||||||
- name: config
|
- name: config
|
||||||
configMap:
|
configMap:
|
||||||
|
@ -112,18 +112,7 @@ services:
|
|||||||
MINIO_ROOT_PASSWORD: key12345
|
MINIO_ROOT_PASSWORD: key12345
|
||||||
restart: always
|
restart: always
|
||||||
command: minio server /data --console-address ':9090'
|
command: minio server /data --console-address ':9090'
|
||||||
#
|
|
||||||
# dtm:
|
|
||||||
# image: yedf/dtm
|
|
||||||
# ports:
|
|
||||||
# - 36789:36789
|
|
||||||
# - 36790:36790
|
|
||||||
# environment:
|
|
||||||
# STORE_DRIVER: mysql
|
|
||||||
# STORE_HOST: localhost
|
|
||||||
# STORE_USER: root
|
|
||||||
# STORE_PASSWORD: ''
|
|
||||||
# STORE_PORT: 3306
|
|
||||||
|
|
||||||
open_im_server:
|
open_im_server:
|
||||||
image: openim/open_im_server:v2.3.2
|
image: openim/open_im_server:v2.3.2
|
||||||
@ -147,3 +136,39 @@ services:
|
|||||||
options:
|
options:
|
||||||
max-size: "1g"
|
max-size: "1g"
|
||||||
max-file: "2"
|
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:
|
||||||
|
# - ./grafana/dashboards/dashboard.json:/var/lib/grafana/dashboards/dashboard.json
|
||||||
|
# - ./grafana/provisioning/dashboard.yaml:/etc/grafana/provisioning/dashboards/dashboard.yaml
|
||||||
|
- ./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
|
||||||
|
container_name: grafana
|
||||||
|
ports:
|
||||||
|
- 10007:10007
|
||||||
|
depends_on:
|
||||||
|
- prometheus
|
||||||
|
network_mode: "host"
|
||||||
|
|
||||||
|
node-exporter:
|
||||||
|
image: quay.io/prometheus/node-exporter
|
||||||
|
container_name: node-exporter
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- "9100:9100"
|
||||||
|
# command: --collector.ENTER-THE-NAME-OF-COLLECTOR
|
||||||
|
13
docker-compose_cfg/datasource-compose.yaml
Normal file
13
docker-compose_cfg/datasource-compose.yaml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#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
|
1285
docker-compose_cfg/grafana.ini
Normal file
1285
docker-compose_cfg/grafana.ini
Normal file
File diff suppressed because it is too large
Load Diff
7253
docker-compose_cfg/node-exporter-full_rev1.json
Normal file
7253
docker-compose_cfg/node-exporter-full_rev1.json
Normal file
File diff suppressed because it is too large
Load Diff
28
docker-compose_cfg/prometheus-compose.yml
Normal file
28
docker-compose_cfg/prometheus-compose.yml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#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:10006']
|
||||||
|
labels:
|
||||||
|
group: 'cms-api'
|
||||||
|
- targets: ['localhost:21400']
|
||||||
|
labels:
|
||||||
|
group: 'msg-transfer'
|
||||||
|
|
||||||
|
|
||||||
|
- job_name: 'node'
|
||||||
|
scrape_interval: 8s
|
||||||
|
static_configs:
|
||||||
|
- targets: ['localhost:9100']
|
||||||
|
|
3
go.mod
3
go.mod
@ -38,6 +38,7 @@ require (
|
|||||||
github.com/olivere/elastic/v7 v7.0.23
|
github.com/olivere/elastic/v7 v7.0.23
|
||||||
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
|
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
|
github.com/prometheus/client_golang v1.13.0 // indirect
|
||||||
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
|
github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5
|
||||||
github.com/robfig/cron/v3 v3.0.1
|
github.com/robfig/cron/v3 v3.0.1
|
||||||
github.com/sirupsen/logrus v1.8.1
|
github.com/sirupsen/logrus v1.8.1
|
||||||
@ -62,7 +63,7 @@ require (
|
|||||||
golang.org/x/tools v0.1.11 // indirect
|
golang.org/x/tools v0.1.11 // indirect
|
||||||
google.golang.org/api v0.59.0
|
google.golang.org/api v0.59.0
|
||||||
google.golang.org/grpc v1.45.0
|
google.golang.org/grpc v1.45.0
|
||||||
google.golang.org/protobuf v1.28.0
|
google.golang.org/protobuf v1.28.1
|
||||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
||||||
gopkg.in/ini.v1 v1.66.2 // indirect
|
gopkg.in/ini.v1 v1.66.2 // indirect
|
||||||
|
24
go.sum
24
go.sum
@ -125,6 +125,7 @@ github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLj
|
|||||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||||
|
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||||
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
|
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
|
||||||
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
|
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
|
||||||
@ -202,9 +203,11 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2
|
|||||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||||
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
||||||
|
github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
|
||||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||||
|
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
|
||||||
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
|
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
|
||||||
github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY=
|
github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY=
|
||||||
github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
|
github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
|
||||||
@ -428,6 +431,7 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
|
|||||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||||
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
|
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
|
||||||
|
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
github.com/minio/md5-simd v1.1.0 h1:QPfiOqlZH+Cj9teu0t9b1nTBfPbyTl16Of5MeuShdK4=
|
github.com/minio/md5-simd v1.1.0 h1:QPfiOqlZH+Cj9teu0t9b1nTBfPbyTl16Of5MeuShdK4=
|
||||||
github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw=
|
github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw=
|
||||||
@ -492,18 +496,29 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
|||||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||||
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
|
||||||
|
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
|
||||||
github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
|
github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
|
||||||
|
github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
|
||||||
|
github.com/prometheus/client_golang v1.13.0 h1:b71QUfeo5M8gq2+evJdTPfZhYMAU0uKPkyPJ7TPsloU=
|
||||||
|
github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ=
|
||||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
|
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
|
||||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||||
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
|
||||||
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
|
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
|
||||||
|
github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
|
||||||
|
github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE=
|
||||||
|
github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA=
|
||||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||||
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
|
||||||
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||||
|
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
|
||||||
|
github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo=
|
||||||
|
github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
|
||||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM=
|
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM=
|
||||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||||
github.com/richardlehane/mscfb v1.0.4 h1:WULscsljNPConisD5hR0+OyZjwK46Pfyr6mPu5ZawpM=
|
github.com/richardlehane/mscfb v1.0.4 h1:WULscsljNPConisD5hR0+OyZjwK46Pfyr6mPu5ZawpM=
|
||||||
@ -726,9 +741,12 @@ golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1
|
|||||||
golang.org/x/net v0.0.0-20210427231257-85d9c07bbe3a/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
golang.org/x/net v0.0.0-20210427231257-85d9c07bbe3a/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||||
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||||
|
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||||
golang.org/x/net v0.0.0-20220407224826-aac1ed45d8e3/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
golang.org/x/net v0.0.0-20220407224826-aac1ed45d8e3/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||||
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||||
golang.org/x/net v0.0.0-20220622184535-263ec571b305 h1:dAgbJ2SP4jD6XYfMNLVj0BF21jo2PjChrtGaAvF5M3I=
|
golang.org/x/net v0.0.0-20220622184535-263ec571b305 h1:dAgbJ2SP4jD6XYfMNLVj0BF21jo2PjChrtGaAvF5M3I=
|
||||||
@ -750,6 +768,7 @@ golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ
|
|||||||
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||||
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1 h1:B333XXssMuKQeBwiNODx4TupZy7bf4sxFZnN2ZOcvUE=
|
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1 h1:B333XXssMuKQeBwiNODx4TupZy7bf4sxFZnN2ZOcvUE=
|
||||||
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
@ -762,6 +781,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
|
|||||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f h1:Ax0t5p6N38Ga0dThY21weqDEyz2oklo4IvDkpigvkD8=
|
||||||
|
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
@ -830,6 +851,7 @@ golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664 h1:wEZYwx+kK+KlZ0hpvP2Ls1Xr4+RWnlzGFwPP0aiDjIU=
|
golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664 h1:wEZYwx+kK+KlZ0hpvP2Ls1Xr4+RWnlzGFwPP0aiDjIU=
|
||||||
golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
@ -1056,6 +1078,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
|
|||||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
|
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
|
||||||
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
|
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
|
||||||
|
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
|
||||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
|
||||||
|
@ -77,7 +77,7 @@ func UserRegister(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pbDataToken := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID, LoginIp: params.CreateIp}
|
pbDataToken := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}
|
||||||
replyToken, err := client.UserToken(context.Background(), pbDataToken)
|
replyToken, err := client.UserToken(context.Background(), pbDataToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := req.OperationID + " " + " client.UserToken failed " + err.Error() + pbDataToken.String()
|
errMsg := req.OperationID + " " + " client.UserToken failed " + err.Error() + pbDataToken.String()
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/golang/protobuf/ptypes/wrappers"
|
"github.com/golang/protobuf/ptypes/wrappers"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
@ -319,12 +320,7 @@ func InviteUserToGroup(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
req := &rpc.InviteUserToGroupReq{}
|
req := &rpc.InviteUserToGroupReq{}
|
||||||
utils.CopyStructFields(req, ¶ms)
|
utils.CopyStructFields(req, ¶ms)
|
||||||
if len(req.InvitedUserIDList) > constant.MaxNotificationNum {
|
|
||||||
errMsg := req.OperationID + " too many, Limit: " + utils.IntToString(constant.MaxNotificationNum)
|
|
||||||
log.NewError(req.OperationID, errMsg, len(req.InvitedUserIDList))
|
|
||||||
c.JSON(http.StatusRequestEntityTooLarge, gin.H{"errCode": 400, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var ok bool
|
var ok bool
|
||||||
var errInfo string
|
var errInfo string
|
||||||
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
ok, req.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
@ -384,7 +380,13 @@ func CreateGroup(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//
|
|
||||||
|
if len(params.MemberList) > constant.MaxNotificationNum {
|
||||||
|
errMsg := params.OperationID + " too many members " + utils.Int32ToString(int32(len(params.MemberList)))
|
||||||
|
log.Error(params.OperationID, errMsg)
|
||||||
|
c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||||
|
return
|
||||||
|
}
|
||||||
req := &rpc.CreateGroupReq{GroupInfo: &open_im_sdk.GroupInfo{}}
|
req := &rpc.CreateGroupReq{GroupInfo: &open_im_sdk.GroupInfo{}}
|
||||||
utils.CopyStructFields(req.GroupInfo, ¶ms)
|
utils.CopyStructFields(req.GroupInfo, ¶ms)
|
||||||
|
|
||||||
|
@ -216,21 +216,22 @@ func ManagementSendMsg(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
client := pbChat.NewMsgClient(etcdConn)
|
client := pbChat.NewMsgClient(etcdConn)
|
||||||
log.Info(params.OperationID, "", "api ManagementSendMsg call, api call rpc...")
|
log.Info(params.OperationID, "", "api ManagementSendMsg call, api call rpc...")
|
||||||
|
var status int32
|
||||||
RpcResp, err := client.SendMsg(context.Background(), pbData)
|
RpcResp, err := client.SendMsg(context.Background(), pbData)
|
||||||
if err != nil || (RpcResp != nil && RpcResp.ErrCode != 0) {
|
if err != nil || (RpcResp != nil && RpcResp.ErrCode != 0) {
|
||||||
resp, err2 := client.SetSendMsgFailedFlag(context.Background(), &pbChat.SetSendMsgFailedFlagReq{OperationID: params.OperationID})
|
status = constant.MsgSendFailed
|
||||||
|
} else {
|
||||||
|
status = constant.MsgSendSuccessed
|
||||||
|
}
|
||||||
|
|
||||||
|
respSetSendMsgStatus, err2 := client.SetSendMsgStatus(context.Background(), &pbChat.SetSendMsgStatusReq{OperationID: params.OperationID, Status: status})
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err.Error())
|
log.NewError(params.OperationID, utils.GetSelfFuncName(), err2.Error())
|
||||||
}
|
|
||||||
if resp != nil && resp.ErrCode != 0 {
|
|
||||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), resp.ErrCode, resp.ErrMsg)
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(params.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call UserSendMsg rpc server failed"})
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
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())
|
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}}
|
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)
|
log.Info(params.OperationID, "ManagementSendMsg return", resp)
|
||||||
@ -319,16 +320,26 @@ func ManagementBatchSendMsg(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
log.NewInfo(params.OperationID, "Ws call success to ManagementSendMsgReq", params)
|
log.NewInfo(params.OperationID, "Ws call success to ManagementSendMsgReq", params)
|
||||||
var msgSendFailedFlag bool
|
var msgSendFailedFlag bool
|
||||||
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, params.OperationID)
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, params.OperationID)
|
||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
errMsg := params.OperationID + "getcdv3.GetDefaultConn == nil"
|
errMsg := params.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
log.NewError(params.OperationID, errMsg)
|
log.NewError(params.OperationID, errMsg)
|
||||||
//resp.Data.FailedIDList = params.RecvIDList
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "rpc server error: etcdConn == nil"})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "rpc server error: etcdConn == nil"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pbChat.NewMsgClient(etcdConn)
|
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()})
|
||||||
|
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{
|
req := &api.ManagementSendMsgReq{
|
||||||
ManagementSendMsg: params.ManagementSendMsg,
|
ManagementSendMsg: params.ManagementSendMsg,
|
||||||
}
|
}
|
||||||
@ -346,7 +357,6 @@ func ManagementBatchSendMsg(c *gin.Context) {
|
|||||||
for _, recvID := range recvList {
|
for _, recvID := range recvList {
|
||||||
pbData.MsgData.RecvID = recvID
|
pbData.MsgData.RecvID = recvID
|
||||||
log.Info(params.OperationID, "", "api ManagementSendMsg call start..., ", pbData.String())
|
log.Info(params.OperationID, "", "api ManagementSendMsg call start..., ", pbData.String())
|
||||||
|
|
||||||
rpcResp, err := client.SendMsg(context.Background(), pbData)
|
rpcResp, err := client.SendMsg(context.Background(), pbData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(params.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
log.NewError(params.OperationID, "call delete UserSendMsg rpc server failed", err.Error())
|
||||||
@ -367,15 +377,19 @@ func ManagementBatchSendMsg(c *gin.Context) {
|
|||||||
RecvID: recvID,
|
RecvID: recvID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
var status int32
|
||||||
if msgSendFailedFlag {
|
if msgSendFailedFlag {
|
||||||
resp, err2 := client.SetSendMsgFailedFlag(context.Background(), &pbChat.SetSendMsgFailedFlagReq{OperationID: params.OperationID})
|
status = constant.MsgSendFailed
|
||||||
|
} else {
|
||||||
|
status = constant.MsgSendSuccessed
|
||||||
|
}
|
||||||
|
respSetSendMsgStatus, err2 := client.SetSendMsgStatus(context.Background(), &pbChat.SetSendMsgStatusReq{OperationID: params.OperationID, Status: status})
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err2.Error())
|
log.NewError(params.OperationID, utils.GetSelfFuncName(), err2.Error())
|
||||||
}
|
}
|
||||||
if resp != nil && resp.ErrCode != 0 {
|
if respSetSendMsgStatus != nil && resp.ErrCode != 0 {
|
||||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), resp.ErrCode, resp.ErrMsg)
|
log.NewError(params.OperationID, utils.GetSelfFuncName(), resp.ErrCode, resp.ErrMsg)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
log.NewInfo(params.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
log.NewInfo(params.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
|
@ -23,49 +23,6 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
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
|
|
||||||
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(params.OperationID, "DeleteUser 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
|
|
||||||
}
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Summary 获取所有用户uid列表
|
// @Summary 获取所有用户uid列表
|
||||||
// @Description 获取所有用户uid列表
|
// @Description 获取所有用户uid列表
|
||||||
// @Tags 用户相关
|
// @Tags 用户相关
|
||||||
|
@ -147,13 +147,13 @@ func MinioStorageCredential(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
li, err := cr.NewSTSAssumeRole(endpoint, stsOpts)
|
li, err := cr.NewSTSAssumeRole(endpoint, stsOpts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("", utils.GetSelfFuncName(), "NewSTSAssumeRole failed", err.Error(), stsOpts, config.Config.Credential.Minio.Endpoint)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "NewSTSAssumeRole failed", err.Error(), stsOpts, config.Config.Credential.Minio.Endpoint)
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
v, err := li.Get()
|
v, err := li.Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), "li.Get error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "li.Get error", err.Error())
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
50
internal/api/third/set_app_badge.go
Normal file
50
internal/api/third/set_app_badge.go
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
package apiThird
|
||||||
|
|
||||||
|
import (
|
||||||
|
api "Open_IM/pkg/base_info"
|
||||||
|
"Open_IM/pkg/common/db"
|
||||||
|
"Open_IM/pkg/common/log"
|
||||||
|
"Open_IM/pkg/common/token_verify"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
func SetAppBadge(c *gin.Context) {
|
||||||
|
var (
|
||||||
|
req api.SetAppBadgeReq
|
||||||
|
resp api.SetAppBadgeResp
|
||||||
|
)
|
||||||
|
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)
|
||||||
|
|
||||||
|
var ok bool
|
||||||
|
var errInfo, opUserID string
|
||||||
|
ok, opUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||||
|
if !ok {
|
||||||
|
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
|
||||||
|
log.NewError(req.OperationID, errMsg)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !token_verify.CheckAccess(opUserID, req.FromUserID) {
|
||||||
|
log.NewError(req.OperationID, "CheckAccess false ", opUserID, req.FromUserID)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "no permission"})
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req, opUserID)
|
||||||
|
err := db.DB.SetUserBadgeUnreadCountSum(req.FromUserID, int(req.AppUnreadCount))
|
||||||
|
if err != nil {
|
||||||
|
errMsg := req.OperationID + " " + "SetUserBadgeUnreadCountSum 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
|
||||||
|
}
|
@ -160,7 +160,7 @@ func GetBlackIDListFromCache(c *gin.Context) {
|
|||||||
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
// @Failure 500 {object} api.Swagger500Resp "errCode为500 一般为服务器内部错误"
|
||||||
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
// @Failure 400 {object} api.Swagger400Resp "errCode为400 一般为参数输入错误, token未带上等"
|
||||||
// @Router /user/get_users_info [post]
|
// @Router /user/get_users_info [post]
|
||||||
func GetUsersInfo(c *gin.Context) {
|
func GetUsersPublicInfo(c *gin.Context) {
|
||||||
params := api.GetUsersInfoReq{}
|
params := api.GetUsersInfoReq{}
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
log.NewError("0", "BindJSON failed ", err.Error())
|
||||||
@ -456,3 +456,59 @@ func GetUsersOnlineStatus(c *gin.Context) {
|
|||||||
log.NewInfo(req.OperationID, "GetUsersOnlineStatus api return", resp)
|
log.NewInfo(req.OperationID, "GetUsersOnlineStatus api return", resp)
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetUsers(c *gin.Context) {
|
||||||
|
var (
|
||||||
|
req api.GetUsersReq
|
||||||
|
resp api.GetUsersResp
|
||||||
|
reqPb rpc.GetUsersReq
|
||||||
|
)
|
||||||
|
if err := c.BindJSON(&req); err != nil {
|
||||||
|
log.NewError(req.OperationID, "Bind failed ", err.Error(), req)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
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.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
|
reqPb.OperationID = req.OperationID
|
||||||
|
reqPb.UserID = req.UserID
|
||||||
|
reqPb.UserName = req.UserName
|
||||||
|
reqPb.Content = req.Content
|
||||||
|
reqPb.Pagination = &open_im_sdk.RequestPagination{ShowNumber: req.ShowNumber, PageNumber: req.PageNumber}
|
||||||
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
||||||
|
if etcdConn == nil {
|
||||||
|
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
|
log.NewError(reqPb.OperationID, errMsg)
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
client := rpc.NewUserClient(etcdConn)
|
||||||
|
respPb, err := client.GetUsers(context.Background(), &reqPb)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), reqPb.String())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, v := range respPb.UserList {
|
||||||
|
user := api.CMSUser{}
|
||||||
|
utils.CopyStructFields(&user, v.User)
|
||||||
|
user.IsBlock = v.IsBlock
|
||||||
|
resp.Data.UserList = append(resp.Data.UserList, &user)
|
||||||
|
}
|
||||||
|
resp.CommResp.ErrCode = respPb.CommonResp.ErrCode
|
||||||
|
resp.CommResp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||||
|
resp.Data.TotalNum = respPb.TotalNums
|
||||||
|
resp.Data.CurrentPage = respPb.Pagination.CurrentPage
|
||||||
|
resp.Data.ShowNumber = respPb.Pagination.ShowNumber
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -3,8 +3,6 @@ package admin
|
|||||||
import (
|
import (
|
||||||
apiStruct "Open_IM/pkg/cms_api_struct"
|
apiStruct "Open_IM/pkg/cms_api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
|
||||||
openIMHttp "Open_IM/pkg/common/http"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbAdmin "Open_IM/pkg/proto/admin_cms"
|
pbAdmin "Open_IM/pkg/proto/admin_cms"
|
||||||
@ -66,8 +64,8 @@ func AdminLogin(c *gin.Context) {
|
|||||||
reqPb pbAdmin.AdminLoginReq
|
reqPb pbAdmin.AdminLoginReq
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.Secret = req.Secret
|
reqPb.Secret = req.Secret
|
||||||
@ -84,24 +82,26 @@ func AdminLogin(c *gin.Context) {
|
|||||||
respPb, err := client.AdminLogin(context.Background(), &reqPb)
|
respPb, err := client.AdminLogin(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
resp.FaceURL = respPb.FaceURL
|
||||||
|
resp.UserName = respPb.UserName
|
||||||
resp.Token = respPb.Token
|
resp.Token = respPb.Token
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddUserRegisterAddFriendIDList(c *gin.Context) {
|
func AddUserRegisterAddFriendIDList(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req apiStruct.AddUserRegisterAddFriendIDListRequest
|
req apiStruct.AddUserRegisterAddFriendIDListRequest
|
||||||
resp apiStruct.AddUserRegisterAddFriendIDListResponse
|
// resp apiStruct.AddUserRegisterAddFriendIDListResponse
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, req.OperationID)
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, req.OperationID)
|
||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
errMsg := req.OperationID + "getcdv3.GetConn == nil"
|
||||||
@ -110,23 +110,24 @@ func AddUserRegisterAddFriendIDList(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
||||||
_, err := client.AddUserRegisterAddFriendIDList(context.Background(), &pbAdmin.AddUserRegisterAddFriendIDListReq{OperationID: req.OperationID, UserIDList: req.UserIDList})
|
respPb, err := client.AddUserRegisterAddFriendIDList(context.Background(), &pbAdmin.AddUserRegisterAddFriendIDListReq{OperationID: req.OperationID, UserIDList: req.UserIDList})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", respPb.String())
|
||||||
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReduceUserRegisterAddFriendIDList(c *gin.Context) {
|
func ReduceUserRegisterAddFriendIDList(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req apiStruct.ReduceUserRegisterAddFriendIDListRequest
|
req apiStruct.ReduceUserRegisterAddFriendIDListRequest
|
||||||
resp apiStruct.ReduceUserRegisterAddFriendIDListResponse
|
// resp apiStruct.ReduceUserRegisterAddFriendIDListResponse
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
||||||
@ -138,13 +139,13 @@ func ReduceUserRegisterAddFriendIDList(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
||||||
_, err := client.ReduceUserRegisterAddFriendIDList(context.Background(), &pbAdmin.ReduceUserRegisterAddFriendIDListReq{OperationID: req.OperationID, UserIDList: req.UserIDList, Operation: req.Operation})
|
respPb, err := client.ReduceUserRegisterAddFriendIDList(context.Background(), &pbAdmin.ReduceUserRegisterAddFriendIDListReq{OperationID: req.OperationID, UserIDList: req.UserIDList, Operation: req.Operation})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUserRegisterAddFriendIDList(c *gin.Context) {
|
func GetUserRegisterAddFriendIDList(c *gin.Context) {
|
||||||
@ -153,8 +154,8 @@ func GetUserRegisterAddFriendIDList(c *gin.Context) {
|
|||||||
resp apiStruct.GetUserRegisterAddFriendIDListResponse
|
resp apiStruct.GetUserRegisterAddFriendIDListResponse
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req)
|
||||||
@ -172,12 +173,12 @@ func GetUserRegisterAddFriendIDList(c *gin.Context) {
|
|||||||
}})
|
}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp.Users = respPb.UserInfoList
|
resp.Users = respPb.UserInfoList
|
||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
}
|
||||||
|
63
internal/cms_api/friend/friend.go
Normal file
63
internal/cms_api/friend/friend.go
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
package friend
|
||||||
|
|
||||||
|
import (
|
||||||
|
"Open_IM/pkg/cms_api_struct"
|
||||||
|
"Open_IM/pkg/common/config"
|
||||||
|
"Open_IM/pkg/common/log"
|
||||||
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
|
pbAdmin "Open_IM/pkg/proto/admin_cms"
|
||||||
|
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetUserFriends(c *gin.Context) {
|
||||||
|
var (
|
||||||
|
req cms_api_struct.GetFriendsReq
|
||||||
|
resp cms_api_struct.GetFriendsResp
|
||||||
|
reqPb pbAdmin.GetUserFriendsReq
|
||||||
|
)
|
||||||
|
if err := c.BindJSON(&req); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
|
reqPb.Pagination = &pbCommon.RequestPagination{}
|
||||||
|
utils.CopyStructFields(&reqPb.Pagination, req)
|
||||||
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||||
|
if etcdConn == nil {
|
||||||
|
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
|
log.NewError(reqPb.OperationID, errMsg)
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
reqPb.OperationID = req.OperationID
|
||||||
|
reqPb.UserID = req.UserID
|
||||||
|
reqPb.FriendUserName = req.FriendUserName
|
||||||
|
reqPb.FriendUserID = req.FriendUserID
|
||||||
|
|
||||||
|
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
||||||
|
respPb, err := client.GetUserFriends(context.Background(), &reqPb)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetUserInfo failed ", err.Error())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, v := range respPb.FriendInfoList {
|
||||||
|
friend := &cms_api_struct.FriendInfo{}
|
||||||
|
utils.CopyStructFields(friend, v)
|
||||||
|
friend.Nickname = v.FriendUser.Nickname
|
||||||
|
friend.UserID = v.FriendUser.UserID
|
||||||
|
resp.FriendInfoList = append(resp.FriendInfoList, friend)
|
||||||
|
}
|
||||||
|
resp.FriendNums = respPb.FriendNums
|
||||||
|
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||||
|
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
|
}
|
@ -3,8 +3,6 @@ package group
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/cms_api_struct"
|
"Open_IM/pkg/cms_api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
|
||||||
openIMHttp "Open_IM/pkg/common/http"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
commonPb "Open_IM/pkg/proto/sdk_ws"
|
commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||||
@ -18,51 +16,15 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetGroupByID(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.GetGroupByIDRequest
|
|
||||||
resp cms_api_struct.GetGroupByIDResponse
|
|
||||||
reqPb pbGroup.GetGroupByIDReq
|
|
||||||
)
|
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.GroupID = req.GroupID
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
|
||||||
respPb, err := client.GetGroupByID(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroupById failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
utils.CopyStructFields(&resp, respPb.CMSGroup.GroupInfo)
|
|
||||||
resp.GroupOwnerID = respPb.CMSGroup.GroupOwnerUserID
|
|
||||||
resp.GroupOwnerName = respPb.CMSGroup.GroupOwnerUserName
|
|
||||||
|
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetGroups(c *gin.Context) {
|
func GetGroups(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetGroupsRequest
|
req cms_api_struct.GetGroupsRequest
|
||||||
resp cms_api_struct.GetGroupsResponse
|
resp cms_api_struct.GetGroupsResponse
|
||||||
reqPb pbGroup.GetGroupsReq
|
reqPb pbGroup.GetGroupsReq
|
||||||
)
|
)
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
@ -76,11 +38,13 @@ func GetGroups(c *gin.Context) {
|
|||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
reqPb.GroupID = req.GroupID
|
||||||
|
reqPb.GroupName = req.GroupName
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
client := pbGroup.NewGroupClient(etcdConn)
|
||||||
respPb, err := client.GetGroups(context.Background(), &reqPb)
|
respPb, err := client.GetGroups(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetUserInfo failed ", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetUserInfo failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range respPb.CMSGroups {
|
for _, v := range respPb.CMSGroups {
|
||||||
@ -91,95 +55,10 @@ func GetGroups(c *gin.Context) {
|
|||||||
resp.Groups = append(resp.Groups, groupResp)
|
resp.Groups = append(resp.Groups, groupResp)
|
||||||
}
|
}
|
||||||
resp.GroupNums = int(respPb.GroupNum)
|
resp.GroupNums = int(respPb.GroupNum)
|
||||||
resp.CurrentPage = int(respPb.Pagination.PageNumber)
|
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
|
||||||
|
|
||||||
func GetGroupByName(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.GetGroupRequest
|
|
||||||
resp cms_api_struct.GetGroupResponse
|
|
||||||
reqPb pbGroup.GetGroupReq
|
|
||||||
)
|
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.GroupName = req.GroupName
|
|
||||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
|
||||||
utils.CopyStructFields(&reqPb.Pagination, req)
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
|
||||||
respPb, err := client.GetGroup(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroup failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for _, v := range respPb.CMSGroups {
|
|
||||||
groupResp := cms_api_struct.GroupResponse{}
|
|
||||||
utils.CopyStructFields(&groupResp, v.GroupInfo)
|
|
||||||
groupResp.GroupOwnerName = v.GroupOwnerUserName
|
|
||||||
groupResp.GroupOwnerID = v.GroupOwnerUserID
|
|
||||||
resp.Groups = append(resp.Groups, groupResp)
|
|
||||||
}
|
|
||||||
resp.CurrentPage = int(respPb.Pagination.PageNumber)
|
|
||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
|
||||||
resp.GroupNums = int(respPb.GroupNums)
|
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateGroup(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.CreateGroupRequest
|
|
||||||
_ cms_api_struct.CreateGroupResponse
|
|
||||||
reqPb pbGroup.CreateGroupReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.GroupInfo = &commonPb.GroupInfo{}
|
|
||||||
reqPb.GroupInfo.GroupName = req.GroupName
|
|
||||||
reqPb.GroupInfo.CreatorUserID = req.GroupMasterId
|
|
||||||
reqPb.OwnerUserID = req.GroupMasterId
|
|
||||||
reqPb.OpUserID = req.GroupMasterId
|
|
||||||
for _, v := range req.GroupMembers {
|
|
||||||
reqPb.InitMemberList = append(reqPb.InitMemberList, &pbGroup.GroupAddMemberInfo{
|
|
||||||
UserID: v,
|
|
||||||
RoleLevel: 1,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
|
||||||
_, err := client.CreateGroup(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "CreateGroup failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetGroupMembers(c *gin.Context) {
|
func GetGroupMembers(c *gin.Context) {
|
||||||
@ -188,9 +67,9 @@ func GetGroupMembers(c *gin.Context) {
|
|||||||
reqPb pbGroup.GetGroupMembersCMSReq
|
reqPb pbGroup.GetGroupMembersCMSReq
|
||||||
resp cms_api_struct.GetGroupMembersResponse
|
resp cms_api_struct.GetGroupMembersResponse
|
||||||
)
|
)
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
@ -212,7 +91,7 @@ func GetGroupMembers(c *gin.Context) {
|
|||||||
respPb, err := client.GetGroupMembersCMS(context.Background(), &reqPb)
|
respPb, err := client.GetGroupMembersCMS(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroupMembersCMS failed:", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroupMembersCMS failed:", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
resp.ResponsePagination = cms_api_struct.ResponsePagination{
|
resp.ResponsePagination = cms_api_struct.ResponsePagination{
|
||||||
@ -226,179 +105,5 @@ func GetGroupMembers(c *gin.Context) {
|
|||||||
resp.GroupMembers = append(resp.GroupMembers, memberResp)
|
resp.GroupMembers = append(resp.GroupMembers, memberResp)
|
||||||
}
|
}
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
|
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
|
||||||
|
|
||||||
func AddGroupMembers(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.RemoveGroupMembersRequest
|
|
||||||
resp cms_api_struct.RemoveGroupMembersResponse
|
|
||||||
reqPb pbGroup.AddGroupMembersCMSReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.UserIDList = req.Members
|
|
||||||
reqPb.GroupID = req.GroupId
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
|
||||||
respPb, err := client.AddGroupMembersCMS(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "AddGroupMembersCMS failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.Success = respPb.Success
|
|
||||||
resp.Failed = respPb.Failed
|
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func RemoveGroupMembers(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.RemoveGroupMembersRequest
|
|
||||||
resp cms_api_struct.RemoveGroupMembersResponse
|
|
||||||
reqPb pbGroup.RemoveGroupMembersCMSReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.UserIDList = req.Members
|
|
||||||
reqPb.GroupID = req.GroupId
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
|
||||||
respPb, err := client.RemoveGroupMembersCMS(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "RemoveGroupMembersCMS failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.Success = respPb.Success
|
|
||||||
resp.Failed = respPb.Failed
|
|
||||||
log.NewInfo("", utils.GetSelfFuncName(), "req: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetGroupOwner(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.SetGroupMasterRequest
|
|
||||||
_ cms_api_struct.SetGroupMasterResponse
|
|
||||||
reqPb pbGroup.OperateUserRoleReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.GroupID = req.GroupId
|
|
||||||
reqPb.UserID = req.UserId
|
|
||||||
reqPb.RoleLevel = constant.GroupOwner
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
|
||||||
_, err := client.OperateUserRole(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "DeleteGroup failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetGroupOrdinaryUsers(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.SetGroupMemberRequest
|
|
||||||
_ cms_api_struct.AdminLoginResponse
|
|
||||||
reqPb pbGroup.OperateUserRoleReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.GroupID = req.GroupId
|
|
||||||
reqPb.UserID = req.UserId
|
|
||||||
reqPb.RoleLevel = constant.GroupOrdinaryUsers
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
|
||||||
_, err := client.OperateUserRole(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "DeleteGroup failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func AlterGroupInfo(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.AlterGroupInfoRequest
|
|
||||||
_ cms_api_struct.SetGroupMasterResponse
|
|
||||||
reqPb pbGroup.SetGroupInfoReq
|
|
||||||
)
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OpUserID = c.MustGet("userID").(string)
|
|
||||||
reqPb.GroupInfoForSet = &commonPb.GroupInfoForSet{
|
|
||||||
GroupID: req.GroupID,
|
|
||||||
GroupName: req.GroupName,
|
|
||||||
Introduction: req.Introduction,
|
|
||||||
Notification: req.Notification,
|
|
||||||
FaceURL: req.ProfilePhoto,
|
|
||||||
}
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
|
||||||
_, err := client.SetGroupInfo(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "DeleteGroup failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
|
||||||
}
|
}
|
||||||
|
@ -3,96 +3,27 @@ package messageCMS
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/cms_api_struct"
|
"Open_IM/pkg/cms_api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
openIMHttp "Open_IM/pkg/common/http"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbMessage "Open_IM/pkg/proto/message_cms"
|
pbAdminCMS "Open_IM/pkg/proto/admin_cms"
|
||||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"Open_IM/pkg/common/constant"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func BroadcastMessage(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
reqPb pbMessage.BoradcastMessageReq
|
|
||||||
)
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
|
||||||
_, err := client.BoradcastMessage(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetChatLogs rpc failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func MassSendMassage(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
reqPb pbMessage.MassSendMessageReq
|
|
||||||
)
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
|
||||||
_, err := client.MassSendMessage(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetChatLogs rpc failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func WithdrawMessage(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
reqPb pbMessage.WithdrawMessageReq
|
|
||||||
)
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
|
||||||
_, err := client.WithdrawMessage(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetChatLogs rpc failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetChatLogs(c *gin.Context) {
|
func GetChatLogs(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetChatLogsRequest
|
req cms_api_struct.GetChatLogsReq
|
||||||
resp cms_api_struct.GetChatLogsResponse
|
resp cms_api_struct.GetChatLogsResp
|
||||||
reqPb pbMessage.GetChatLogsReq
|
reqPb pbAdminCMS.GetChatLogsReq
|
||||||
)
|
)
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.Bind(&req); err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.Pagination = &pbCommon.RequestPagination{
|
reqPb.Pagination = &pbCommon.RequestPagination{
|
||||||
@ -101,39 +32,28 @@ func GetChatLogs(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
utils.CopyStructFields(&reqPb, &req)
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMessageCMSName, reqPb.OperationID)
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
log.NewError(reqPb.OperationID, errMsg)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pbMessage.NewMessageCMSClient(etcdConn)
|
client := pbAdminCMS.NewAdminCMSClient(etcdConn)
|
||||||
respPb, err := client.GetChatLogs(context.Background(), &reqPb)
|
respPb, err := client.GetChatLogs(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetChatLogs rpc failed", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetChatLogs rpc failed", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, resp)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//utils.CopyStructFields(&resp, &respPb)
|
for _, v := range respPb.ChatLogs {
|
||||||
for _, chatLog := range respPb.ChatLogs {
|
chatLog := cms_api_struct.ChatLog{}
|
||||||
resp.ChatLogs = append(resp.ChatLogs, cms_api_struct.ChatLog{
|
utils.CopyStructFields(&chatLog, v)
|
||||||
SessionType: int(chatLog.SessionType),
|
resp.ChatLogs = append(resp.ChatLogs, &chatLog)
|
||||||
ContentType: int(chatLog.ContentType),
|
|
||||||
SenderNickName: chatLog.SenderNickName,
|
|
||||||
SenderId: chatLog.SenderId,
|
|
||||||
SearchContent: chatLog.SearchContent,
|
|
||||||
WholeContent: chatLog.WholeContent,
|
|
||||||
ReceiverNickName: chatLog.ReciverNickName,
|
|
||||||
ReceiverID: chatLog.ReciverId,
|
|
||||||
GroupName: chatLog.GroupName,
|
|
||||||
GroupId: chatLog.GroupId,
|
|
||||||
Date: chatLog.Date,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
||||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||||
resp.ChatLogsNum = int(respPb.ChatLogsNum)
|
resp.ChatLogsNum = int(respPb.ChatLogsNum)
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp", resp)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
package middleware
|
package middleware
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/constant"
|
|
||||||
"Open_IM/pkg/common/http"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func JWTAuth() gin.HandlerFunc {
|
func JWTAuth() gin.HandlerFunc {
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
ok, userID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), "")
|
ok, userID, errInfo := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), "")
|
||||||
log.NewInfo("0", utils.GetSelfFuncName(), "userID: ", userID)
|
// log.NewInfo("0", utils.GetSelfFuncName(), "userID: ", userID)
|
||||||
c.Set("userID", userID)
|
c.Set("userID", userID)
|
||||||
if !ok {
|
if !ok {
|
||||||
log.NewError("", "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
log.NewError("", "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||||
c.Abort()
|
c.Abort()
|
||||||
http.RespHttp200(c, constant.ErrParseToken, nil)
|
c.JSON(http.StatusOK, gin.H{"errCode": 400, "errMsg": errInfo})
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
log.NewInfo("0", utils.GetSelfFuncName(), "failed: ", errInfo)
|
log.NewInfo("0", utils.GetSelfFuncName(), "failed: ", errInfo)
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
package organization
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
func GetStaffs(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetOrganizations(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetSquads(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func AlterStaff(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func AddOrganization(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func InquireOrganization(g *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func AlterOrganization(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func DeleteOrganization(g *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetOrganizationSquads(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func AlterStaffsInfo(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func AddChildOrganization(c *gin.Context) {
|
|
||||||
|
|
||||||
}
|
|
14
internal/cms_api/prome.go
Normal file
14
internal/cms_api/prome.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package cms_api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
|
)
|
||||||
|
|
||||||
|
func prometheusHandler() gin.HandlerFunc {
|
||||||
|
h := promhttp.Handler()
|
||||||
|
|
||||||
|
return func(c *gin.Context) {
|
||||||
|
h.ServeHTTP(c.Writer, c.Request)
|
||||||
|
}
|
||||||
|
}
|
@ -2,12 +2,14 @@ package cms_api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/internal/cms_api/admin"
|
"Open_IM/internal/cms_api/admin"
|
||||||
|
"Open_IM/internal/cms_api/friend"
|
||||||
"Open_IM/internal/cms_api/group"
|
"Open_IM/internal/cms_api/group"
|
||||||
messageCMS "Open_IM/internal/cms_api/message_cms"
|
messageCMS "Open_IM/internal/cms_api/message_cms"
|
||||||
"Open_IM/internal/cms_api/middleware"
|
"Open_IM/internal/cms_api/middleware"
|
||||||
"Open_IM/internal/cms_api/organization"
|
|
||||||
"Open_IM/internal/cms_api/statistics"
|
"Open_IM/internal/cms_api/statistics"
|
||||||
"Open_IM/internal/cms_api/user"
|
"Open_IM/internal/cms_api/user"
|
||||||
|
"Open_IM/internal/demo/register"
|
||||||
|
"Open_IM/pkg/common/config"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
@ -15,6 +17,9 @@ import (
|
|||||||
func NewGinRouter() *gin.Engine {
|
func NewGinRouter() *gin.Engine {
|
||||||
gin.SetMode(gin.ReleaseMode)
|
gin.SetMode(gin.ReleaseMode)
|
||||||
baseRouter := gin.Default()
|
baseRouter := gin.Default()
|
||||||
|
if config.Config.Prometheus.Enable {
|
||||||
|
baseRouter.GET("/metrics", prometheusHandler())
|
||||||
|
}
|
||||||
router := baseRouter.Group("/cms")
|
router := baseRouter.Group("/cms")
|
||||||
router.Use(middleware.CorsHandler())
|
router.Use(middleware.CorsHandler())
|
||||||
adminRouterGroup := router.Group("/admin")
|
adminRouterGroup := router.Group("/admin")
|
||||||
@ -24,65 +29,49 @@ func NewGinRouter() *gin.Engine {
|
|||||||
adminRouterGroup.POST("/add_user_register_add_friend_id", admin.AddUserRegisterAddFriendIDList)
|
adminRouterGroup.POST("/add_user_register_add_friend_id", admin.AddUserRegisterAddFriendIDList)
|
||||||
adminRouterGroup.POST("/reduce_user_register_reduce_friend_id", admin.ReduceUserRegisterAddFriendIDList)
|
adminRouterGroup.POST("/reduce_user_register_reduce_friend_id", admin.ReduceUserRegisterAddFriendIDList)
|
||||||
adminRouterGroup.POST("/get_user_register_reduce_friend_id_list", admin.GetUserRegisterAddFriendIDList)
|
adminRouterGroup.POST("/get_user_register_reduce_friend_id_list", admin.GetUserRegisterAddFriendIDList)
|
||||||
|
|
||||||
|
adminRouterGroup.POST("/generate_invitation_code", register.GenerateInvitationCode)
|
||||||
|
adminRouterGroup.POST("/query_invitation_code", register.QueryInvitationCode)
|
||||||
|
adminRouterGroup.POST("/get_invitation_codes", register.GetInvitationCodes)
|
||||||
|
|
||||||
|
adminRouterGroup.POST("/query_user_ip_limit_login", register.QueryUserIDLimitLogin)
|
||||||
|
adminRouterGroup.POST("/add_user_ip_limit_login", register.AddUserIPLimitLogin)
|
||||||
|
adminRouterGroup.POST("/remove_user_ip_limit_login", register.RemoveUserIPLimitLogin)
|
||||||
|
|
||||||
|
adminRouterGroup.POST("/query_ip_register", register.QueryIPRegister)
|
||||||
|
adminRouterGroup.POST("/add_ip_limit", register.AddIPLimit)
|
||||||
|
adminRouterGroup.POST("/remove_ip_Limit", register.RemoveIPLimit)
|
||||||
}
|
}
|
||||||
r2 := router.Group("")
|
r2 := router.Group("")
|
||||||
r2.Use(middleware.JWTAuth())
|
r2.Use(middleware.JWTAuth())
|
||||||
statisticsRouterGroup := r2.Group("/statistics")
|
statisticsRouterGroup := r2.Group("/statistics")
|
||||||
{
|
{
|
||||||
statisticsRouterGroup.GET("/get_messages_statistics", statistics.GetMessagesStatistics)
|
statisticsRouterGroup.POST("/get_messages_statistics", statistics.GetMessagesStatistics)
|
||||||
statisticsRouterGroup.GET("/get_user_statistics", statistics.GetUserStatistics)
|
statisticsRouterGroup.POST("/get_user_statistics", statistics.GetUserStatistics)
|
||||||
statisticsRouterGroup.GET("/get_group_statistics", statistics.GetGroupStatistics)
|
statisticsRouterGroup.POST("/get_group_statistics", statistics.GetGroupStatistics)
|
||||||
statisticsRouterGroup.GET("/get_active_user", statistics.GetActiveUser)
|
statisticsRouterGroup.POST("/get_active_user", statistics.GetActiveUser)
|
||||||
statisticsRouterGroup.GET("/get_active_group", statistics.GetActiveGroup)
|
statisticsRouterGroup.POST("/get_active_group", statistics.GetActiveGroup)
|
||||||
}
|
|
||||||
organizationRouterGroup := r2.Group("/organization")
|
|
||||||
{
|
|
||||||
organizationRouterGroup.GET("/get_staffs", organization.GetStaffs)
|
|
||||||
organizationRouterGroup.GET("/get_organizations", organization.GetOrganizations)
|
|
||||||
organizationRouterGroup.GET("/get_squad", organization.GetSquads)
|
|
||||||
organizationRouterGroup.POST("/add_organization", organization.AddOrganization)
|
|
||||||
organizationRouterGroup.POST("/alter_staff", organization.AlterStaff)
|
|
||||||
organizationRouterGroup.GET("/inquire_organization", organization.InquireOrganization)
|
|
||||||
organizationRouterGroup.POST("/alter_organization", organization.AlterOrganization)
|
|
||||||
organizationRouterGroup.POST("/delete_organization", organization.DeleteOrganization)
|
|
||||||
organizationRouterGroup.POST("/get_organization_squad", organization.GetOrganizationSquads)
|
|
||||||
organizationRouterGroup.PATCH("/alter_corps_info", organization.AlterStaffsInfo)
|
|
||||||
organizationRouterGroup.POST("/add_child_org", organization.AddChildOrganization)
|
|
||||||
}
|
}
|
||||||
groupRouterGroup := r2.Group("/group")
|
groupRouterGroup := r2.Group("/group")
|
||||||
{
|
{
|
||||||
groupRouterGroup.GET("/get_group_by_id", group.GetGroupByID)
|
groupRouterGroup.POST("/get_groups", group.GetGroups)
|
||||||
groupRouterGroup.GET("/get_groups", group.GetGroups)
|
groupRouterGroup.POST("/get_group_members", group.GetGroupMembers)
|
||||||
groupRouterGroup.GET("/get_group_by_name", group.GetGroupByName)
|
|
||||||
groupRouterGroup.GET("/get_group_members", group.GetGroupMembers)
|
|
||||||
groupRouterGroup.POST("/create_group", group.CreateGroup)
|
|
||||||
groupRouterGroup.POST("/add_members", group.AddGroupMembers)
|
|
||||||
groupRouterGroup.POST("/remove_members", group.RemoveGroupMembers)
|
|
||||||
groupRouterGroup.POST("/get_members_in_group", group.GetGroupMembers)
|
|
||||||
groupRouterGroup.POST("/set_group_master", group.SetGroupOwner)
|
|
||||||
groupRouterGroup.POST("/set_group_ordinary_user", group.SetGroupOrdinaryUsers)
|
|
||||||
groupRouterGroup.POST("/alter_group_info", group.AlterGroupInfo)
|
|
||||||
}
|
}
|
||||||
userRouterGroup := r2.Group("/user")
|
userRouterGroup := r2.Group("/user")
|
||||||
{
|
{
|
||||||
userRouterGroup.POST("/resign", user.ResignUser)
|
|
||||||
userRouterGroup.GET("/get_user", user.GetUserById)
|
|
||||||
userRouterGroup.POST("/alter_user", user.AlterUser)
|
|
||||||
userRouterGroup.GET("/get_users", user.GetUsers)
|
|
||||||
userRouterGroup.POST("/add_user", user.AddUser)
|
userRouterGroup.POST("/add_user", user.AddUser)
|
||||||
userRouterGroup.POST("/unblock_user", user.UnblockUser)
|
userRouterGroup.POST("/unblock_user", user.UnblockUser)
|
||||||
userRouterGroup.POST("/block_user", user.BlockUser)
|
userRouterGroup.POST("/block_user", user.BlockUser)
|
||||||
userRouterGroup.GET("/get_block_users", user.GetBlockUsers)
|
userRouterGroup.POST("/get_block_users", user.GetBlockUsers)
|
||||||
userRouterGroup.GET("/get_block_user", user.GetBlockUserById)
|
|
||||||
userRouterGroup.POST("/delete_user", user.DeleteUser)
|
|
||||||
userRouterGroup.GET("/get_users_by_name", user.GetUsersByName)
|
|
||||||
}
|
}
|
||||||
messageCMSRouterGroup := r2.Group("/message")
|
messageCMSRouterGroup := r2.Group("/message")
|
||||||
{
|
{
|
||||||
messageCMSRouterGroup.GET("/get_chat_logs", messageCMS.GetChatLogs)
|
messageCMSRouterGroup.POST("/get_chat_logs", messageCMS.GetChatLogs)
|
||||||
messageCMSRouterGroup.POST("/broadcast_message", messageCMS.BroadcastMessage)
|
|
||||||
messageCMSRouterGroup.POST("/mass_send_message", messageCMS.MassSendMassage)
|
|
||||||
messageCMSRouterGroup.POST("/withdraw_message", messageCMS.WithdrawMessage)
|
|
||||||
}
|
}
|
||||||
|
friendCMSRouterGroup := r2.Group("/friend")
|
||||||
|
{
|
||||||
|
friendCMSRouterGroup.POST("/get_friends", friend.GetUserFriends)
|
||||||
|
}
|
||||||
|
|
||||||
return baseRouter
|
return baseRouter
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,14 @@ package statistics
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/cms_api_struct"
|
"Open_IM/pkg/cms_api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
|
||||||
openIMHttp "Open_IM/pkg/common/http"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pb "Open_IM/pkg/proto/statistics"
|
admin "Open_IM/pkg/proto/admin_cms"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
@ -20,38 +19,40 @@ func GetMessagesStatistics(c *gin.Context) {
|
|||||||
var (
|
var (
|
||||||
req cms_api_struct.GetMessageStatisticsRequest
|
req cms_api_struct.GetMessageStatisticsRequest
|
||||||
resp cms_api_struct.GetMessageStatisticsResponse
|
resp cms_api_struct.GetMessageStatisticsResponse
|
||||||
reqPb pb.GetMessageStatisticsReq
|
reqPb admin.GetMessageStatisticsReq
|
||||||
)
|
)
|
||||||
reqPb.StatisticsReq = &pb.StatisticsReq{}
|
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
log.NewError(reqPb.OperationID, errMsg)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := admin.NewAdminCMSClient(etcdConn)
|
||||||
respPb, err := client.GetMessageStatistics(context.Background(), &reqPb)
|
ctx, cancel := context.WithTimeout(context.TODO(), time.Second*100)
|
||||||
|
defer cancel()
|
||||||
|
respPb, err := client.GetMessageStatistics(ctx, &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetMessageStatistics failed", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetMessageStatistics failed", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, resp)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// utils.CopyStructFields(&resp, respPb)
|
|
||||||
resp.GroupMessageNum = int(respPb.GroupMessageNum)
|
resp.GroupMessageNum = int(respPb.GroupMessageNum)
|
||||||
resp.PrivateMessageNum = int(respPb.PrivateMessageNum)
|
resp.PrivateMessageNum = int(respPb.PrivateMessageNum)
|
||||||
for _, v := range respPb.PrivateMessageNumList {
|
for _, v := range respPb.PrivateMessageNumList {
|
||||||
resp.PrivateMessageNumList = append(resp.PrivateMessageNumList, struct {
|
resp.PrivateMessageNumList = append(resp.PrivateMessageNumList, struct {
|
||||||
Date string "json:\"date\""
|
Date string "json:\"date\""
|
||||||
MessageNum int "json:\"message_num\""
|
MessageNum int "json:\"messageNum\""
|
||||||
}{
|
}{
|
||||||
Date: v.Date,
|
Date: v.Date,
|
||||||
MessageNum: int(v.Num),
|
MessageNum: int(v.Num),
|
||||||
@ -60,53 +61,54 @@ func GetMessagesStatistics(c *gin.Context) {
|
|||||||
for _, v := range respPb.GroupMessageNumList {
|
for _, v := range respPb.GroupMessageNumList {
|
||||||
resp.GroupMessageNumList = append(resp.GroupMessageNumList, struct {
|
resp.GroupMessageNumList = append(resp.GroupMessageNumList, struct {
|
||||||
Date string "json:\"date\""
|
Date string "json:\"date\""
|
||||||
MessageNum int "json:\"message_num\""
|
MessageNum int "json:\"messageNum\""
|
||||||
}{
|
}{
|
||||||
Date: v.Date,
|
Date: v.Date,
|
||||||
MessageNum: int(v.Num),
|
MessageNum: int(v.Num),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUserStatistics(c *gin.Context) {
|
func GetUserStatistics(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetUserStatisticsRequest
|
req cms_api_struct.GetUserStatisticsRequest
|
||||||
resp cms_api_struct.GetUserStatisticsResponse
|
resp cms_api_struct.GetUserStatisticsResponse
|
||||||
reqPb pb.GetUserStatisticsReq
|
reqPb admin.GetUserStatisticsReq
|
||||||
)
|
)
|
||||||
reqPb.StatisticsReq = &pb.StatisticsReq{}
|
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
log.NewError(reqPb.OperationID, errMsg)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := admin.NewAdminCMSClient(etcdConn)
|
||||||
respPb, err := client.GetUserStatistics(context.Background(), &reqPb)
|
ctx, cancel := context.WithTimeout(context.TODO(), time.Second*100)
|
||||||
|
defer cancel()
|
||||||
|
respPb, err := client.GetUserStatistics(ctx, &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetUserStatistics failed", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetUserStatistics failed", err.Error(), reqPb.String())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// utils.CopyStructFields(&resp, respPb)
|
|
||||||
resp.ActiveUserNum = int(respPb.ActiveUserNum)
|
resp.ActiveUserNum = int(respPb.ActiveUserNum)
|
||||||
resp.IncreaseUserNum = int(respPb.IncreaseUserNum)
|
resp.IncreaseUserNum = int(respPb.IncreaseUserNum)
|
||||||
resp.TotalUserNum = int(respPb.TotalUserNum)
|
resp.TotalUserNum = int(respPb.TotalUserNum)
|
||||||
for _, v := range respPb.ActiveUserNumList {
|
for _, v := range respPb.ActiveUserNumList {
|
||||||
resp.ActiveUserNumList = append(resp.ActiveUserNumList, struct {
|
resp.ActiveUserNumList = append(resp.ActiveUserNumList, struct {
|
||||||
Date string "json:\"date\""
|
Date string "json:\"date\""
|
||||||
ActiveUserNum int "json:\"active_user_num\""
|
ActiveUserNum int "json:\"activeUserNum\""
|
||||||
}{
|
}{
|
||||||
Date: v.Date,
|
Date: v.Date,
|
||||||
ActiveUserNum: int(v.Num),
|
ActiveUserNum: int(v.Num),
|
||||||
@ -115,7 +117,7 @@ func GetUserStatistics(c *gin.Context) {
|
|||||||
for _, v := range respPb.IncreaseUserNumList {
|
for _, v := range respPb.IncreaseUserNumList {
|
||||||
resp.IncreaseUserNumList = append(resp.IncreaseUserNumList, struct {
|
resp.IncreaseUserNumList = append(resp.IncreaseUserNumList, struct {
|
||||||
Date string "json:\"date\""
|
Date string "json:\"date\""
|
||||||
IncreaseUserNum int "json:\"increase_user_num\""
|
IncreaseUserNum int "json:\"increaseUserNum\""
|
||||||
}{
|
}{
|
||||||
Date: v.Date,
|
Date: v.Date,
|
||||||
IncreaseUserNum: int(v.Num),
|
IncreaseUserNum: int(v.Num),
|
||||||
@ -124,43 +126,45 @@ func GetUserStatistics(c *gin.Context) {
|
|||||||
for _, v := range respPb.TotalUserNumList {
|
for _, v := range respPb.TotalUserNumList {
|
||||||
resp.TotalUserNumList = append(resp.TotalUserNumList, struct {
|
resp.TotalUserNumList = append(resp.TotalUserNumList, struct {
|
||||||
Date string "json:\"date\""
|
Date string "json:\"date\""
|
||||||
TotalUserNum int "json:\"total_user_num\""
|
TotalUserNum int "json:\"totalUserNum\""
|
||||||
}{
|
}{
|
||||||
Date: v.Date,
|
Date: v.Date,
|
||||||
TotalUserNum: int(v.Num),
|
TotalUserNum: int(v.Num),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetGroupStatistics(c *gin.Context) {
|
func GetGroupStatistics(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetGroupStatisticsRequest
|
req cms_api_struct.GetGroupStatisticsRequest
|
||||||
resp cms_api_struct.GetGroupStatisticsResponse
|
resp cms_api_struct.GetGroupStatisticsResponse
|
||||||
reqPb pb.GetGroupStatisticsReq
|
reqPb admin.GetGroupStatisticsReq
|
||||||
)
|
)
|
||||||
reqPb.StatisticsReq = &pb.StatisticsReq{}
|
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
log.NewError(req.OperationID, "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
utils.CopyStructFields(&reqPb.StatisticsReq, &req)
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
log.NewError(reqPb.OperationID, errMsg)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := admin.NewAdminCMSClient(etcdConn)
|
||||||
respPb, err := client.GetGroupStatistics(context.Background(), &reqPb)
|
ctx, cancel := context.WithTimeout(context.TODO(), time.Second*100)
|
||||||
|
defer cancel()
|
||||||
|
respPb, err := client.GetGroupStatistics(ctx, &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroupStatistics failed", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroupStatistics failed", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// utils.CopyStructFields(&resp, respPb)
|
// utils.CopyStructFields(&resp, respPb)
|
||||||
@ -170,7 +174,7 @@ func GetGroupStatistics(c *gin.Context) {
|
|||||||
resp.IncreaseGroupNumList = append(resp.IncreaseGroupNumList,
|
resp.IncreaseGroupNumList = append(resp.IncreaseGroupNumList,
|
||||||
struct {
|
struct {
|
||||||
Date string "json:\"date\""
|
Date string "json:\"date\""
|
||||||
IncreaseGroupNum int "json:\"increase_group_num\""
|
IncreaseGroupNum int "json:\"increaseGroupNum\""
|
||||||
}{
|
}{
|
||||||
Date: v.Date,
|
Date: v.Date,
|
||||||
IncreaseGroupNum: int(v.Num),
|
IncreaseGroupNum: int(v.Num),
|
||||||
@ -180,7 +184,7 @@ func GetGroupStatistics(c *gin.Context) {
|
|||||||
resp.TotalGroupNumList = append(resp.TotalGroupNumList,
|
resp.TotalGroupNumList = append(resp.TotalGroupNumList,
|
||||||
struct {
|
struct {
|
||||||
Date string "json:\"date\""
|
Date string "json:\"date\""
|
||||||
TotalGroupNum int "json:\"total_group_num\""
|
TotalGroupNum int "json:\"totalGroupNum\""
|
||||||
}{
|
}{
|
||||||
Date: v.Date,
|
Date: v.Date,
|
||||||
TotalGroupNum: int(v.Num),
|
TotalGroupNum: int(v.Num),
|
||||||
@ -188,77 +192,81 @@ func GetGroupStatistics(c *gin.Context) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetActiveUser(c *gin.Context) {
|
func GetActiveUser(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetActiveUserRequest
|
req cms_api_struct.GetActiveUserRequest
|
||||||
resp cms_api_struct.GetActiveUserResponse
|
resp cms_api_struct.GetActiveUserResponse
|
||||||
reqPb pb.GetActiveUserReq
|
reqPb admin.GetActiveUserReq
|
||||||
)
|
)
|
||||||
reqPb.StatisticsReq = &pb.StatisticsReq{}
|
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
log.NewError(req.OperationID, "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb.StatisticsReq, req)
|
utils.CopyStructFields(&reqPb.StatisticsReq, req)
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
log.NewError(reqPb.OperationID, errMsg)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := admin.NewAdminCMSClient(etcdConn)
|
||||||
respPb, err := client.GetActiveUser(context.Background(), &reqPb)
|
ctx, cancel := context.WithTimeout(context.TODO(), time.Second*100)
|
||||||
|
defer cancel()
|
||||||
|
respPb, err := client.GetActiveUser(ctx, &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetActiveUser failed ", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetActiveUser failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
utils.CopyStructFields(&resp.ActiveUserList, respPb.Users)
|
utils.CopyStructFields(&resp.ActiveUserList, respPb.Users)
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetActiveGroup(c *gin.Context) {
|
func GetActiveGroup(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.GetActiveGroupRequest
|
req cms_api_struct.GetActiveGroupRequest
|
||||||
resp cms_api_struct.GetActiveGroupResponse
|
resp cms_api_struct.GetActiveGroupResponse
|
||||||
reqPb pb.GetActiveGroupReq
|
reqPb admin.GetActiveGroupReq
|
||||||
)
|
)
|
||||||
reqPb.StatisticsReq = &pb.StatisticsReq{}
|
reqPb.StatisticsReq = &admin.StatisticsReq{}
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError("0", utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
||||||
utils.CopyStructFields(&reqPb.StatisticsReq, req)
|
utils.CopyStructFields(&reqPb.StatisticsReq, req)
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImStatisticsName, reqPb.OperationID)
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName, reqPb.OperationID)
|
||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
log.NewError(reqPb.OperationID, errMsg)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := admin.NewAdminCMSClient(etcdConn)
|
||||||
respPb, err := client.GetActiveGroup(context.Background(), &reqPb)
|
ctx, cancel := context.WithTimeout(context.TODO(), time.Second*100)
|
||||||
|
defer cancel()
|
||||||
|
respPb, err := client.GetActiveGroup(ctx, &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetActiveGroup failed ", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetActiveGroup failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, group := range respPb.Groups {
|
for _, group := range respPb.Groups {
|
||||||
resp.ActiveGroupList = append(resp.ActiveGroupList, struct {
|
resp.ActiveGroupList = append(resp.ActiveGroupList, struct {
|
||||||
GroupName string "json:\"group_name\""
|
GroupName string "json:\"groupName\""
|
||||||
GroupId string "json:\"group_id\""
|
GroupId string "json:\"groupID\""
|
||||||
MessageNum int "json:\"message_num\""
|
MessageNum int "json:\"messageNum\""
|
||||||
}{
|
}{
|
||||||
GroupName: group.GroupName,
|
GroupName: group.GroupName,
|
||||||
GroupId: group.GroupId,
|
GroupId: group.GroupId,
|
||||||
@ -266,5 +274,5 @@ func GetActiveGroup(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
}
|
||||||
|
@ -3,196 +3,18 @@ package user
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/cms_api_struct"
|
"Open_IM/pkg/cms_api_struct"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
|
||||||
openIMHttp "Open_IM/pkg/common/http"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
commonPb "Open_IM/pkg/proto/sdk_ws"
|
commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||||
pb "Open_IM/pkg/proto/user"
|
pb "Open_IM/pkg/proto/user"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetUserById(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.GetUserRequest
|
|
||||||
resp cms_api_struct.GetUserResponse
|
|
||||||
reqPb pb.GetUserByIdReq
|
|
||||||
)
|
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
|
||||||
respPb, err := client.GetUserById(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if respPb.User.UserId == "" {
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
utils.CopyStructFields(&resp, respPb.User)
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetUsersByName(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.GetUsersByNameRequest
|
|
||||||
resp cms_api_struct.GetUsersByNameResponse
|
|
||||||
reqPb pb.GetUsersByNameReq
|
|
||||||
)
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.UserName = req.UserName
|
|
||||||
reqPb.Pagination = &commonPb.RequestPagination{
|
|
||||||
PageNumber: int32(req.PageNumber),
|
|
||||||
ShowNumber: int32(req.ShowNumber),
|
|
||||||
}
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
|
||||||
respPb, err := client.GetUsersByName(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "rpc", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
utils.CopyStructFields(&resp.Users, respPb.Users)
|
|
||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
|
||||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
|
||||||
resp.UserNums = respPb.UserNums
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetUsers(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.GetUsersRequest
|
|
||||||
resp cms_api_struct.GetUsersResponse
|
|
||||||
reqPb pb.GetUsersReq
|
|
||||||
)
|
|
||||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
|
||||||
log.NewError("0", "ShouldBindQuery failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb.Pagination, &req)
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
|
||||||
respPb, err := client.GetUsers(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
openIMHttp.RespHttp200(c, err, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
utils.CopyStructFields(&resp.Users, respPb.User)
|
|
||||||
resp.ShowNumber = int(respPb.Pagination.ShowNumber)
|
|
||||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
|
||||||
resp.UserNums = respPb.UserNums
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func ResignUser(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.ResignUserRequest
|
|
||||||
resp cms_api_struct.ResignUserResponse
|
|
||||||
reqPb pb.ResignUserReq
|
|
||||||
)
|
|
||||||
if err := c.ShouldBind(&req); err != nil {
|
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": http.StatusBadRequest, "errMsg": err.Error()})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
|
||||||
_, err := client.ResignUser(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
openIMHttp.RespHttp200(c, err, resp)
|
|
||||||
}
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func AlterUser(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.AlterUserRequest
|
|
||||||
resp cms_api_struct.AlterUserResponse
|
|
||||||
reqPb pb.AlterUserReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
utils.CopyStructFields(&reqPb, &req)
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
|
||||||
_, err := client.AlterUser(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, "microserver failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
}
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func AddUser(c *gin.Context) {
|
func AddUser(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.AddUserRequest
|
req cms_api_struct.AddUserRequest
|
||||||
@ -200,7 +22,7 @@ func AddUser(c *gin.Context) {
|
|||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
@ -214,24 +36,23 @@ func AddUser(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
_, err := client.AddUser(context.Background(), &reqPb)
|
respPb, err := client.AddUser(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), reqPb.String())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
||||||
}
|
}
|
||||||
|
|
||||||
func BlockUser(c *gin.Context) {
|
func BlockUser(c *gin.Context) {
|
||||||
var (
|
var (
|
||||||
req cms_api_struct.BlockUserRequest
|
req cms_api_struct.BlockUserRequest
|
||||||
resp cms_api_struct.BlockUserResponse
|
|
||||||
reqPb pb.BlockUserReq
|
reqPb pb.BlockUserReq
|
||||||
)
|
)
|
||||||
if err := c.BindJSON(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
fmt.Println(err)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
@ -245,13 +66,13 @@ func BlockUser(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
fmt.Println(reqPb)
|
respPb, err := client.BlockUser(context.Background(), &reqPb)
|
||||||
_, err := client.BlockUser(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
openIMHttp.RespHttp200(c, err, resp)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), reqPb.String())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
||||||
}
|
}
|
||||||
|
|
||||||
func UnblockUser(c *gin.Context) {
|
func UnblockUser(c *gin.Context) {
|
||||||
@ -260,9 +81,9 @@ func UnblockUser(c *gin.Context) {
|
|||||||
resp cms_api_struct.UnBlockUserResponse
|
resp cms_api_struct.UnBlockUserResponse
|
||||||
reqPb pb.UnBlockUserReq
|
reqPb pb.UnBlockUserReq
|
||||||
)
|
)
|
||||||
if err := c.ShouldBind(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
log.NewError(req.OperationID, "BindJSON failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
@ -276,13 +97,14 @@ func UnblockUser(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
client := pb.NewUserClient(etcdConn)
|
client := pb.NewUserClient(etcdConn)
|
||||||
_, err := client.UnBlockUser(context.Background(), &reqPb)
|
respPb, err := client.UnBlockUser(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
openIMHttp.RespHttp200(c, err, resp)
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), err.Error(), reqPb.String())
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg})
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetBlockUsers(c *gin.Context) {
|
func GetBlockUsers(c *gin.Context) {
|
||||||
@ -293,9 +115,9 @@ func GetBlockUsers(c *gin.Context) {
|
|||||||
respPb *pb.GetBlockUsersResp
|
respPb *pb.GetBlockUsersResp
|
||||||
)
|
)
|
||||||
reqPb.Pagination = &commonPb.RequestPagination{}
|
reqPb.Pagination = &commonPb.RequestPagination{}
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
if err := c.BindJSON(&req); err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "ShouldBindQuery failed ", err.Error())
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, resp)
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
reqPb.OperationID = utils.OperationIDGenerator()
|
||||||
@ -313,21 +135,18 @@ func GetBlockUsers(c *gin.Context) {
|
|||||||
respPb, err := client.GetBlockUsers(context.Background(), &reqPb)
|
respPb, err := client.GetBlockUsers(context.Background(), &reqPb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetBlockUsers rpc", err.Error())
|
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetBlockUsers rpc", err.Error())
|
||||||
openIMHttp.RespHttp200(c, err, resp)
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range respPb.BlockUsers {
|
for _, v := range respPb.BlockUsers {
|
||||||
resp.BlockUsers = append(resp.BlockUsers, cms_api_struct.BlockUser{
|
resp.BlockUsers = append(resp.BlockUsers, cms_api_struct.BlockUser{
|
||||||
UserResponse: cms_api_struct.UserResponse{
|
UserResponse: cms_api_struct.UserResponse{
|
||||||
UserId: v.User.UserId,
|
UserID: v.UserInfo.UserID,
|
||||||
ProfilePhoto: v.User.ProfilePhoto,
|
FaceURL: v.UserInfo.FaceURL,
|
||||||
Nickname: v.User.Nickname,
|
Nickname: v.UserInfo.Nickname,
|
||||||
IsBlock: v.User.IsBlock,
|
PhoneNumber: v.UserInfo.PhoneNumber,
|
||||||
Birth: v.User.Birth,
|
Email: v.UserInfo.Email,
|
||||||
PhoneNumber: v.User.PhoneNumber,
|
Gender: int(v.UserInfo.Gender),
|
||||||
Email: v.User.Email,
|
|
||||||
Gender: int(v.User.Gender),
|
|
||||||
CreateTime: v.User.CreateTime,
|
|
||||||
},
|
},
|
||||||
BeginDisableTime: v.BeginDisableTime,
|
BeginDisableTime: v.BeginDisableTime,
|
||||||
EndDisableTime: v.EndDisableTime,
|
EndDisableTime: v.EndDisableTime,
|
||||||
@ -337,70 +156,5 @@ func GetBlockUsers(c *gin.Context) {
|
|||||||
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
resp.CurrentPage = int(respPb.Pagination.CurrentPage)
|
||||||
resp.UserNums = respPb.UserNums
|
resp.UserNums = respPb.UserNums
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", resp)
|
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", resp)
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
c.JSON(http.StatusOK, gin.H{"errCode": respPb.CommonResp.ErrCode, "errMsg": respPb.CommonResp.ErrMsg, "data": resp})
|
||||||
}
|
|
||||||
|
|
||||||
func GetBlockUserById(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.GetBlockUserRequest
|
|
||||||
resp cms_api_struct.GetBlockUserResponse
|
|
||||||
reqPb pb.GetBlockUserByIdReq
|
|
||||||
)
|
|
||||||
if err := c.ShouldBindQuery(&req); err != nil {
|
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.UserId = req.UserId
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
|
||||||
respPb, err := client.GetBlockUserById(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, "GetBlockUserById rpc failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp.EndDisableTime = respPb.BlockUser.EndDisableTime
|
|
||||||
resp.BeginDisableTime = respPb.BlockUser.BeginDisableTime
|
|
||||||
utils.CopyStructFields(&resp, respPb.BlockUser.User)
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func DeleteUser(c *gin.Context) {
|
|
||||||
var (
|
|
||||||
req cms_api_struct.DeleteUserRequest
|
|
||||||
reqPb pb.DeleteUserReq
|
|
||||||
)
|
|
||||||
if err := c.BindJSON(&req); err != nil {
|
|
||||||
log.NewError("0", "BindJSON failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
reqPb.OperationID = utils.OperationIDGenerator()
|
|
||||||
log.NewInfo(reqPb.OperationID, utils.GetSelfFuncName(), "req: ", req)
|
|
||||||
reqPb.UserId = req.UserId
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, reqPb.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := reqPb.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(reqPb.OperationID, errMsg)
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pb.NewUserClient(etcdConn)
|
|
||||||
_, err := client.DeleteUser(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(reqPb.OperationID, "DeleteUser rpc failed ", err.Error())
|
|
||||||
openIMHttp.RespHttp200(c, err, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
|
||||||
}
|
}
|
||||||
|
85
internal/demo/register/check_login.go
Normal file
85
internal/demo/register/check_login.go
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
package register
|
||||||
|
|
||||||
|
import (
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
|
"Open_IM/pkg/common/log"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CheckLoginLimitReq struct {
|
||||||
|
OperationID string `json:"operationID"`
|
||||||
|
UserID string `json:"userID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CheckLoginLimitResp struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func CheckLoginLimit(c *gin.Context) {
|
||||||
|
req := CheckLoginLimitReq{}
|
||||||
|
if err := c.BindJSON(&req); err != nil {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ip := c.Request.Header.Get("X-Forward-For")
|
||||||
|
if ip == "" {
|
||||||
|
ip = c.ClientIP()
|
||||||
|
}
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "IP: ", ip)
|
||||||
|
user, err := imdb.GetUserIPLimit(req.UserID)
|
||||||
|
if err != nil && !errors.Is(gorm.ErrRecordNotFound, err) {
|
||||||
|
errMsg := req.OperationID + " imdb.GetUserByUserID failed " + err.Error() + req.UserID
|
||||||
|
log.NewError(req.OperationID, errMsg)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": errMsg})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := imdb.UpdateIpReocord(req.UserID, ip); err != nil {
|
||||||
|
log.NewError(req.OperationID, err.Error(), req.UserID, ip)
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var Limited bool
|
||||||
|
var LimitError error
|
||||||
|
Limited, LimitError = imdb.IsLimitLoginIp(ip)
|
||||||
|
if LimitError != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), LimitError, ip)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": LimitError})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if Limited {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), Limited, ip, req.UserID)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.LoginLimit, "errMsg": "ip limited Login"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Limited, LimitError = imdb.IsLimitUserLoginIp(user.UserID, ip)
|
||||||
|
if LimitError != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), LimitError, ip)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": LimitError})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if Limited {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), Limited, ip, req.UserID)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.LoginLimit, "errMsg": "user ip limited Login"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Limited, LimitError = imdb.UserIsBlock(user.UserID)
|
||||||
|
if LimitError != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), LimitError, user.UserID)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.ErrDB.ErrCode, "errMsg": LimitError})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if Limited {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), Limited, ip, req.UserID)
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.LoginLimit, "errMsg": "user is block"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": ""})
|
||||||
|
}
|
@ -6,9 +6,10 @@ import (
|
|||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type InvitationCode struct {
|
type InvitationCode struct {
|
||||||
@ -88,6 +89,7 @@ type GetInvitationCodesReq struct {
|
|||||||
type GetInvitationCodesResp struct {
|
type GetInvitationCodesResp struct {
|
||||||
apiStruct.Pagination
|
apiStruct.Pagination
|
||||||
Codes []InvitationCode `json:"codes"`
|
Codes []InvitationCode `json:"codes"`
|
||||||
|
CodeNums int64 `json:"codeNums"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetInvitationCodes(c *gin.Context) {
|
func GetInvitationCodes(c *gin.Context) {
|
||||||
@ -98,7 +100,7 @@ func GetInvitationCodes(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||||
codes, err := imdb.GetInvitationCodes(req.ShowNumber, req.PageNumber, req.Status)
|
codes, count, err := imdb.GetInvitationCodes(req.ShowNumber, req.PageNumber, req.Status)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "GetInvitationCode failed", req.ShowNumber, req.PageNumber, req.Status)
|
log.NewError(req.OperationID, "GetInvitationCode failed", req.ShowNumber, req.PageNumber, req.Status)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "Verification code error!"})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": constant.ErrDB, "errMsg": "Verification code error!"})
|
||||||
@ -115,6 +117,7 @@ func GetInvitationCodes(c *gin.Context) {
|
|||||||
Status: v.Status,
|
Status: v.Status,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
resp.CodeNums = count
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp:", resp)
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,9 @@ import (
|
|||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
//"github.com/jinzhu/gorm"
|
//"github.com/jinzhu/gorm"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@ -141,7 +143,7 @@ func QueryUserIDLimitLogin(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": resp})
|
c.JSON(http.StatusOK, gin.H{"errCode": 0, "errMsg": "", "data": gin.H{"limit": resp}})
|
||||||
}
|
}
|
||||||
|
|
||||||
type AddUserIPLimitLoginReq struct {
|
type AddUserIPLimitLoginReq struct {
|
||||||
@ -164,7 +166,7 @@ func AddUserIPLimitLogin(c *gin.Context) {
|
|||||||
userIp := db.UserIpLimit{UserID: req.UserID, Ip: req.IP}
|
userIp := db.UserIpLimit{UserID: req.UserID, Ip: req.IP}
|
||||||
err := imdb.UpdateUserInfo(db.User{
|
err := imdb.UpdateUserInfo(db.User{
|
||||||
UserID: req.UserID,
|
UserID: req.UserID,
|
||||||
LoginLimit: 1,
|
// LoginLimit: 1,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID)
|
||||||
|
@ -16,10 +16,11 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/golang/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OnboardingProcessReq struct {
|
type OnboardingProcessReq struct {
|
||||||
@ -48,9 +49,7 @@ func OnboardingProcessRoutine() {
|
|||||||
|
|
||||||
func onboardingProcess(operationID, userID, userName, faceURL, phoneNumber, email string) {
|
func onboardingProcess(operationID, userID, userName, faceURL, phoneNumber, email string) {
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), userName, userID, faceURL)
|
log.NewInfo(operationID, utils.GetSelfFuncName(), userName, userID, faceURL)
|
||||||
if err := createOrganizationUser(operationID, userID, userName, phoneNumber, email); err != nil {
|
|
||||||
log.NewError(operationID, utils.GetSelfFuncName(), "createOrganizationUser failed", err.Error())
|
|
||||||
}
|
|
||||||
var joinDepartmentIDList []string
|
var joinDepartmentIDList []string
|
||||||
if len(config.Config.Demo.JoinDepartmentIDList) == 0 {
|
if len(config.Config.Demo.JoinDepartmentIDList) == 0 {
|
||||||
departmentID, err := imdb.GetRandomDepartmentID()
|
departmentID, err := imdb.GetRandomDepartmentID()
|
||||||
@ -62,12 +61,16 @@ func onboardingProcess(operationID, userID, userName, faceURL, phoneNumber, emai
|
|||||||
} else {
|
} else {
|
||||||
joinDepartmentIDList = config.Config.Demo.JoinDepartmentIDList
|
joinDepartmentIDList = config.Config.Demo.JoinDepartmentIDList
|
||||||
}
|
}
|
||||||
|
if config.Config.Demo.CreateOrganizationUserAndJoinDepartment && len(joinDepartmentIDList) > 0 {
|
||||||
|
if err := createOrganizationUser(operationID, userID, userName, phoneNumber, email); err != nil {
|
||||||
|
log.NewError(operationID, utils.GetSelfFuncName(), "createOrganizationUser failed", err.Error())
|
||||||
|
}
|
||||||
for _, departmentID := range joinDepartmentIDList {
|
for _, departmentID := range joinDepartmentIDList {
|
||||||
if err := joinTestDepartment(operationID, userID, departmentID); err != nil {
|
if err := joinTestDepartment(operationID, userID, departmentID); err != nil {
|
||||||
log.NewError(operationID, utils.GetSelfFuncName(), "joinTestDepartment failed", err.Error())
|
log.NewError(operationID, utils.GetSelfFuncName(), "joinTestDepartment failed", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if config.Config.Demo.JoinDepartmentGroups {
|
if config.Config.Demo.JoinDepartmentGroups {
|
||||||
for _, departmentID := range joinDepartmentIDList {
|
for _, departmentID := range joinDepartmentIDList {
|
||||||
@ -75,6 +78,7 @@ func onboardingProcess(operationID, userID, userName, faceURL, phoneNumber, emai
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
|
log.NewError(operationID, utils.GetSelfFuncName(), err.Error())
|
||||||
}
|
}
|
||||||
|
log.Debug(operationID, utils.GetSelfFuncName(), "getjoinGroupIDListdepartmentID", groupIDList)
|
||||||
joinGroups(operationID, userID, userName, faceURL, groupIDList)
|
joinGroups(operationID, userID, userName, faceURL, groupIDList)
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName(), "fineshed")
|
log.NewInfo(operationID, utils.GetSelfFuncName(), "fineshed")
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
http2 "Open_IM/pkg/common/http"
|
http2 "Open_IM/pkg/common/http"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
|
"Open_IM/pkg/common/token_verify"
|
||||||
pbFriend "Open_IM/pkg/proto/friend"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -32,6 +33,8 @@ type ParamsSetPassword struct {
|
|||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
AreaCode string `json:"areaCode"`
|
AreaCode string `json:"areaCode"`
|
||||||
InvitationCode string `json:"invitationCode"`
|
InvitationCode string `json:"invitationCode"`
|
||||||
|
Gender int32 `json:"gender"`
|
||||||
|
Birth int32 `json:"birth"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetPassword(c *gin.Context) {
|
func SetPassword(c *gin.Context) {
|
||||||
@ -41,12 +44,14 @@ func SetPassword(c *gin.Context) {
|
|||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.FormattingError, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ip := c.Request.Header.Get("X-Forward-For")
|
ip := c.Request.Header.Get("X-Forward-For")
|
||||||
if ip == "" {
|
if ip == "" {
|
||||||
ip = c.ClientIP()
|
ip = c.ClientIP()
|
||||||
}
|
}
|
||||||
log.NewDebug(params.OperationID, utils.GetSelfFuncName(), "ip:", ip)
|
log.NewDebug(params.OperationID, utils.GetSelfFuncName(), "ip:", ip)
|
||||||
|
|
||||||
|
ok, opUserID, _ := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), params.OperationID)
|
||||||
|
if !ok || !utils.IsContain(opUserID, config.Config.Manager.AppManagerUid) {
|
||||||
Limited, LimitError := imdb.IsLimitRegisterIp(ip)
|
Limited, LimitError := imdb.IsLimitRegisterIp(ip)
|
||||||
if LimitError != nil {
|
if LimitError != nil {
|
||||||
log.Error(params.OperationID, utils.GetSelfFuncName(), LimitError, ip)
|
log.Error(params.OperationID, utils.GetSelfFuncName(), LimitError, ip)
|
||||||
@ -54,15 +59,19 @@ func SetPassword(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if Limited {
|
if Limited {
|
||||||
|
log.NewInfo(params.OperationID, utils.GetSelfFuncName(), "is limited", ip, "params:", params)
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.RegisterLimit, "errMsg": "limited"})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": constant.RegisterLimit, "errMsg": "limited"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
openIMRegisterReq := api.UserRegisterReq{}
|
||||||
var account string
|
var account string
|
||||||
if params.Email != "" {
|
if params.Email != "" {
|
||||||
account = params.Email
|
account = params.Email
|
||||||
|
openIMRegisterReq.Email = params.Email
|
||||||
} else if params.PhoneNumber != "" {
|
} else if params.PhoneNumber != "" {
|
||||||
account = params.PhoneNumber
|
account = params.PhoneNumber
|
||||||
|
openIMRegisterReq.PhoneNumber = params.PhoneNumber
|
||||||
} else {
|
} else {
|
||||||
account = params.UserID
|
account = params.UserID
|
||||||
}
|
}
|
||||||
@ -84,7 +93,7 @@ func SetPassword(c *gin.Context) {
|
|||||||
if config.Config.Demo.NeedInvitationCode && params.InvitationCode != "" {
|
if config.Config.Demo.NeedInvitationCode && params.InvitationCode != "" {
|
||||||
err := imdb.CheckInvitationCode(params.InvitationCode)
|
err := imdb.CheckInvitationCode(params.InvitationCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.InvitationError, "errMsg": "邀请码错误"})
|
c.JSON(http.StatusOK, gin.H{"errCode": constant.InvitationError, "errMsg": "InvitationCode error"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,18 +108,15 @@ func SetPassword(c *gin.Context) {
|
|||||||
} else {
|
} else {
|
||||||
userID = params.UserID
|
userID = params.UserID
|
||||||
}
|
}
|
||||||
|
|
||||||
url := config.Config.Demo.ImAPIURL + "/auth/user_register"
|
url := config.Config.Demo.ImAPIURL + "/auth/user_register"
|
||||||
openIMRegisterReq := api.UserRegisterReq{}
|
|
||||||
openIMRegisterReq.OperationID = params.OperationID
|
openIMRegisterReq.OperationID = params.OperationID
|
||||||
openIMRegisterReq.Platform = params.Platform
|
openIMRegisterReq.Platform = params.Platform
|
||||||
openIMRegisterReq.UserID = userID
|
openIMRegisterReq.UserID = userID
|
||||||
openIMRegisterReq.Nickname = params.Nickname
|
openIMRegisterReq.Nickname = params.Nickname
|
||||||
openIMRegisterReq.Secret = config.Config.Secret
|
openIMRegisterReq.Secret = config.Config.Secret
|
||||||
openIMRegisterReq.FaceURL = params.FaceURL
|
openIMRegisterReq.FaceURL = params.FaceURL
|
||||||
openIMRegisterReq.CreateIp = ip
|
openIMRegisterReq.Gender = params.Gender
|
||||||
openIMRegisterReq.LastLoginIp = ip
|
openIMRegisterReq.Birth = uint32(params.Birth)
|
||||||
openIMRegisterReq.InvitationCode = params.InvitationCode
|
|
||||||
openIMRegisterResp := api.UserRegisterResp{}
|
openIMRegisterResp := api.UserRegisterResp{}
|
||||||
log.NewDebug(params.OperationID, utils.GetSelfFuncName(), "register req:", openIMRegisterReq)
|
log.NewDebug(params.OperationID, utils.GetSelfFuncName(), "register req:", openIMRegisterReq)
|
||||||
bMsg, err := http2.Post(url, openIMRegisterReq, 2)
|
bMsg, err := http2.Post(url, openIMRegisterReq, 2)
|
||||||
@ -124,14 +130,10 @@ func SetPassword(c *gin.Context) {
|
|||||||
log.NewError(params.OperationID, "request openIM register error", account, "err", "resp: ", openIMRegisterResp.ErrCode)
|
log.NewError(params.OperationID, "request openIM register error", account, "err", "resp: ", openIMRegisterResp.ErrCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err.Error())
|
log.NewError(params.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
|
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": "register limit"})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
if openIMRegisterResp.ErrCode == constant.RegisterLimit {
|
if openIMRegisterResp.ErrCode != 0 {
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterLimit, "errMsg": "用户注册被限制"})
|
|
||||||
return
|
|
||||||
} else if openIMRegisterResp.ErrCode == constant.InvitationError {
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.InvitationError, "errMsg": "邀请码错误"})
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": "register failed: " + openIMRegisterResp.ErrMsg})
|
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": "register failed: " + openIMRegisterResp.ErrMsg})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -150,8 +152,11 @@ func SetPassword(c *gin.Context) {
|
|||||||
imdb.FinishInvitationCode(params.InvitationCode, userID)
|
imdb.FinishInvitationCode(params.InvitationCode, userID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err := imdb.InsertIpRecord(userID, ip); err != nil {
|
||||||
|
log.NewError(params.OperationID, utils.GetSelfFuncName(), userID, ip, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
log.Info(params.OperationID, "end setPassword", account, params.Password)
|
log.Info(params.OperationID, "end setuserInfo", account, params.Password)
|
||||||
// demo onboarding
|
// demo onboarding
|
||||||
if params.UserID == "" && config.Config.Demo.OnboardProcess {
|
if params.UserID == "" && config.Config.Demo.OnboardProcess {
|
||||||
select {
|
select {
|
||||||
@ -168,6 +173,7 @@ func SetPassword(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// register add friend
|
||||||
select {
|
select {
|
||||||
case ChImportFriend <- &pbFriend.ImportFriendReq{
|
case ChImportFriend <- &pbFriend.ImportFriendReq{
|
||||||
OperationID: params.OperationID,
|
OperationID: params.OperationID,
|
||||||
|
@ -153,6 +153,7 @@ func (ws *WServer) pullMsgBySeqListReq(conn *UserConn, m *Req) {
|
|||||||
ws.pullMsgBySeqListResp(conn, m, nReply)
|
ws.pullMsgBySeqListResp(conn, m, nReply)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ws *WServer) pullMsgBySeqListResp(conn *UserConn, m *Req, pb *sdk_ws.PullMessageBySeqListResp) {
|
func (ws *WServer) pullMsgBySeqListResp(conn *UserConn, m *Req, pb *sdk_ws.PullMessageBySeqListResp) {
|
||||||
log.NewInfo(m.OperationID, "pullMsgBySeqListResp come here ", pb.String())
|
log.NewInfo(m.OperationID, "pullMsgBySeqListResp come here ", pb.String())
|
||||||
c, _ := proto.Marshal(pb)
|
c, _ := proto.Marshal(pb)
|
||||||
@ -166,10 +167,9 @@ func (ws *WServer) pullMsgBySeqListResp(conn *UserConn, m *Req, pb *sdk_ws.PullM
|
|||||||
}
|
}
|
||||||
log.NewInfo(m.OperationID, "pullMsgBySeqListResp all data is ", mReply.ReqIdentifier, mReply.MsgIncr, mReply.ErrCode, mReply.ErrMsg,
|
log.NewInfo(m.OperationID, "pullMsgBySeqListResp all data is ", mReply.ReqIdentifier, mReply.MsgIncr, mReply.ErrCode, mReply.ErrMsg,
|
||||||
len(mReply.Data))
|
len(mReply.Data))
|
||||||
|
|
||||||
ws.sendMsg(conn, mReply)
|
ws.sendMsg(conn, mReply)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ws *WServer) sendMsgReq(conn *UserConn, m *Req) {
|
func (ws *WServer) sendMsgReq(conn *UserConn, m *Req) {
|
||||||
sendMsgAllCountLock.Lock()
|
sendMsgAllCountLock.Lock()
|
||||||
sendMsgAllCount++
|
sendMsgAllCount++
|
||||||
|
@ -66,6 +66,7 @@ func (r *RPCServer) run() {
|
|||||||
err = getcdv3.RegisterEtcd4Unique(r.etcdSchema, strings.Join(r.etcdAddr, ","), rpcRegisterIP, r.rpcPort, r.rpcRegisterName, 10)
|
err = getcdv3.RegisterEtcd4Unique(r.etcdSchema, strings.Join(r.etcdAddr, ","), rpcRegisterIP, r.rpcPort, r.rpcRegisterName, 10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("", "register push message rpc to etcd err", "", "err", err.Error(), r.etcdSchema, strings.Join(r.etcdAddr, ","), rpcRegisterIP, r.rpcPort, r.rpcRegisterName)
|
log.Error("", "register push message rpc to etcd err", "", "err", err.Error(), r.etcdSchema, strings.Join(r.etcdAddr, ","), rpcRegisterIP, r.rpcPort, r.rpcRegisterName)
|
||||||
|
panic(utils.Wrap(err, "register msg_gataway module rpc to etcd err"))
|
||||||
}
|
}
|
||||||
r.target = getcdv3.GetTarget(r.etcdSchema, rpcRegisterIP, r.rpcPort, r.rpcRegisterName)
|
r.target = getcdv3.GetTarget(r.etcdSchema, rpcRegisterIP, r.rpcPort, r.rpcRegisterName)
|
||||||
err = srv.Serve(listener)
|
err = srv.Serve(listener)
|
||||||
|
@ -138,7 +138,9 @@ func (ws *WServer) MultiTerminalLoginRemoteChecker(userID string, platformID int
|
|||||||
}
|
}
|
||||||
if resp.ErrCode != 0 {
|
if resp.ErrCode != 0 {
|
||||||
log.Error(operationID, "MultiTerminalLoginCheck errCode, errMsg: ", resp.ErrCode, resp.ErrMsg)
|
log.Error(operationID, "MultiTerminalLoginCheck errCode, errMsg: ", resp.ErrCode, resp.ErrMsg)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
log.Debug(operationID, "MultiTerminalLoginCheck resp ", resp.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,7 +368,11 @@ func (ws *WServer) getUserAllCons(uid string) map[int]*UserConn {
|
|||||||
rwLock.RLock()
|
rwLock.RLock()
|
||||||
defer rwLock.RUnlock()
|
defer rwLock.RUnlock()
|
||||||
if connMap, ok := ws.wsUserToConn[uid]; ok {
|
if connMap, ok := ws.wsUserToConn[uid]; ok {
|
||||||
return connMap
|
newConnMap := make(map[int]*UserConn)
|
||||||
|
for k, v := range connMap {
|
||||||
|
newConnMap[k] = v
|
||||||
|
}
|
||||||
|
return newConnMap
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,11 @@ import (
|
|||||||
"Open_IM/pkg/common/kafka"
|
"Open_IM/pkg/common/kafka"
|
||||||
"Open_IM/pkg/statistics"
|
"Open_IM/pkg/statistics"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
)
|
)
|
||||||
|
|
||||||
const OnlineTopicBusy = 1
|
const OnlineTopicBusy = 1
|
||||||
@ -36,8 +40,8 @@ var (
|
|||||||
func Init() {
|
func Init() {
|
||||||
cmdCh = make(chan Cmd2Value, 10000)
|
cmdCh = make(chan Cmd2Value, 10000)
|
||||||
w = new(sync.Mutex)
|
w = new(sync.Mutex)
|
||||||
persistentCH.Init() // 订阅ws2mschat 消费到 mysql
|
persistentCH.Init() // ws2mschat save mysql
|
||||||
historyCH.Init(cmdCh) // 订阅ws2mschat 如果可靠性存储 消费到 incrseq 再存入mongo 再push || 非可靠性 直接incr再push 初始化ws2mschat
|
historyCH.Init(cmdCh) //
|
||||||
historyMongoCH.Init()
|
historyMongoCH.Init()
|
||||||
onlineTopicStatus = OnlineTopicVacancy
|
onlineTopicStatus = OnlineTopicVacancy
|
||||||
//offlineHistoryCH.Init(cmdCh)
|
//offlineHistoryCH.Init(cmdCh)
|
||||||
@ -46,7 +50,7 @@ func Init() {
|
|||||||
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ms2pschat.Addr, config.Config.Kafka.Ms2pschat.Topic)
|
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ms2pschat.Addr, config.Config.Kafka.Ms2pschat.Topic)
|
||||||
producerToMongo = kafka.NewKafkaProducer(config.Config.Kafka.MsgToMongo.Addr, config.Config.Kafka.MsgToMongo.Topic)
|
producerToMongo = kafka.NewKafkaProducer(config.Config.Kafka.MsgToMongo.Addr, config.Config.Kafka.MsgToMongo.Topic)
|
||||||
}
|
}
|
||||||
func Run() {
|
func Run(promethuesPort int) {
|
||||||
//register mysqlConsumerHandler to
|
//register mysqlConsumerHandler to
|
||||||
if config.Config.ChatPersistenceMysql {
|
if config.Config.ChatPersistenceMysql {
|
||||||
go persistentCH.persistentConsumerGroup.RegisterHandleAndConsumer(&persistentCH)
|
go persistentCH.persistentConsumerGroup.RegisterHandleAndConsumer(&persistentCH)
|
||||||
@ -56,6 +60,10 @@ func Run() {
|
|||||||
go historyCH.historyConsumerGroup.RegisterHandleAndConsumer(&historyCH)
|
go historyCH.historyConsumerGroup.RegisterHandleAndConsumer(&historyCH)
|
||||||
go historyMongoCH.historyConsumerGroup.RegisterHandleAndConsumer(&historyMongoCH)
|
go historyMongoCH.historyConsumerGroup.RegisterHandleAndConsumer(&historyMongoCH)
|
||||||
//go offlineHistoryCH.historyConsumerGroup.RegisterHandleAndConsumer(&offlineHistoryCH)
|
//go offlineHistoryCH.historyConsumerGroup.RegisterHandleAndConsumer(&offlineHistoryCH)
|
||||||
|
if config.Config.Prometheus.Enable {
|
||||||
|
http.Handle("/metrics", promhttp.Handler())
|
||||||
|
http.ListenAndServe(":"+strconv.Itoa(promethuesPort), nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
func SetOnlineTopicStatus(status int) {
|
func SetOnlineTopicStatus(status int) {
|
||||||
w.Lock()
|
w.Lock()
|
||||||
|
@ -14,8 +14,16 @@ import (
|
|||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
pbMsg "Open_IM/pkg/proto/msg"
|
pbMsg "Open_IM/pkg/proto/msg"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
|
|
||||||
"github.com/Shopify/sarama"
|
"github.com/Shopify/sarama"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
|
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
msgInsertMysqlProcessed prometheus.Counter
|
||||||
)
|
)
|
||||||
|
|
||||||
type PersistentConsumerHandler struct {
|
type PersistentConsumerHandler struct {
|
||||||
@ -29,7 +37,12 @@ func (pc *PersistentConsumerHandler) Init() {
|
|||||||
pc.persistentConsumerGroup = kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0,
|
pc.persistentConsumerGroup = kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0,
|
||||||
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.Ws2mschat.Topic},
|
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.Ws2mschat.Topic},
|
||||||
config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMySql)
|
config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMySql)
|
||||||
|
if config.Config.Prometheus.Enable {
|
||||||
|
msgInsertMysqlProcessed = promauto.NewCounter(prometheus.CounterOpts{
|
||||||
|
Name: "insert_mysql_msg_total",
|
||||||
|
Help: "The total number of msg insert mysql events",
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pc *PersistentConsumerHandler) handleChatWs2Mysql(cMsg *sarama.ConsumerMessage, msgKey string, _ sarama.ConsumerGroupSession) {
|
func (pc *PersistentConsumerHandler) handleChatWs2Mysql(cMsg *sarama.ConsumerMessage, msgKey string, _ sarama.ConsumerGroupSession) {
|
||||||
@ -65,6 +78,12 @@ func (pc *PersistentConsumerHandler) handleChatWs2Mysql(cMsg *sarama.ConsumerMes
|
|||||||
log.NewError(msgFromMQ.OperationID, "Message insert failed", "err", err.Error(), "msg", msgFromMQ.String())
|
log.NewError(msgFromMQ.OperationID, "Message insert failed", "err", err.Error(), "msg", msgFromMQ.String())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
msgInsertMysqlProcessed.Inc()
|
||||||
|
msgInsertMysqlProcessed.Add(1)
|
||||||
|
if config.Config.Prometheus.Enable {
|
||||||
|
log.NewDebug(msgFromMQ.OperationID, utils.GetSelfFuncName(), "inc msgInsertMysqlProcessed", msgInsertMysqlProcessed.Desc())
|
||||||
|
msgInsertMysqlProcessed.Inc()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,14 @@ import (
|
|||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/tools/splitter"
|
|
||||||
"context"
|
"context"
|
||||||
|
go_redis "github.com/go-redis/redis/v8"
|
||||||
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
firebase "firebase.google.com/go"
|
firebase "firebase.google.com/go"
|
||||||
"firebase.google.com/go/messaging"
|
"firebase.google.com/go/messaging"
|
||||||
"google.golang.org/api/option"
|
"google.golang.org/api/option"
|
||||||
"path/filepath"
|
|
||||||
"strconv"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const SinglePushCountLimit = 400
|
const SinglePushCountLimit = 400
|
||||||
@ -46,45 +47,83 @@ func newFcmClient() *Fcm {
|
|||||||
return &Fcm{FcmMsgCli: fcmMsgClient}
|
return &Fcm{FcmMsgCli: fcmMsgClient}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Fcm) Push(accounts []string, alert, detailContent, operationID string, opts push.PushOpts) (string, error) {
|
func (f *Fcm) Push(accounts []string, title, detailContent, operationID string, opts push.PushOpts) (string, error) {
|
||||||
// accounts->registrationToken
|
// accounts->registrationToken
|
||||||
Tokens := make([]string, 0)
|
allTokens := make(map[string][]string, 0)
|
||||||
for _, account := range accounts {
|
for _, account := range accounts {
|
||||||
IosfcmToken, IosErr := db.DB.GetFcmToken(account, 1)
|
var personTokens []string
|
||||||
AndroidfcmToken, AndroidErr := db.DB.GetFcmToken(account, 2)
|
for _, v := range push.PushTerminal {
|
||||||
|
Token, err := db.DB.GetFcmToken(account, v)
|
||||||
if IosErr == nil {
|
if err == nil {
|
||||||
Tokens = append(Tokens, IosfcmToken)
|
personTokens = append(personTokens, Token)
|
||||||
}
|
}
|
||||||
if AndroidErr == nil {
|
|
||||||
Tokens = append(Tokens, AndroidfcmToken)
|
|
||||||
}
|
}
|
||||||
|
allTokens[account] = personTokens
|
||||||
}
|
}
|
||||||
Success := 0
|
Success := 0
|
||||||
Fail := 0
|
Fail := 0
|
||||||
result := splitter.NewSplitter(SinglePushCountLimit, Tokens).GetSplitResult()
|
notification := &messaging.Notification{}
|
||||||
Msg := new(messaging.MulticastMessage)
|
notification.Body = detailContent
|
||||||
Msg.Notification = &messaging.Notification{}
|
notification.Title = title
|
||||||
Msg.Notification.Body = detailContent
|
var messages []*messaging.Message
|
||||||
Msg.Notification.Title = alert
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
for _, v := range result {
|
for uid, personTokens := range allTokens {
|
||||||
Msg.Tokens = v.Item
|
apns := &messaging.APNSConfig{Payload: &messaging.APNSPayload{Aps: &messaging.Aps{Sound: opts.IOSPushSound}}}
|
||||||
//SendMulticast sends the given multicast message to all the FCM registration tokens specified.
|
messageCount := len(messages)
|
||||||
//The tokens array in MulticastMessage may contain up to 500 tokens.
|
if messageCount >= SinglePushCountLimit {
|
||||||
//SendMulticast uses the `SendAll()` function to send the given message to all the target recipients.
|
response, err := f.FcmMsgCli.SendAll(ctx, messages)
|
||||||
//The responses list obtained from the return value corresponds to the order of the input tokens.
|
|
||||||
//An error from SendMulticast indicates a total failure -- i.e.
|
|
||||||
//the message could not be sent to any of the recipients.
|
|
||||||
//Partial failures are indicated by a `BatchResponse` return value.
|
|
||||||
response, err := f.FcmMsgCli.SendMulticast(ctx, Msg)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fail = Fail + len(v.Item)
|
Fail = Fail + messageCount
|
||||||
log.Info(operationID, "some token push err", err.Error(), len(v.Item))
|
log.Info(operationID, "some token push err", err.Error(), messageCount)
|
||||||
continue
|
} else {
|
||||||
}
|
|
||||||
Success = Success + response.SuccessCount
|
Success = Success + response.SuccessCount
|
||||||
Fail = Fail + response.FailureCount
|
Fail = Fail + response.FailureCount
|
||||||
}
|
}
|
||||||
|
messages = messages[0:0]
|
||||||
|
}
|
||||||
|
if opts.IOSBadgeCount {
|
||||||
|
unreadCountSum, err := db.DB.IncrUserBadgeUnreadCountSum(uid)
|
||||||
|
if err == nil {
|
||||||
|
apns.Payload.Aps.Badge = &unreadCountSum
|
||||||
|
} else {
|
||||||
|
log.Error(operationID, "IncrUserBadgeUnreadCountSum redis err", err.Error(), uid)
|
||||||
|
Fail++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unreadCountSum, err := db.DB.GetUserBadgeUnreadCountSum(uid)
|
||||||
|
if err == nil && unreadCountSum != 0 {
|
||||||
|
apns.Payload.Aps.Badge = &unreadCountSum
|
||||||
|
} else if err == go_redis.Nil || unreadCountSum == 0 {
|
||||||
|
zero := 1
|
||||||
|
apns.Payload.Aps.Badge = &zero
|
||||||
|
} else {
|
||||||
|
log.Error(operationID, "GetUserBadgeUnreadCountSum redis err", err.Error(), uid)
|
||||||
|
Fail++
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, token := range personTokens {
|
||||||
|
temp := &messaging.Message{
|
||||||
|
Data: map[string]string{"ex": opts.Data},
|
||||||
|
Token: token,
|
||||||
|
Notification: notification,
|
||||||
|
APNS: apns,
|
||||||
|
}
|
||||||
|
messages = append(messages, temp)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
messageCount := len(messages)
|
||||||
|
if messageCount > 0 {
|
||||||
|
response, err := f.FcmMsgCli.SendAll(ctx, messages)
|
||||||
|
if err != nil {
|
||||||
|
Fail = Fail + messageCount
|
||||||
|
log.Info(operationID, "some token push err", err.Error(), messageCount)
|
||||||
|
} else {
|
||||||
|
Success = Success + response.SuccessCount
|
||||||
|
Fail = Fail + response.FailureCount
|
||||||
|
}
|
||||||
|
}
|
||||||
return strconv.Itoa(Success) + " Success," + strconv.Itoa(Fail) + " Fail", nil
|
return strconv.Itoa(Success) + " Success," + strconv.Itoa(Fail) + " Fail", nil
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,10 @@ type Options struct {
|
|||||||
} `json:"HW"`
|
} `json:"HW"`
|
||||||
XM struct {
|
XM struct {
|
||||||
ChannelID string `json:"/extra.channel_id"`
|
ChannelID string `json:"/extra.channel_id"`
|
||||||
} `json:""`
|
} `json:"XM"`
|
||||||
|
VV struct {
|
||||||
|
Classification int `json:"/classification"`
|
||||||
|
} `json:"VV"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PushResp struct {
|
type PushResp struct {
|
||||||
@ -112,7 +115,7 @@ func newGetuiClient() *Getui {
|
|||||||
return &Getui{}
|
return &Getui{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Getui) Push(userIDList []string, alert, detailContent, operationID string, opts push.PushOpts) (resp string, err error) {
|
func (g *Getui) Push(userIDList []string, title, detailContent, operationID string, opts push.PushOpts) (resp string, err error) {
|
||||||
token, err := db.DB.GetGetuiToken()
|
token, err := db.DB.GetGetuiToken()
|
||||||
log.NewDebug(operationID, utils.GetSelfFuncName(), "token:", token)
|
log.NewDebug(operationID, utils.GetSelfFuncName(), "token:", token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -132,18 +135,18 @@ func (g *Getui) Push(userIDList []string, alert, detailContent, operationID stri
|
|||||||
}{Alias: []string{userIDList[0]}},
|
}{Alias: []string{userIDList[0]}},
|
||||||
}
|
}
|
||||||
pushReq.PushMessage.Notification = Notification{
|
pushReq.PushMessage.Notification = Notification{
|
||||||
Title: alert,
|
Title: title,
|
||||||
Body: detailContent,
|
Body: detailContent,
|
||||||
ClickType: "startapp",
|
ClickType: "startapp",
|
||||||
}
|
}
|
||||||
pushReq.PushChannel.Ios.Aps.Sound = "default"
|
pushReq.PushChannel.Ios.Aps.Sound = "default"
|
||||||
pushReq.PushChannel.Ios.Aps.Alert = Alert{
|
pushReq.PushChannel.Ios.Aps.Alert = Alert{
|
||||||
Title: alert,
|
Title: title,
|
||||||
Body: alert,
|
Body: title,
|
||||||
}
|
}
|
||||||
pushReq.PushChannel.Android.Ups.Notification = Notification{
|
pushReq.PushChannel.Android.Ups.Notification = Notification{
|
||||||
Title: alert,
|
Title: title,
|
||||||
Body: alert,
|
Body: title,
|
||||||
ClickType: "startapp",
|
ClickType: "startapp",
|
||||||
}
|
}
|
||||||
pushReq.PushChannel.Android.Ups.Options = Options{
|
pushReq.PushChannel.Android.Ups.Options = Options{
|
||||||
@ -156,6 +159,11 @@ func (g *Getui) Push(userIDList []string, alert, detailContent, operationID stri
|
|||||||
XM: struct {
|
XM: struct {
|
||||||
ChannelID string `json:"/extra.channel_id"`
|
ChannelID string `json:"/extra.channel_id"`
|
||||||
}{ChannelID: "high_system"},
|
}{ChannelID: "high_system"},
|
||||||
|
VV: struct {
|
||||||
|
Classification int "json:\"/classification\""
|
||||||
|
}{
|
||||||
|
Classification: 1,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
pushResp := PushResp{}
|
pushResp := PushResp{}
|
||||||
err = g.request(PushURL, pushReq, token, &pushResp, operationID)
|
err = g.request(PushURL, pushReq, token, &pushResp, operationID)
|
||||||
|
@ -33,7 +33,7 @@ func (j *JPush) SetAlias(cid, alias string) (resp string, err error) {
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *JPush) Push(accounts []string, alert, detailContent, operationID string, opts push.PushOpts) (string, error) {
|
func (j *JPush) Push(accounts []string, title, detailContent, operationID string, opts push.PushOpts) (string, error) {
|
||||||
|
|
||||||
var pf requestBody.Platform
|
var pf requestBody.Platform
|
||||||
pf.SetAll()
|
pf.SetAll()
|
||||||
@ -47,7 +47,7 @@ func (j *JPush) Push(accounts []string, alert, detailContent, operationID string
|
|||||||
}
|
}
|
||||||
no.IOSEnableMutableContent()
|
no.IOSEnableMutableContent()
|
||||||
no.SetExtras(extras)
|
no.SetExtras(extras)
|
||||||
no.SetAlert(alert)
|
no.SetAlert(title)
|
||||||
var me requestBody.Message
|
var me requestBody.Message
|
||||||
me.SetMsgContent(detailContent)
|
me.SetMsgContent(detailContent)
|
||||||
var o requestBody.Options
|
var o requestBody.Options
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
http2 "net/http"
|
http2 "net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.MsgData, offlinePushUserIDList *[]string, offlineInfo *commonPb.OfflinePushInfo) cbApi.CommonCallbackResp {
|
func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.MsgData, offlinePushUserIDList *[]string) cbApi.CommonCallbackResp {
|
||||||
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
|
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
|
||||||
if !config.Config.Callback.CallbackOfflinePush.Enable {
|
if !config.Config.Callback.CallbackOfflinePush.Enable {
|
||||||
return callbackResp
|
return callbackResp
|
||||||
@ -28,6 +28,7 @@ func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.
|
|||||||
UserIDList: userIDList,
|
UserIDList: userIDList,
|
||||||
},
|
},
|
||||||
OfflinePushInfo: msg.OfflinePushInfo,
|
OfflinePushInfo: msg.OfflinePushInfo,
|
||||||
|
ClientMsgID: msg.ClientMsgID,
|
||||||
SendID: msg.SendID,
|
SendID: msg.SendID,
|
||||||
GroupID: msg.GroupID,
|
GroupID: msg.GroupID,
|
||||||
ContentType: msg.ContentType,
|
ContentType: msg.ContentType,
|
||||||
@ -52,7 +53,7 @@ func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.
|
|||||||
*offlinePushUserIDList = resp.UserIDList
|
*offlinePushUserIDList = resp.UserIDList
|
||||||
}
|
}
|
||||||
if resp.OfflinePushInfo != nil {
|
if resp.OfflinePushInfo != nil {
|
||||||
*offlineInfo = *resp.OfflinePushInfo
|
msg.OfflinePushInfo = resp.OfflinePushInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.NewDebug(operationID, utils.GetSelfFuncName(), offlinePushUserIDList, resp.UserIDList)
|
log.NewDebug(operationID, utils.GetSelfFuncName(), offlinePushUserIDList, resp.UserIDList)
|
||||||
@ -75,6 +76,7 @@ func callbackOnlinePush(operationID string, userIDList []string, msg *commonPb.M
|
|||||||
UserIDList: userIDList,
|
UserIDList: userIDList,
|
||||||
},
|
},
|
||||||
OfflinePushInfo: msg.OfflinePushInfo,
|
OfflinePushInfo: msg.OfflinePushInfo,
|
||||||
|
ClientMsgID: msg.ClientMsgID,
|
||||||
SendID: msg.SendID,
|
SendID: msg.SendID,
|
||||||
GroupID: msg.GroupID,
|
GroupID: msg.GroupID,
|
||||||
ContentType: msg.ContentType,
|
ContentType: msg.ContentType,
|
||||||
@ -111,6 +113,7 @@ func callbackBeforeSuperGroupOnlinePush(operationID string, groupID string, msg
|
|||||||
Platform: constant.PlatformIDToName(int(msg.SenderPlatformID)),
|
Platform: constant.PlatformIDToName(int(msg.SenderPlatformID)),
|
||||||
},
|
},
|
||||||
OfflinePushInfo: msg.OfflinePushInfo,
|
OfflinePushInfo: msg.OfflinePushInfo,
|
||||||
|
ClientMsgID: msg.ClientMsgID,
|
||||||
SendID: msg.SendID,
|
SendID: msg.SendID,
|
||||||
GroupID: groupID,
|
GroupID: groupID,
|
||||||
ContentType: msg.ContentType,
|
ContentType: msg.ContentType,
|
||||||
|
@ -21,17 +21,15 @@ import (
|
|||||||
var (
|
var (
|
||||||
rpcServer RPCServer
|
rpcServer RPCServer
|
||||||
pushCh PushConsumerHandler
|
pushCh PushConsumerHandler
|
||||||
pushTerminal []int32
|
|
||||||
producer *kafka.Producer
|
producer *kafka.Producer
|
||||||
offlinePusher pusher.OfflinePusher
|
offlinePusher pusher.OfflinePusher
|
||||||
successCount uint64
|
successCount uint64
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init(rpcPort int) {
|
func Init(rpcPort int) {
|
||||||
|
|
||||||
rpcServer.Init(rpcPort)
|
rpcServer.Init(rpcPort)
|
||||||
pushCh.Init()
|
pushCh.Init()
|
||||||
pushTerminal = []int32{constant.IOSPlatformID, constant.AndroidPlatformID}
|
|
||||||
}
|
}
|
||||||
func init() {
|
func init() {
|
||||||
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.Ws2mschat.Topic)
|
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.Ws2mschat.Topic)
|
||||||
|
@ -55,6 +55,7 @@ func (r *RPCServer) run() {
|
|||||||
err = getcdv3.RegisterEtcd(r.etcdSchema, strings.Join(r.etcdAddr, ","), rpcRegisterIP, r.rpcPort, r.rpcRegisterName, 10)
|
err = getcdv3.RegisterEtcd(r.etcdSchema, strings.Join(r.etcdAddr, ","), rpcRegisterIP, r.rpcPort, r.rpcRegisterName, 10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("", "register push module rpc to etcd err", err.Error(), r.etcdSchema, strings.Join(r.etcdAddr, ","), rpcRegisterIP, r.rpcPort, r.rpcRegisterName)
|
log.Error("", "register push module rpc to etcd err", err.Error(), r.etcdSchema, strings.Join(r.etcdAddr, ","), rpcRegisterIP, r.rpcPort, r.rpcRegisterName)
|
||||||
|
panic(utils.Wrap(err, "register push module rpc to etcd err"))
|
||||||
}
|
}
|
||||||
err = srv.Serve(listener)
|
err = srv.Serve(listener)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -8,19 +8,17 @@ package logic
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/internal/push"
|
"Open_IM/internal/push"
|
||||||
|
utils2 "Open_IM/internal/utils"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbCache "Open_IM/pkg/proto/cache"
|
|
||||||
pbPush "Open_IM/pkg/proto/push"
|
pbPush "Open_IM/pkg/proto/push"
|
||||||
pbRelay "Open_IM/pkg/proto/relay"
|
pbRelay "Open_IM/pkg/proto/relay"
|
||||||
pbRtc "Open_IM/pkg/proto/rtc"
|
pbRtc "Open_IM/pkg/proto/rtc"
|
||||||
commonPb "Open_IM/pkg/proto/sdk_ws"
|
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
@ -80,53 +78,17 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if pushMsg.MsgData.ContentType == constant.SignalingNotification {
|
if pushMsg.MsgData.ContentType == constant.SignalingNotification {
|
||||||
if err := db.DB.HandleSignalInfo(pushMsg.OperationID, pushMsg.MsgData); err != nil {
|
isSend, err := db.DB.HandleSignalInfo(pushMsg.OperationID, pushMsg.MsgData, pushMsg.PushToUserID)
|
||||||
|
if err != nil {
|
||||||
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), err.Error(), pushMsg.MsgData)
|
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), err.Error(), pushMsg.MsgData)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
if !isSend {
|
||||||
customContent := OpenIMContent{
|
return
|
||||||
SessionType: int(pushMsg.MsgData.SessionType),
|
|
||||||
From: pushMsg.MsgData.SendID,
|
|
||||||
To: pushMsg.MsgData.RecvID,
|
|
||||||
Seq: pushMsg.MsgData.Seq,
|
|
||||||
}
|
|
||||||
bCustomContent, _ := json.Marshal(customContent)
|
|
||||||
jsonCustomContent := string(bCustomContent)
|
|
||||||
var content string
|
|
||||||
if pushMsg.MsgData.OfflinePushInfo != nil {
|
|
||||||
content = pushMsg.MsgData.OfflinePushInfo.Title
|
|
||||||
jsonCustomContent = pushMsg.MsgData.OfflinePushInfo.Desc
|
|
||||||
}
|
|
||||||
if content == "" {
|
|
||||||
switch pushMsg.MsgData.ContentType {
|
|
||||||
case constant.Text:
|
|
||||||
content = constant.ContentType2PushContent[constant.Text]
|
|
||||||
case constant.Picture:
|
|
||||||
content = constant.ContentType2PushContent[constant.Picture]
|
|
||||||
case constant.Voice:
|
|
||||||
content = constant.ContentType2PushContent[constant.Voice]
|
|
||||||
case constant.Video:
|
|
||||||
content = constant.ContentType2PushContent[constant.Video]
|
|
||||||
case constant.File:
|
|
||||||
content = constant.ContentType2PushContent[constant.File]
|
|
||||||
case constant.AtText:
|
|
||||||
a := AtContent{}
|
|
||||||
_ = utils.JsonStringToStruct(string(pushMsg.MsgData.Content), &a)
|
|
||||||
if utils.IsContain(pushMsg.PushToUserID, a.AtUserList) {
|
|
||||||
content = constant.ContentType2PushContent[constant.AtText] + constant.ContentType2PushContent[constant.Common]
|
|
||||||
} else {
|
|
||||||
content = constant.ContentType2PushContent[constant.GroupMsg]
|
|
||||||
}
|
|
||||||
case constant.SignalingNotification:
|
|
||||||
content = constant.ContentType2PushContent[constant.SignalMsg]
|
|
||||||
default:
|
|
||||||
content = constant.ContentType2PushContent[constant.Common]
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var offlineInfo commonPb.OfflinePushInfo
|
var title, detailContent string
|
||||||
callbackResp := callbackOfflinePush(pushMsg.OperationID, UIDList, pushMsg.MsgData, &[]string{}, &offlineInfo)
|
callbackResp := callbackOfflinePush(pushMsg.OperationID, UIDList, pushMsg.MsgData, &[]string{})
|
||||||
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp")
|
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp")
|
||||||
if callbackResp.ErrCode != 0 {
|
if callbackResp.ErrCode != 0 {
|
||||||
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp)
|
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp)
|
||||||
@ -135,12 +97,11 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offlinePush stop")
|
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offlinePush stop")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if offlineInfo.Title != "" {
|
if pushMsg.MsgData.OfflinePushInfo != nil {
|
||||||
content = offlineInfo.Title
|
title = pushMsg.MsgData.OfflinePushInfo.Title
|
||||||
}
|
detailContent = pushMsg.MsgData.OfflinePushInfo.Desc
|
||||||
if offlineInfo.Desc != "" {
|
|
||||||
jsonCustomContent = offlineInfo.Desc
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if offlinePusher == nil {
|
if offlinePusher == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -148,8 +109,36 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "GetOfflinePushOpts failed", pushMsg, err.Error())
|
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "GetOfflinePushOpts failed", pushMsg, err.Error())
|
||||||
}
|
}
|
||||||
log.NewInfo(pushMsg.OperationID, utils.GetSelfFuncName(), UIDList, content, jsonCustomContent, "opts:", opts)
|
log.NewInfo(pushMsg.OperationID, utils.GetSelfFuncName(), UIDList, title, detailContent, "opts:", opts)
|
||||||
pushResult, err := offlinePusher.Push(UIDList, content, jsonCustomContent, pushMsg.OperationID, opts)
|
if title == "" {
|
||||||
|
switch pushMsg.MsgData.ContentType {
|
||||||
|
case constant.Text:
|
||||||
|
fallthrough
|
||||||
|
case constant.Picture:
|
||||||
|
fallthrough
|
||||||
|
case constant.Voice:
|
||||||
|
fallthrough
|
||||||
|
case constant.Video:
|
||||||
|
fallthrough
|
||||||
|
case constant.File:
|
||||||
|
title = constant.ContentType2PushContent[int64(pushMsg.MsgData.ContentType)]
|
||||||
|
case constant.AtText:
|
||||||
|
a := AtContent{}
|
||||||
|
_ = utils.JsonStringToStruct(string(pushMsg.MsgData.Content), &a)
|
||||||
|
if utils.IsContain(pushMsg.PushToUserID, a.AtUserList) {
|
||||||
|
title = constant.ContentType2PushContent[constant.AtText] + constant.ContentType2PushContent[constant.Common]
|
||||||
|
} else {
|
||||||
|
title = constant.ContentType2PushContent[constant.GroupMsg]
|
||||||
|
}
|
||||||
|
case constant.SignalingNotification:
|
||||||
|
title = constant.ContentType2PushContent[constant.SignalMsg]
|
||||||
|
default:
|
||||||
|
title = constant.ContentType2PushContent[constant.Common]
|
||||||
|
|
||||||
|
}
|
||||||
|
detailContent = title
|
||||||
|
}
|
||||||
|
pushResult, err := offlinePusher.Push(UIDList, title, detailContent, pushMsg.OperationID, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error())
|
log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error())
|
||||||
} else {
|
} else {
|
||||||
@ -176,24 +165,12 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "callback userIDList Resp", pushToUserIDList)
|
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "callback userIDList Resp", pushToUserIDList)
|
||||||
}
|
}
|
||||||
if len(pushToUserIDList) == 0 {
|
if len(pushToUserIDList) == 0 {
|
||||||
getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: pushMsg.OperationID, GroupID: pushMsg.MsgData.GroupID}
|
userIDList, err := utils2.GetGroupMemberUserIDList(pushMsg.MsgData.GroupID, pushMsg.OperationID)
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, pushMsg.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := pushMsg.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(pushMsg.OperationID, errMsg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
client := pbCache.NewCacheClient(etcdConn)
|
|
||||||
cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(pushMsg.OperationID, "GetGroupMemberIDListFromCache rpc call failed ", err.Error())
|
log.Error(pushMsg.OperationID, "GetGroupMemberUserIDList failed ", err.Error(), pushMsg.MsgData.GroupID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if cacheResp.CommonResp.ErrCode != 0 {
|
pushToUserIDList = userIDList
|
||||||
log.NewError(pushMsg.OperationID, "GetGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
pushToUserIDList = cacheResp.UserIDList
|
|
||||||
}
|
}
|
||||||
|
|
||||||
grpcCons := getcdv3.GetDefaultGatewayConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), pushMsg.OperationID)
|
grpcCons := getcdv3.GetDefaultGatewayConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), pushMsg.OperationID)
|
||||||
@ -223,51 +200,11 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
}
|
}
|
||||||
onlineFailedUserIDList := utils.DifferenceString(onlineSuccessUserIDList, pushToUserIDList)
|
onlineFailedUserIDList := utils.DifferenceString(onlineSuccessUserIDList, pushToUserIDList)
|
||||||
//Use offline push messaging
|
//Use offline push messaging
|
||||||
customContent := OpenIMContent{
|
var title, detailContent string
|
||||||
SessionType: int(pushMsg.MsgData.SessionType),
|
|
||||||
From: pushMsg.MsgData.SendID,
|
|
||||||
To: pushMsg.MsgData.RecvID,
|
|
||||||
Seq: pushMsg.MsgData.Seq,
|
|
||||||
}
|
|
||||||
bCustomContent, _ := json.Marshal(customContent)
|
|
||||||
jsonCustomContent := string(bCustomContent)
|
|
||||||
var content string
|
|
||||||
if pushMsg.MsgData.OfflinePushInfo != nil {
|
|
||||||
content = pushMsg.MsgData.OfflinePushInfo.Title
|
|
||||||
jsonCustomContent = pushMsg.MsgData.OfflinePushInfo.Desc
|
|
||||||
|
|
||||||
} else {
|
|
||||||
switch pushMsg.MsgData.ContentType {
|
|
||||||
case constant.Text:
|
|
||||||
content = constant.ContentType2PushContent[constant.Text]
|
|
||||||
case constant.Picture:
|
|
||||||
content = constant.ContentType2PushContent[constant.Picture]
|
|
||||||
case constant.Voice:
|
|
||||||
content = constant.ContentType2PushContent[constant.Voice]
|
|
||||||
case constant.Video:
|
|
||||||
content = constant.ContentType2PushContent[constant.Video]
|
|
||||||
case constant.File:
|
|
||||||
content = constant.ContentType2PushContent[constant.File]
|
|
||||||
case constant.AtText:
|
|
||||||
a := AtContent{}
|
|
||||||
_ = utils.JsonStringToStruct(string(pushMsg.MsgData.Content), &a)
|
|
||||||
if utils.IsContain(pushMsg.PushToUserID, a.AtUserList) {
|
|
||||||
content = constant.ContentType2PushContent[constant.AtText] + constant.ContentType2PushContent[constant.Common]
|
|
||||||
} else {
|
|
||||||
content = constant.ContentType2PushContent[constant.GroupMsg]
|
|
||||||
}
|
|
||||||
case constant.SignalingNotification:
|
|
||||||
content = constant.ContentType2PushContent[constant.SignalMsg]
|
|
||||||
default:
|
|
||||||
content = constant.ContentType2PushContent[constant.Common]
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(onlineFailedUserIDList) > 0 {
|
if len(onlineFailedUserIDList) > 0 {
|
||||||
var offlinePushUserIDList []string
|
var offlinePushUserIDList []string
|
||||||
var needOfflinePushUserIDList []string
|
var needOfflinePushUserIDList []string
|
||||||
var offlineInfo commonPb.OfflinePushInfo
|
callbackResp := callbackOfflinePush(pushMsg.OperationID, onlineFailedUserIDList, pushMsg.MsgData, &offlinePushUserIDList)
|
||||||
callbackResp := callbackOfflinePush(pushMsg.OperationID, onlineFailedUserIDList, pushMsg.MsgData, &offlinePushUserIDList, &offlineInfo)
|
|
||||||
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp")
|
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp")
|
||||||
if callbackResp.ErrCode != 0 {
|
if callbackResp.ErrCode != 0 {
|
||||||
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp)
|
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp)
|
||||||
@ -276,17 +213,16 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offlinePush stop")
|
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offlinePush stop")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if pushMsg.MsgData.OfflinePushInfo != nil {
|
||||||
|
title = pushMsg.MsgData.OfflinePushInfo.Title
|
||||||
|
detailContent = pushMsg.MsgData.OfflinePushInfo.Desc
|
||||||
|
}
|
||||||
if len(offlinePushUserIDList) > 0 {
|
if len(offlinePushUserIDList) > 0 {
|
||||||
needOfflinePushUserIDList = offlinePushUserIDList
|
needOfflinePushUserIDList = offlinePushUserIDList
|
||||||
} else {
|
} else {
|
||||||
needOfflinePushUserIDList = onlineFailedUserIDList
|
needOfflinePushUserIDList = onlineFailedUserIDList
|
||||||
}
|
}
|
||||||
if offlineInfo.Title != "" {
|
|
||||||
content = offlineInfo.Title
|
|
||||||
}
|
|
||||||
if offlineInfo.Desc != "" {
|
|
||||||
jsonCustomContent = offlineInfo.Desc
|
|
||||||
}
|
|
||||||
if offlinePusher == nil {
|
if offlinePusher == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -294,8 +230,36 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "GetOfflinePushOpts failed", pushMsg, err.Error())
|
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "GetOfflinePushOpts failed", pushMsg, err.Error())
|
||||||
}
|
}
|
||||||
log.NewInfo(pushMsg.OperationID, utils.GetSelfFuncName(), onlineFailedUserIDList, content, jsonCustomContent, "opts:", opts)
|
log.NewInfo(pushMsg.OperationID, utils.GetSelfFuncName(), onlineFailedUserIDList, title, detailContent, "opts:", opts)
|
||||||
pushResult, err := offlinePusher.Push(needOfflinePushUserIDList, content, jsonCustomContent, pushMsg.OperationID, opts)
|
if title == "" {
|
||||||
|
switch pushMsg.MsgData.ContentType {
|
||||||
|
case constant.Text:
|
||||||
|
fallthrough
|
||||||
|
case constant.Picture:
|
||||||
|
fallthrough
|
||||||
|
case constant.Voice:
|
||||||
|
fallthrough
|
||||||
|
case constant.Video:
|
||||||
|
fallthrough
|
||||||
|
case constant.File:
|
||||||
|
title = constant.ContentType2PushContent[int64(pushMsg.MsgData.ContentType)]
|
||||||
|
case constant.AtText:
|
||||||
|
a := AtContent{}
|
||||||
|
_ = utils.JsonStringToStruct(string(pushMsg.MsgData.Content), &a)
|
||||||
|
if utils.IsContain(pushMsg.PushToUserID, a.AtUserList) {
|
||||||
|
title = constant.ContentType2PushContent[constant.AtText] + constant.ContentType2PushContent[constant.Common]
|
||||||
|
} else {
|
||||||
|
title = constant.ContentType2PushContent[constant.GroupMsg]
|
||||||
|
}
|
||||||
|
case constant.SignalingNotification:
|
||||||
|
title = constant.ContentType2PushContent[constant.SignalMsg]
|
||||||
|
default:
|
||||||
|
title = constant.ContentType2PushContent[constant.Common]
|
||||||
|
|
||||||
|
}
|
||||||
|
detailContent = title
|
||||||
|
}
|
||||||
|
pushResult, err := offlinePusher.Push(needOfflinePushUserIDList, title, detailContent, pushMsg.OperationID, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error())
|
log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error())
|
||||||
} else {
|
} else {
|
||||||
@ -318,8 +282,13 @@ func GetOfflinePushOpts(pushMsg *pbPush.PushMsgReq) (opts push.PushOpts, err err
|
|||||||
opts.Signal.ClientMsgID = pushMsg.MsgData.ClientMsgID
|
opts.Signal.ClientMsgID = pushMsg.MsgData.ClientMsgID
|
||||||
log.NewDebug(pushMsg.OperationID, opts)
|
log.NewDebug(pushMsg.OperationID, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if pushMsg.MsgData.OfflinePushInfo != nil {
|
||||||
|
opts.IOSBadgeCount = pushMsg.MsgData.OfflinePushInfo.IOSBadgeCount
|
||||||
|
opts.IOSPushSound = pushMsg.MsgData.OfflinePushInfo.IOSPushSound
|
||||||
|
opts.Data = pushMsg.MsgData.OfflinePushInfo.Ex
|
||||||
|
}
|
||||||
|
|
||||||
return opts, nil
|
return opts, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package push
|
package push
|
||||||
|
|
||||||
|
import "Open_IM/pkg/common/constant"
|
||||||
|
|
||||||
|
var PushTerminal = []int{constant.IOSPlatformID, constant.AndroidPlatformID}
|
||||||
|
|
||||||
type OfflinePusher interface {
|
type OfflinePusher interface {
|
||||||
Push(userIDList []string, alert, detailContent, operationID string, opts PushOpts) (resp string, err error)
|
Push(userIDList []string, title, detailContent, operationID string, opts PushOpts) (resp string, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type PushOpts struct {
|
type PushOpts struct {
|
||||||
Signal Signal
|
Signal Signal
|
||||||
|
IOSPushSound string
|
||||||
|
IOSBadgeCount bool
|
||||||
|
Data string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Signal struct {
|
type Signal struct {
|
||||||
|
@ -3,8 +3,8 @@ package admin_cms
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
|
"Open_IM/pkg/common/db"
|
||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
openIMHttp "Open_IM/pkg/common/http"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
@ -12,11 +12,15 @@ import (
|
|||||||
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type adminCMSServer struct {
|
type adminCMSServer struct {
|
||||||
@ -65,11 +69,11 @@ func (s *adminCMSServer) Run() {
|
|||||||
log.Error("", "GetLocalIP failed ", err.Error())
|
log.Error("", "GetLocalIP failed ", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.NewInfo("", "rpcRegisterIP", rpcRegisterIP)
|
log.NewInfo("", "rpcRegisterIP ", rpcRegisterIP)
|
||||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("0", "RegisterEtcd failed ", err.Error())
|
log.NewError("0", "RegisterEtcd failed ", err.Error())
|
||||||
return
|
panic(utils.Wrap(err, "register admin module rpc to etcd err"))
|
||||||
}
|
}
|
||||||
err = srv.Serve(listener)
|
err = srv.Serve(listener)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -81,34 +85,48 @@ func (s *adminCMSServer) Run() {
|
|||||||
|
|
||||||
func (s *adminCMSServer) AdminLogin(_ context.Context, req *pbAdminCMS.AdminLoginReq) (*pbAdminCMS.AdminLoginResp, error) {
|
func (s *adminCMSServer) AdminLogin(_ context.Context, req *pbAdminCMS.AdminLoginReq) (*pbAdminCMS.AdminLoginResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbAdminCMS.AdminLoginResp{}
|
resp := &pbAdminCMS.AdminLoginResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||||
for i, adminID := range config.Config.Manager.AppManagerUid {
|
for i, adminID := range config.Config.Manager.AppManagerUid {
|
||||||
if adminID == req.AdminID && config.Config.Manager.Secrets[i] == req.Secret {
|
if adminID == req.AdminID && config.Config.Manager.Secrets[i] == req.Secret {
|
||||||
token, expTime, err := token_verify.CreateToken(adminID, constant.SingleChatType)
|
token, expTime, err := token_verify.CreateToken(adminID, constant.SingleChatType)
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "generate token success", "token: ", token, "expTime:", expTime)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "generate token failed", "adminID: ", adminID, err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "generate token failed", "adminID: ", adminID, err.Error())
|
||||||
return resp, openIMHttp.WrapError(constant.ErrTokenUnknown)
|
resp.CommonResp.ErrCode = constant.ErrTokenUnknown.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "generate token success", "token: ", token, "expTime:", expTime)
|
||||||
resp.Token = token
|
resp.Token = token
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.Token == "" {
|
if resp.Token == "" {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "failed")
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "failed")
|
||||||
return resp, openIMHttp.WrapError(constant.ErrTokenMalformed)
|
resp.CommonResp.ErrCode = constant.ErrTokenUnknown.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = constant.ErrTokenMalformed.ErrMsg
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
admin, err := imdb.GetUserByUserID(req.AdminID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "failed", req.AdminID)
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrTokenUnknown.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = constant.ErrTokenMalformed.ErrMsg
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
resp.UserName = admin.Nickname
|
||||||
|
resp.FaceURL = admin.FaceURL
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *adminCMSServer) AddUserRegisterAddFriendIDList(_ context.Context, req *pbAdminCMS.AddUserRegisterAddFriendIDListReq) (*pbAdminCMS.AddUserRegisterAddFriendIDListResp, error) {
|
func (s *adminCMSServer) AddUserRegisterAddFriendIDList(_ context.Context, req *pbAdminCMS.AddUserRegisterAddFriendIDListReq) (*pbAdminCMS.AddUserRegisterAddFriendIDListResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbAdminCMS.AddUserRegisterAddFriendIDListResp{}
|
resp := &pbAdminCMS.AddUserRegisterAddFriendIDListResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||||
if err := imdb.AddUserRegisterAddFriendIDList(req.UserIDList...); err != nil {
|
if err := imdb.AddUserRegisterAddFriendIDList(req.UserIDList...); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserIDList)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserIDList)
|
||||||
return resp, openIMHttp.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
@ -116,16 +134,20 @@ func (s *adminCMSServer) AddUserRegisterAddFriendIDList(_ context.Context, req *
|
|||||||
|
|
||||||
func (s *adminCMSServer) ReduceUserRegisterAddFriendIDList(_ context.Context, req *pbAdminCMS.ReduceUserRegisterAddFriendIDListReq) (*pbAdminCMS.ReduceUserRegisterAddFriendIDListResp, error) {
|
func (s *adminCMSServer) ReduceUserRegisterAddFriendIDList(_ context.Context, req *pbAdminCMS.ReduceUserRegisterAddFriendIDListReq) (*pbAdminCMS.ReduceUserRegisterAddFriendIDListResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbAdminCMS.ReduceUserRegisterAddFriendIDListResp{}
|
resp := &pbAdminCMS.ReduceUserRegisterAddFriendIDListResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||||
if req.Operation == 0 {
|
if req.Operation == 0 {
|
||||||
if err := imdb.ReduceUserRegisterAddFriendIDList(req.UserIDList...); err != nil {
|
if err := imdb.ReduceUserRegisterAddFriendIDList(req.UserIDList...); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserIDList)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserIDList)
|
||||||
return resp, openIMHttp.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := imdb.DeleteAllRegisterAddFriendIDList(); err != nil {
|
if err := imdb.DeleteAllRegisterAddFriendIDList(); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserIDList)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserIDList)
|
||||||
return resp, openIMHttp.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
||||||
@ -134,16 +156,19 @@ func (s *adminCMSServer) ReduceUserRegisterAddFriendIDList(_ context.Context, re
|
|||||||
|
|
||||||
func (s *adminCMSServer) GetUserRegisterAddFriendIDList(_ context.Context, req *pbAdminCMS.GetUserRegisterAddFriendIDListReq) (*pbAdminCMS.GetUserRegisterAddFriendIDListResp, error) {
|
func (s *adminCMSServer) GetUserRegisterAddFriendIDList(_ context.Context, req *pbAdminCMS.GetUserRegisterAddFriendIDListReq) (*pbAdminCMS.GetUserRegisterAddFriendIDListResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbAdminCMS.GetUserRegisterAddFriendIDListResp{UserInfoList: []*server_api_params.UserInfo{}}
|
resp := &pbAdminCMS.GetUserRegisterAddFriendIDListResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||||
userIDList, err := imdb.GetRegisterAddFriendList(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
userIDList, err := imdb.GetRegisterAddFriendList(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
return resp, openIMHttp.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
userList, err := imdb.GetUsersByUserIDList(userIDList)
|
userList, err := imdb.GetUsersByUserIDList(userIDList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), userIDList)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
return resp, openIMHttp.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), userList, userIDList)
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), userList, userIDList)
|
||||||
resp.Pagination = &server_api_params.ResponsePagination{
|
resp.Pagination = &server_api_params.ResponsePagination{
|
||||||
@ -154,3 +179,500 @@ func (s *adminCMSServer) GetUserRegisterAddFriendIDList(_ context.Context, req *
|
|||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) GetChatLogs(_ context.Context, req *pbAdminCMS.GetChatLogsReq) (*pbAdminCMS.GetChatLogsResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetChatLogs", req.String())
|
||||||
|
resp := &pbAdminCMS.GetChatLogsResp{CommonResp: &pbAdminCMS.CommonResp{}, Pagination: &server_api_params.ResponsePagination{}}
|
||||||
|
time, err := utils.TimeStringToTime(req.SendTime)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "time string parse error", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrArgs.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
chatLog := db.ChatLog{
|
||||||
|
Content: req.Content,
|
||||||
|
SendTime: time,
|
||||||
|
ContentType: req.ContentType,
|
||||||
|
SessionType: req.SessionType,
|
||||||
|
RecvID: req.RecvID,
|
||||||
|
SendID: req.SendID,
|
||||||
|
}
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "chat_log: ", chatLog)
|
||||||
|
nums, err := imdb.GetChatLogCount(chatLog)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetChatLogCount", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
resp.ChatLogsNum = int32(nums)
|
||||||
|
chatLogs, err := imdb.GetChatLog(chatLog, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetChatLog", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
for _, chatLog := range chatLogs {
|
||||||
|
pbChatLog := &pbAdminCMS.ChatLog{}
|
||||||
|
utils.CopyStructFields(pbChatLog, chatLog)
|
||||||
|
pbChatLog.SendTime = chatLog.SendTime.Unix()
|
||||||
|
pbChatLog.CreateTime = chatLog.CreateTime.Unix()
|
||||||
|
if chatLog.SenderNickname == "" {
|
||||||
|
sendUser, err := imdb.GetUserByUserID(chatLog.SendID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserByUserID failed", err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
pbChatLog.SenderNickname = sendUser.Nickname
|
||||||
|
}
|
||||||
|
switch chatLog.SessionType {
|
||||||
|
case constant.SingleChatType:
|
||||||
|
recvUser, err := imdb.GetUserByUserID(chatLog.RecvID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserByUserID failed", err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
pbChatLog.SenderNickname = recvUser.Nickname
|
||||||
|
|
||||||
|
case constant.GroupChatType, constant.SuperGroupChatType:
|
||||||
|
group, err := imdb.GetGroupInfoByGroupID(chatLog.RecvID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupById failed")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
pbChatLog.RecvID = group.GroupID
|
||||||
|
pbChatLog.GroupName = group.GroupName
|
||||||
|
}
|
||||||
|
resp.ChatLogs = append(resp.ChatLogs, pbChatLog)
|
||||||
|
}
|
||||||
|
resp.Pagination = &server_api_params.ResponsePagination{
|
||||||
|
CurrentPage: req.Pagination.PageNumber,
|
||||||
|
ShowNumber: req.Pagination.ShowNumber,
|
||||||
|
}
|
||||||
|
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp output: ", resp.String())
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) GetActiveGroup(_ context.Context, req *pbAdminCMS.GetActiveGroupReq) (*pbAdminCMS.GetActiveGroupResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req", req.String())
|
||||||
|
resp := &pbAdminCMS.GetActiveGroupResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||||
|
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
|
||||||
|
activeGroups, err := imdb.GetActiveGroups(fromTime, toTime, 12)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveGroups failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
for _, activeGroup := range activeGroups {
|
||||||
|
resp.Groups = append(resp.Groups,
|
||||||
|
&pbAdminCMS.GroupResp{
|
||||||
|
GroupName: activeGroup.Name,
|
||||||
|
GroupId: activeGroup.Id,
|
||||||
|
MessageNum: int32(activeGroup.MessageNum),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) GetActiveUser(_ context.Context, req *pbAdminCMS.GetActiveUserReq) (*pbAdminCMS.GetActiveUserResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||||
|
resp := &pbAdminCMS.GetActiveUserResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||||
|
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
|
||||||
|
activeUsers, err := imdb.GetActiveUsers(fromTime, toTime, 12)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveUsers failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
for _, activeUser := range activeUsers {
|
||||||
|
resp.Users = append(resp.Users,
|
||||||
|
&pbAdminCMS.UserResp{
|
||||||
|
UserID: activeUser.ID,
|
||||||
|
NickName: activeUser.Name,
|
||||||
|
MessageNum: int32(activeUser.MessageNum),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func ParseTimeFromTo(from, to string) (time.Time, time.Time, error) {
|
||||||
|
var fromTime time.Time
|
||||||
|
var toTime time.Time
|
||||||
|
fromTime, err := utils.TimeStringToTime(from)
|
||||||
|
if err != nil {
|
||||||
|
return fromTime, toTime, err
|
||||||
|
}
|
||||||
|
toTime, err = utils.TimeStringToTime(to)
|
||||||
|
if err != nil {
|
||||||
|
return fromTime, toTime, err
|
||||||
|
}
|
||||||
|
return fromTime, toTime, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func isInOneMonth(from, to time.Time) bool {
|
||||||
|
return from.Month() == to.Month() && from.Year() == to.Year()
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetRangeDate(from, to time.Time) [][2]time.Time {
|
||||||
|
interval := to.Sub(from)
|
||||||
|
var times [][2]time.Time
|
||||||
|
switch {
|
||||||
|
// today
|
||||||
|
case interval == 0:
|
||||||
|
times = append(times, [2]time.Time{
|
||||||
|
from, from.Add(time.Hour * 24),
|
||||||
|
})
|
||||||
|
// days
|
||||||
|
case isInOneMonth(from, to):
|
||||||
|
for i := 0; ; i++ {
|
||||||
|
fromTime := from.Add(time.Hour * 24 * time.Duration(i))
|
||||||
|
toTime := from.Add(time.Hour * 24 * time.Duration(i+1))
|
||||||
|
if toTime.After(to.Add(time.Hour * 24)) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
times = append(times, [2]time.Time{
|
||||||
|
fromTime, toTime,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// month
|
||||||
|
case !isInOneMonth(from, to):
|
||||||
|
if to.Sub(from) < time.Hour*24*30 {
|
||||||
|
for i := 0; ; i++ {
|
||||||
|
fromTime := from.Add(time.Hour * 24 * time.Duration(i))
|
||||||
|
toTime := from.Add(time.Hour * 24 * time.Duration(i+1))
|
||||||
|
if toTime.After(to.Add(time.Hour * 24)) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
times = append(times, [2]time.Time{
|
||||||
|
fromTime, toTime,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for i := 0; ; i++ {
|
||||||
|
if i == 0 {
|
||||||
|
fromTime := from
|
||||||
|
toTime := getFirstDateOfNextNMonth(fromTime, 1)
|
||||||
|
times = append(times, [2]time.Time{
|
||||||
|
fromTime, toTime,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
fromTime := getFirstDateOfNextNMonth(from, i)
|
||||||
|
toTime := getFirstDateOfNextNMonth(fromTime, 1)
|
||||||
|
if toTime.After(to) {
|
||||||
|
toTime = to
|
||||||
|
times = append(times, [2]time.Time{
|
||||||
|
fromTime, toTime,
|
||||||
|
})
|
||||||
|
break
|
||||||
|
}
|
||||||
|
times = append(times, [2]time.Time{
|
||||||
|
fromTime, toTime,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return times
|
||||||
|
}
|
||||||
|
|
||||||
|
func getFirstDateOfNextNMonth(currentTime time.Time, n int) time.Time {
|
||||||
|
lastOfMonth := time.Date(currentTime.Year(), currentTime.Month(), 1, 0, 0, 0, 0, currentTime.Location()).AddDate(0, n, 0)
|
||||||
|
return lastOfMonth
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) GetGroupStatistics(_ context.Context, req *pbAdminCMS.GetGroupStatisticsReq) (*pbAdminCMS.GetGroupStatisticsResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||||
|
resp := &pbAdminCMS.GetGroupStatisticsResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||||
|
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupStatistics failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
increaseGroupNum, err := imdb.GetIncreaseGroupNum(fromTime, toTime.Add(time.Hour*24))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum failed", err.Error(), fromTime, toTime)
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
totalGroupNum, err := imdb.GetTotalGroupNum()
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
resp.IncreaseGroupNum = increaseGroupNum
|
||||||
|
resp.TotalGroupNum = totalGroupNum
|
||||||
|
times := GetRangeDate(fromTime, toTime)
|
||||||
|
log.NewDebug(req.OperationID, "times:", times)
|
||||||
|
wg := &sync.WaitGroup{}
|
||||||
|
resp.IncreaseGroupNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
||||||
|
resp.TotalGroupNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
||||||
|
wg.Add(len(times))
|
||||||
|
for i, v := range times {
|
||||||
|
go func(wg *sync.WaitGroup, index int, v [2]time.Time) {
|
||||||
|
defer wg.Done()
|
||||||
|
num, err := imdb.GetIncreaseGroupNum(v[0], v[1])
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
||||||
|
}
|
||||||
|
resp.IncreaseGroupNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
|
Date: v[0].String(),
|
||||||
|
Num: num,
|
||||||
|
}
|
||||||
|
num, err = imdb.GetGroupNum(v[1])
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
||||||
|
}
|
||||||
|
resp.TotalGroupNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
|
Date: v[0].String(),
|
||||||
|
Num: num,
|
||||||
|
}
|
||||||
|
}(wg, i, v)
|
||||||
|
}
|
||||||
|
wg.Wait()
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) GetMessageStatistics(_ context.Context, req *pbAdminCMS.GetMessageStatisticsReq) (*pbAdminCMS.GetMessageStatisticsResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||||
|
resp := &pbAdminCMS.GetMessageStatisticsResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||||
|
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "times: ", fromTime, toTime)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
privateMessageNum, err := imdb.GetPrivateMessageNum(fromTime, toTime.Add(time.Hour*24))
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetPrivateMessageNum failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
groupMessageNum, err := imdb.GetGroupMessageNum(fromTime, toTime.Add(time.Hour*24))
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMessageNum failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), privateMessageNum, groupMessageNum)
|
||||||
|
resp.PrivateMessageNum = privateMessageNum
|
||||||
|
resp.GroupMessageNum = groupMessageNum
|
||||||
|
times := GetRangeDate(fromTime, toTime)
|
||||||
|
resp.GroupMessageNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
||||||
|
resp.PrivateMessageNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
||||||
|
wg := &sync.WaitGroup{}
|
||||||
|
wg.Add(len(times))
|
||||||
|
for i, v := range times {
|
||||||
|
go func(wg *sync.WaitGroup, index int, v [2]time.Time) {
|
||||||
|
defer wg.Done()
|
||||||
|
|
||||||
|
num, err := imdb.GetPrivateMessageNum(v[0], v[1])
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
||||||
|
}
|
||||||
|
resp.PrivateMessageNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
|
Date: v[0].String(),
|
||||||
|
Num: num,
|
||||||
|
}
|
||||||
|
num, err = imdb.GetGroupMessageNum(v[0], v[1])
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
||||||
|
}
|
||||||
|
resp.GroupMessageNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
|
Date: v[0].String(),
|
||||||
|
Num: num,
|
||||||
|
}
|
||||||
|
}(wg, i, v)
|
||||||
|
}
|
||||||
|
wg.Wait()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) GetUserStatistics(_ context.Context, req *pbAdminCMS.GetUserStatisticsReq) (*pbAdminCMS.GetUserStatisticsResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
|
resp := &pbAdminCMS.GetUserStatisticsResp{CommonResp: &pbAdminCMS.CommonResp{}}
|
||||||
|
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
activeUserNum, err := imdb.GetActiveUserNum(fromTime, toTime.Add(time.Hour*24))
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveUserNum failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
increaseUserNum, err := imdb.GetIncreaseUserNum(fromTime, toTime.Add(time.Hour*24))
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseUserNum failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
totalUserNum, err := imdb.GetTotalUserNum()
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetTotalUserNum failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
resp.ActiveUserNum = activeUserNum
|
||||||
|
resp.TotalUserNum = totalUserNum
|
||||||
|
resp.IncreaseUserNum = increaseUserNum
|
||||||
|
times := GetRangeDate(fromTime, toTime)
|
||||||
|
resp.TotalUserNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
||||||
|
resp.ActiveUserNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
||||||
|
resp.IncreaseUserNumList = make([]*pbAdminCMS.DateNumList, len(times), len(times))
|
||||||
|
wg := &sync.WaitGroup{}
|
||||||
|
wg.Add(len(times))
|
||||||
|
for i, v := range times {
|
||||||
|
go func(wg *sync.WaitGroup, index int, v [2]time.Time) {
|
||||||
|
defer wg.Done()
|
||||||
|
num, err := imdb.GetActiveUserNum(v[0], v[1])
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
||||||
|
}
|
||||||
|
resp.ActiveUserNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
|
Date: v[0].String(),
|
||||||
|
Num: num,
|
||||||
|
}
|
||||||
|
|
||||||
|
num, err = imdb.GetTotalUserNumByDate(v[1])
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetTotalUserNumByDate", v, err.Error())
|
||||||
|
}
|
||||||
|
resp.TotalUserNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
|
Date: v[0].String(),
|
||||||
|
Num: num,
|
||||||
|
}
|
||||||
|
num, err = imdb.GetIncreaseUserNum(v[0], v[1])
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseUserNum", v, err.Error())
|
||||||
|
}
|
||||||
|
resp.IncreaseUserNumList[index] = &pbAdminCMS.DateNumList{
|
||||||
|
Date: v[0].String(),
|
||||||
|
Num: num,
|
||||||
|
}
|
||||||
|
}(wg, i, v)
|
||||||
|
}
|
||||||
|
wg.Wait()
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) GetUserFriends(_ context.Context, req *pbAdminCMS.GetUserFriendsReq) (*pbAdminCMS.GetUserFriendsResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
|
resp := &pbAdminCMS.GetUserFriendsResp{CommonResp: &pbAdminCMS.CommonResp{}, Pagination: &server_api_params.ResponsePagination{CurrentPage: req.Pagination.PageNumber, ShowNumber: req.Pagination.ShowNumber}}
|
||||||
|
var friendList []*imdb.FriendUser
|
||||||
|
var err error
|
||||||
|
if req.FriendUserID != "" {
|
||||||
|
friend, err := imdb.GetFriendByIDCMS(req.UserID, req.FriendUserID)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err, req.UserID, req.FriendUserID)
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID, req.FriendUserID)
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
friendList = append(friendList, friend)
|
||||||
|
resp.FriendNums = 1
|
||||||
|
} else {
|
||||||
|
var count int64
|
||||||
|
friendList, count, err = imdb.GetUserFriendsCMS(req.UserID, req.FriendUserName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID, req.FriendUserName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
resp.FriendNums = int32(count)
|
||||||
|
}
|
||||||
|
for _, v := range friendList {
|
||||||
|
friendInfo := &server_api_params.FriendInfo{}
|
||||||
|
userInfo := &server_api_params.UserInfo{UserID: v.FriendUserID, Nickname: v.Nickname}
|
||||||
|
utils.CopyStructFields(friendInfo, v)
|
||||||
|
friendInfo.FriendUser = userInfo
|
||||||
|
resp.FriendInfoList = append(resp.FriendInfoList, friendInfo)
|
||||||
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) GenerateInvitationCode(_ context.Context, req *pbAdminCMS.GenerateInvitationCodeReq) (*pbAdminCMS.GenerateInvitationCodeResp, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) GetInvitationCodes(_ context.Context, req *pbAdminCMS.GetInvitationCodesReq) (*pbAdminCMS.GetInvitationCodesResp, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) QueryIPRegister(_ context.Context, req *pbAdminCMS.QueryIPRegisterReq) (*pbAdminCMS.QueryIPRegisterResp, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) AddIPLimit(_ context.Context, req *pbAdminCMS.AddIPLimitReq) (*pbAdminCMS.AddIPLimitResp, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) RemoveIPLimit(_ context.Context, req *pbAdminCMS.RemoveIPLimitReq) (*pbAdminCMS.RemoveIPLimitResp, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) QueryUserIDIPLimitLogin(_ context.Context, req *pbAdminCMS.QueryUserIDIPLimitLoginReq) (*pbAdminCMS.QueryUserIDIPLimitLoginResp, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) AddUserIPLimitLogin(_ context.Context, req *pbAdminCMS.AddUserIPLimitLoginReq) (*pbAdminCMS.AddUserIPLimitLoginResp, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) RemoveUserIPLimit(_ context.Context, req *pbAdminCMS.RemoveUserIPLimitReq) (*pbAdminCMS.RemoveUserIPLimitResp, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) GetClientInitConfig(_ context.Context, req *pbAdminCMS.GetClientInitConfigReq) (*pbAdminCMS.GetClientInitConfigResp, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *adminCMSServer) SetClientInitConfig(_ context.Context, req *pbAdminCMS.SetClientInitConfigReq) (*pbAdminCMS.SetClientInitConfigResp, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
@ -29,43 +29,24 @@ func (rpc *rpcAuth) UserRegister(_ context.Context, req *pbAuth.UserRegisterReq)
|
|||||||
user.Birth = utils.UnixSecondToTime(int64(req.UserInfo.Birth))
|
user.Birth = utils.UnixSecondToTime(int64(req.UserInfo.Birth))
|
||||||
}
|
}
|
||||||
log.Debug(req.OperationID, "copy ", user, req.UserInfo)
|
log.Debug(req.OperationID, "copy ", user, req.UserInfo)
|
||||||
Limited, LimitError := imdb.IsLimitRegisterIp(req.UserInfo.CreateIp)
|
|
||||||
if LimitError != nil {
|
|
||||||
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: LimitError.Error()}}, nil
|
|
||||||
}
|
|
||||||
if Limited {
|
|
||||||
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.RegisterLimit, ErrMsg: "Register Limit"}}, nil
|
|
||||||
}
|
|
||||||
err := imdb.UserRegister(user)
|
err := imdb.UserRegister(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == constant.InvitationMsg {
|
|
||||||
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.InvitationError, ErrMsg: "邀请码错误"}}, nil
|
|
||||||
}
|
|
||||||
errMsg := req.OperationID + " imdb.UserRegister failed " + err.Error() + user.UserID
|
errMsg := req.OperationID + " imdb.UserRegister failed " + err.Error() + user.UserID
|
||||||
log.NewError(req.OperationID, errMsg, user)
|
log.NewError(req.OperationID, errMsg, user)
|
||||||
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil
|
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{}})
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{}})
|
||||||
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{}}, nil
|
return &pbAuth.UserRegisterResp{CommonResp: &pbAuth.CommonResp{}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rpc *rpcAuth) UserToken(_ context.Context, req *pbAuth.UserTokenReq) (*pbAuth.UserTokenResp, error) {
|
func (rpc *rpcAuth) UserToken(_ context.Context, req *pbAuth.UserTokenReq) (*pbAuth.UserTokenResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc args ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc args ", req.String())
|
||||||
_, err := imdb.GetUserByUserID(req.FromUserID)
|
|
||||||
if err != nil {
|
|
||||||
errMsg := req.OperationID + " imdb.GetUserByUserID failed " + err.Error() + req.FromUserID
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
tokens, expTime, err := token_verify.CreateToken(req.FromUserID, int(req.Platform))
|
tokens, expTime, err := token_verify.CreateToken(req.FromUserID, int(req.Platform))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := req.OperationID + " token_verify.CreateToken failed " + err.Error() + req.FromUserID + utils.Int32ToString(req.Platform)
|
errMsg := req.OperationID + " token_verify.CreateToken failed " + err.Error() + req.FromUserID + utils.Int32ToString(req.Platform)
|
||||||
log.NewError(req.OperationID, errMsg)
|
log.NewError(req.OperationID, errMsg)
|
||||||
return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil
|
return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{}, Token: tokens, ExpiredTime: expTime})
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{}, Token: tokens, ExpiredTime: expTime})
|
||||||
return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{}, Token: tokens, ExpiredTime: expTime}, nil
|
return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{}, Token: tokens, ExpiredTime: expTime}, nil
|
||||||
}
|
}
|
||||||
@ -156,7 +137,8 @@ func (rpc *rpcAuth) Run() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(operationID, "RegisterEtcd failed ", err.Error(),
|
log.NewError(operationID, "RegisterEtcd failed ", err.Error(),
|
||||||
rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName)
|
rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName)
|
||||||
return
|
panic(utils.Wrap(err, "register auth module rpc to etcd err"))
|
||||||
|
|
||||||
}
|
}
|
||||||
log.NewInfo(operationID, "RegisterAuthServer ok ", rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName)
|
log.NewInfo(operationID, "RegisterAuthServer ok ", rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName)
|
||||||
err = srv.Serve(listener)
|
err = srv.Serve(listener)
|
||||||
|
8
internal/rpc/cache/cache.go
vendored
8
internal/rpc/cache/cache.go
vendored
@ -3,16 +3,17 @@ package cache
|
|||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db/rocks_cache"
|
rocksCache "Open_IM/pkg/common/db/rocks_cache"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbCache "Open_IM/pkg/proto/cache"
|
pbCache "Open_IM/pkg/proto/cache"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"google.golang.org/grpc"
|
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
type cacheServer struct {
|
type cacheServer struct {
|
||||||
@ -65,8 +66,9 @@ func (s *cacheServer) Run() {
|
|||||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("0", "RegisterEtcd failed ", err.Error())
|
log.NewError("0", "RegisterEtcd failed ", err.Error())
|
||||||
return
|
panic(utils.Wrap(err, "register cache module rpc to etcd err"))
|
||||||
}
|
}
|
||||||
|
go rocksCache.DelKeys()
|
||||||
err = srv.Serve(listener)
|
err = srv.Serve(listener)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("0", "Serve failed ", err.Error())
|
log.NewError("0", "Serve failed ", err.Error())
|
||||||
|
@ -74,7 +74,7 @@ func (rpc *rpcConversation) ModifyConversationField(c context.Context, req *pbCo
|
|||||||
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"attached_info": conversation.AttachedInfo})
|
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"attached_info": conversation.AttachedInfo})
|
||||||
case constant.FieldUnread:
|
case constant.FieldUnread:
|
||||||
isSyncConversation = false
|
isSyncConversation = false
|
||||||
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"update_unread_count_time": utils.GetCurrentTimestampByMill()})
|
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"update_unread_count_time": conversation.UpdateUnreadCountTime})
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateColumnsConversations error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateColumnsConversations error", err.Error())
|
||||||
@ -83,7 +83,6 @@ func (rpc *rpcConversation) ModifyConversationField(c context.Context, req *pbCo
|
|||||||
}
|
}
|
||||||
for _, v := range utils.DifferenceString(haveUserID, req.UserIDList) {
|
for _, v := range utils.DifferenceString(haveUserID, req.UserIDList) {
|
||||||
conversation.OwnerUserID = v
|
conversation.OwnerUserID = v
|
||||||
conversation.UpdateUnreadCountTime = utils.GetCurrentTimestampByMill()
|
|
||||||
err = rocksCache.DelUserConversationIDListFromCache(v)
|
err = rocksCache.DelUserConversationIDListFromCache(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), v, req.Conversation.ConversationID, err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), v, req.Conversation.ConversationID, err.Error())
|
||||||
@ -118,7 +117,7 @@ func (rpc *rpcConversation) ModifyConversationField(c context.Context, req *pbCo
|
|||||||
if err = rocksCache.DelConversationFromCache(v, req.Conversation.ConversationID); err != nil {
|
if err = rocksCache.DelConversationFromCache(v, req.Conversation.ConversationID); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), v, req.Conversation.ConversationID, err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), v, req.Conversation.ConversationID, err.Error())
|
||||||
}
|
}
|
||||||
chat.ConversationUnreadChangeNotification(req.OperationID, v, req.Conversation.ConversationID)
|
chat.ConversationUnreadChangeNotification(req.OperationID, v, req.Conversation.ConversationID, conversation.UpdateUnreadCountTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +197,7 @@ func (rpc *rpcConversation) Run() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("0", "RegisterEtcd failed ", err.Error(),
|
log.NewError("0", "RegisterEtcd failed ", err.Error(),
|
||||||
rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName)
|
rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName)
|
||||||
return
|
panic(utils.Wrap(err, "register conversation module rpc to etcd err"))
|
||||||
}
|
}
|
||||||
log.NewInfo("0", "RegisterConversationServer ok ", rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName)
|
log.NewInfo("0", "RegisterConversationServer ok ", rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName)
|
||||||
err = srv.Serve(listener)
|
err = srv.Serve(listener)
|
||||||
|
@ -75,7 +75,7 @@ func (s *friendServer) Run() {
|
|||||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("0", "RegisterEtcd failed ", err.Error(), s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName)
|
log.NewError("0", "RegisterEtcd failed ", err.Error(), s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName)
|
||||||
return
|
panic(utils.Wrap(err, "register friend module rpc to etcd err"))
|
||||||
}
|
}
|
||||||
err = srv.Serve(listener)
|
err = srv.Serve(listener)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -6,8 +6,7 @@ import (
|
|||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
"Open_IM/pkg/common/db/rocks_cache"
|
rocksCache "Open_IM/pkg/common/db/rocks_cache"
|
||||||
"Open_IM/pkg/common/http"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
cp "Open_IM/pkg/common/utils"
|
cp "Open_IM/pkg/common/utils"
|
||||||
@ -19,12 +18,15 @@ import (
|
|||||||
pbUser "Open_IM/pkg/proto/user"
|
pbUser "Open_IM/pkg/proto/user"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
"google.golang.org/grpc"
|
"errors"
|
||||||
"math/big"
|
"math/big"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type groupServer struct {
|
type groupServer struct {
|
||||||
@ -83,7 +85,8 @@ func (s *groupServer) Run() {
|
|||||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("", "RegisterEtcd failed ", err.Error())
|
log.NewError("", "RegisterEtcd failed ", err.Error())
|
||||||
return
|
panic(utils.Wrap(err, "register group module rpc to etcd err"))
|
||||||
|
|
||||||
}
|
}
|
||||||
log.Info("", "RegisterEtcd ", s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName)
|
log.Info("", "RegisterEtcd ", s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName)
|
||||||
err = srv.Serve(listener)
|
err = srv.Serve(listener)
|
||||||
@ -120,7 +123,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
|||||||
err := imdb.InsertIntoGroup(groupInfo)
|
err := imdb.InsertIntoGroup(groupInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "InsertIntoGroup failed, ", err.Error(), groupInfo)
|
log.NewError(req.OperationID, "InsertIntoGroup failed, ", err.Error(), groupInfo)
|
||||||
return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, http.WrapError(constant.ErrDB)
|
return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
var okUserIDList []string
|
var okUserIDList []string
|
||||||
resp := &pbGroup.CreateGroupResp{GroupInfo: &open_im_sdk.GroupInfo{}}
|
resp := &pbGroup.CreateGroupResp{GroupInfo: &open_im_sdk.GroupInfo{}}
|
||||||
@ -130,7 +133,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
|||||||
us, err = imdb.GetUserByUserID(req.OwnerUserID)
|
us, err = imdb.GetUserByUserID(req.OwnerUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), req.OwnerUserID)
|
log.NewError(req.OperationID, "GetUserByUserID failed ", err.Error(), req.OwnerUserID)
|
||||||
return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, http.WrapError(constant.ErrDB)
|
return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
//to group member
|
//to group member
|
||||||
groupMember = db.GroupMember{GroupID: groupId, RoleLevel: constant.GroupOwner, OperatorUserID: req.OpUserID, JoinSource: constant.JoinByInvitation, InviterUserID: req.OpUserID}
|
groupMember = db.GroupMember{GroupID: groupId, RoleLevel: constant.GroupOwner, OperatorUserID: req.OpUserID, JoinSource: constant.JoinByInvitation, InviterUserID: req.OpUserID}
|
||||||
@ -138,9 +141,10 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
|||||||
err = imdb.InsertIntoGroupMember(groupMember)
|
err = imdb.InsertIntoGroupMember(groupMember)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "InsertIntoGroupMember failed ", err.Error(), groupMember)
|
log.NewError(req.OperationID, "InsertIntoGroupMember failed ", err.Error(), groupMember)
|
||||||
return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, http.WrapError(constant.ErrDB)
|
return &pbGroup.CreateGroupResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.GroupInfo.GroupType != constant.SuperGroup {
|
if req.GroupInfo.GroupType != constant.SuperGroup {
|
||||||
//to group member
|
//to group member
|
||||||
for _, user := range req.InitMemberList {
|
for _, user := range req.InitMemberList {
|
||||||
@ -314,7 +318,7 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
|||||||
resp.Id2ResultList = append(resp.Id2ResultList, &resultNode)
|
resp.Id2ResultList = append(resp.Id2ResultList, &resultNode)
|
||||||
|
|
||||||
continue
|
continue
|
||||||
log.NewError(req.OperationID, "InsertIntoGroupRequest failed ", err.Error(), groupRequest)
|
// log.NewError(req.OperationID, "InsertIntoGroupRequest failed ", err.Error(), groupRequest)
|
||||||
// return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
// return &pbGroup.JoinGroupResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
} else {
|
} else {
|
||||||
var resultNode pbGroup.Id2Result
|
var resultNode pbGroup.Id2Result
|
||||||
@ -483,11 +487,9 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.Invite
|
|||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
go func() {
|
|
||||||
for _, v := range req.InvitedUserIDList {
|
for _, v := range req.InvitedUserIDList {
|
||||||
chat.SuperGroupNotification(req.OperationID, v, v)
|
chat.SuperGroupNotification(req.OperationID, v, v)
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "InviteUserToGroup rpc return ", resp)
|
log.NewInfo(req.OperationID, "InviteUserToGroup rpc return ", resp)
|
||||||
@ -827,7 +829,6 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsI
|
|||||||
|
|
||||||
func (s *groupServer) GroupApplicationResponse(_ context.Context, req *pbGroup.GroupApplicationResponseReq) (*pbGroup.GroupApplicationResponseResp, error) {
|
func (s *groupServer) GroupApplicationResponse(_ context.Context, req *pbGroup.GroupApplicationResponseReq) (*pbGroup.GroupApplicationResponseResp, error) {
|
||||||
log.NewInfo(req.OperationID, "GroupApplicationResponse args ", req.String())
|
log.NewInfo(req.OperationID, "GroupApplicationResponse args ", req.String())
|
||||||
|
|
||||||
groupRequest := db.GroupRequest{}
|
groupRequest := db.GroupRequest{}
|
||||||
utils.CopyStructFields(&groupRequest, req)
|
utils.CopyStructFields(&groupRequest, req)
|
||||||
groupRequest.UserID = req.FromUserID
|
groupRequest.UserID = req.FromUserID
|
||||||
@ -1162,7 +1163,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
group, err := imdb.GetGroupInfoByGroupID(req.GroupInfoForSet.GroupID)
|
group, err := imdb.GetGroupInfoByGroupID(req.GroupInfoForSet.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "GetGroupInfoByGroupID failed ", err.Error(), req.GroupInfoForSet.GroupID)
|
log.NewError(req.OperationID, "GetGroupInfoByGroupID failed ", err.Error(), req.GroupInfoForSet.GroupID)
|
||||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, http.WrapError(constant.ErrDB)
|
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if group.Status == constant.GroupStatusDismissed {
|
if group.Status == constant.GroupStatusDismissed {
|
||||||
@ -1199,7 +1200,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
m["need_verification"] = req.GroupInfoForSet.NeedVerification.Value
|
m["need_verification"] = req.GroupInfoForSet.NeedVerification.Value
|
||||||
if err := imdb.UpdateGroupInfoDefaultZero(req.GroupInfoForSet.GroupID, m); err != nil {
|
if err := imdb.UpdateGroupInfoDefaultZero(req.GroupInfoForSet.GroupID, m); err != nil {
|
||||||
log.NewError(req.OperationID, "UpdateGroupInfoDefaultZero failed ", err.Error(), m)
|
log.NewError(req.OperationID, "UpdateGroupInfoDefaultZero failed ", err.Error(), m)
|
||||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, http.WrapError(constant.ErrDB)
|
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if req.GroupInfoForSet.LookMemberInfo != nil {
|
if req.GroupInfoForSet.LookMemberInfo != nil {
|
||||||
@ -1208,7 +1209,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
m["look_member_info"] = req.GroupInfoForSet.LookMemberInfo.Value
|
m["look_member_info"] = req.GroupInfoForSet.LookMemberInfo.Value
|
||||||
if err := imdb.UpdateGroupInfoDefaultZero(req.GroupInfoForSet.GroupID, m); err != nil {
|
if err := imdb.UpdateGroupInfoDefaultZero(req.GroupInfoForSet.GroupID, m); err != nil {
|
||||||
log.NewError(req.OperationID, "UpdateGroupInfoDefaultZero failed ", err.Error(), m)
|
log.NewError(req.OperationID, "UpdateGroupInfoDefaultZero failed ", err.Error(), m)
|
||||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, http.WrapError(constant.ErrDB)
|
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if req.GroupInfoForSet.ApplyMemberFriend != nil {
|
if req.GroupInfoForSet.ApplyMemberFriend != nil {
|
||||||
@ -1217,7 +1218,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
m["apply_member_friend"] = req.GroupInfoForSet.ApplyMemberFriend.Value
|
m["apply_member_friend"] = req.GroupInfoForSet.ApplyMemberFriend.Value
|
||||||
if err := imdb.UpdateGroupInfoDefaultZero(req.GroupInfoForSet.GroupID, m); err != nil {
|
if err := imdb.UpdateGroupInfoDefaultZero(req.GroupInfoForSet.GroupID, m); err != nil {
|
||||||
log.NewError(req.OperationID, "UpdateGroupInfoDefaultZero failed ", err.Error(), m)
|
log.NewError(req.OperationID, "UpdateGroupInfoDefaultZero failed ", err.Error(), m)
|
||||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, http.WrapError(constant.ErrDB)
|
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@ -1234,11 +1235,11 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
err = imdb.SetGroupInfo(groupInfo)
|
err = imdb.SetGroupInfo(groupInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, "SetGroupInfo failed ", err.Error(), groupInfo)
|
log.NewError(req.OperationID, "SetGroupInfo failed ", err.Error(), groupInfo)
|
||||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, http.WrapError(constant.ErrDB)
|
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
if err := rocksCache.DelGroupInfoFromCache(req.GroupInfoForSet.GroupID); err != nil {
|
if err := rocksCache.DelGroupInfoFromCache(req.GroupInfoForSet.GroupID); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelGroupInfoFromCache failed ", err.Error(), req.GroupInfoForSet.GroupID)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelGroupInfoFromCache failed ", err.Error(), req.GroupInfoForSet.GroupID)
|
||||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, http.WrapError(constant.ErrDB)
|
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, "SetGroupInfo rpc return ", pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{}})
|
log.NewInfo(req.OperationID, "SetGroupInfo rpc return ", pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{}})
|
||||||
@ -1252,7 +1253,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
log.NewError(req.OperationID, errMsg)
|
log.NewError(req.OperationID, errMsg)
|
||||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, http.WrapError(constant.ErrInternal)
|
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil
|
||||||
}
|
}
|
||||||
client := pbCache.NewCacheClient(etcdConn)
|
client := pbCache.NewCacheClient(etcdConn)
|
||||||
cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq)
|
cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq)
|
||||||
@ -1281,7 +1282,7 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
|
|||||||
if etcdConn == nil {
|
if etcdConn == nil {
|
||||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
log.NewError(req.OperationID, errMsg)
|
log.NewError(req.OperationID, errMsg)
|
||||||
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, http.WrapError(constant.ErrInternal)
|
return &pbGroup.SetGroupInfoResp{CommonResp: &pbGroup.CommonResp{ErrCode: constant.ErrInternal.ErrCode, ErrMsg: errMsg}}, nil
|
||||||
}
|
}
|
||||||
nClient := pbConversation.NewConversationClient(nEtcdConn)
|
nClient := pbConversation.NewConversationClient(nEtcdConn)
|
||||||
conversationReply, err := nClient.ModifyConversationField(context.Background(), &conversationReq)
|
conversationReply, err := nClient.ModifyConversationField(context.Background(), &conversationReq)
|
||||||
@ -1336,100 +1337,54 @@ func (s *groupServer) TransferGroupOwner(_ context.Context, req *pbGroup.Transfe
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupByID(_ context.Context, req *pbGroup.GetGroupByIDReq) (*pbGroup.GetGroupByIDResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
|
||||||
resp := &pbGroup.GetGroupByIDResp{CMSGroup: &pbGroup.CMSGroup{
|
|
||||||
GroupInfo: &open_im_sdk.GroupInfo{},
|
|
||||||
}}
|
|
||||||
group, err := imdb.GetGroupInfoByGroupID(req.GroupID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupById error", err.Error())
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
utils.CopyStructFields(resp.CMSGroup.GroupInfo, group)
|
|
||||||
groupMember, err := imdb.GetGroupOwnerInfoByGroupID(group.GroupID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster", err.Error())
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
groupMemberNum, err := imdb.GetGroupMemberNumByGroupID(req.GroupID)
|
|
||||||
if err == nil {
|
|
||||||
resp.CMSGroup.GroupInfo.MemberCount = uint32(groupMemberNum)
|
|
||||||
} else {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
|
||||||
}
|
|
||||||
resp.CMSGroup.GroupOwnerUserName = groupMember.Nickname
|
|
||||||
resp.CMSGroup.GroupOwnerUserID = groupMember.UserID
|
|
||||||
resp.CMSGroup.GroupInfo.CreatorUserID = group.CreatorUserID
|
|
||||||
resp.CMSGroup.GroupInfo.CreateTime = uint32(group.CreateTime.Unix())
|
|
||||||
utils.CopyStructFields(resp.CMSGroup.GroupInfo, group)
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *groupServer) GetGroup(_ context.Context, req *pbGroup.GetGroupReq) (*pbGroup.GetGroupResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
|
||||||
resp := &pbGroup.GetGroupResp{
|
|
||||||
CMSGroups: []*pbGroup.CMSGroup{},
|
|
||||||
}
|
|
||||||
groups, err := imdb.GetGroupsByName(req.GroupName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsByName error", req.String(), req.GroupName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "groups", groups)
|
|
||||||
nums, err := imdb.GetGroupsCountNum(db.Group{GroupName: req.GroupName})
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsCountNum error", err.Error(), req.GroupName)
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
resp.GroupNums = nums
|
|
||||||
resp.Pagination = &open_im_sdk.RequestPagination{
|
|
||||||
PageNumber: req.Pagination.PageNumber,
|
|
||||||
ShowNumber: req.Pagination.ShowNumber,
|
|
||||||
}
|
|
||||||
for _, v := range groups {
|
|
||||||
group := &pbGroup.CMSGroup{GroupInfo: &open_im_sdk.GroupInfo{}}
|
|
||||||
utils.CopyStructFields(group.GroupInfo, v)
|
|
||||||
groupMember, err := imdb.GetGroupOwnerInfoByGroupID(v.GroupID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster error", err.Error())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
group.GroupInfo.CreateTime = uint32(v.CreateTime.Unix())
|
|
||||||
group.GroupOwnerUserID = groupMember.UserID
|
|
||||||
group.GroupOwnerUserName = groupMember.Nickname
|
|
||||||
resp.CMSGroups = append(resp.CMSGroups, group)
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*pbGroup.GetGroupsResp, error) {
|
func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*pbGroup.GetGroupsResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetGroups ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetGroups ", req.String())
|
||||||
resp := &pbGroup.GetGroupsResp{
|
resp := &pbGroup.GetGroupsResp{
|
||||||
|
CommonResp: &pbGroup.CommonResp{},
|
||||||
CMSGroups: []*pbGroup.CMSGroup{},
|
CMSGroups: []*pbGroup.CMSGroup{},
|
||||||
Pagination: &open_im_sdk.RequestPagination{},
|
Pagination: &open_im_sdk.ResponsePagination{CurrentPage: req.Pagination.PageNumber, ShowNumber: req.Pagination.ShowNumber},
|
||||||
}
|
}
|
||||||
groups, err := imdb.GetGroups(int(req.Pagination.PageNumber), int(req.Pagination.ShowNumber))
|
if req.GroupID != "" {
|
||||||
|
groupInfoDB, err := imdb.GetGroupInfoByGroupID(req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroups error", err.Error())
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
return resp, nil
|
||||||
}
|
}
|
||||||
resp.GroupNum, err = imdb.GetGroupsCountNum(db.Group{})
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
resp.GroupNum = 1
|
||||||
|
groupInfo := &open_im_sdk.GroupInfo{}
|
||||||
|
utils.CopyStructFields(groupInfo, groupInfoDB)
|
||||||
|
groupMember, err := imdb.GetGroupOwnerInfoByGroupID(req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsCountNum error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
memberNum, err := imdb.GetGroupMembersCount(req.GroupID, "")
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
groupInfo.MemberCount = uint32(memberNum)
|
||||||
|
resp.CMSGroups = append(resp.CMSGroups, &pbGroup.CMSGroup{GroupInfo: groupInfo, GroupOwnerUserName: groupMember.Nickname, GroupOwnerUserID: groupMember.UserID})
|
||||||
|
} else {
|
||||||
|
groups, err := imdb.GetGroupsByName(req.GroupName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsByName error", req.String(), req.GroupName, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||||
}
|
}
|
||||||
resp.Pagination.PageNumber = req.Pagination.PageNumber
|
|
||||||
resp.Pagination.ShowNumber = req.Pagination.ShowNumber
|
|
||||||
for _, v := range groups {
|
for _, v := range groups {
|
||||||
group := &pbGroup.CMSGroup{GroupInfo: &open_im_sdk.GroupInfo{}}
|
group := &pbGroup.CMSGroup{GroupInfo: &open_im_sdk.GroupInfo{}}
|
||||||
utils.CopyStructFields(group.GroupInfo, v)
|
utils.CopyStructFields(group.GroupInfo, v)
|
||||||
groupMember, err := imdb.GetGroupOwnerInfoByGroupID(v.GroupID)
|
groupMember, err := imdb.GetGroupOwnerInfoByGroupID(v.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster failed", err.Error(), v)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupOwnerInfoByGroupID failed", err.Error(), v)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
group.GroupInfo.CreateTime = uint32(v.CreateTime.Unix())
|
group.GroupInfo.CreateTime = uint32(v.CreateTime.Unix())
|
||||||
@ -1437,53 +1392,34 @@ func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*
|
|||||||
group.GroupOwnerUserName = groupMember.Nickname
|
group.GroupOwnerUserName = groupMember.Nickname
|
||||||
resp.CMSGroups = append(resp.CMSGroups, group)
|
resp.CMSGroups = append(resp.CMSGroups, group)
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetGroups ", resp.String())
|
resp.GroupNum, err = imdb.GetGroupsCountNum(db.Group{GroupName: req.GroupName})
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupsCountNum error", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
|
||||||
|
|
||||||
func (s *groupServer) OperateUserRole(_ context.Context, req *pbGroup.OperateUserRoleReq) (*pbGroup.OperateUserRoleResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String())
|
|
||||||
resp := &pbGroup.OperateUserRoleResp{}
|
|
||||||
oldOwnerUserID, err := imdb.GetGroupOwnerInfoByGroupID(req.GroupID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster failed", err.Error())
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
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)
|
|
||||||
return resp, http.WrapError(constant.ErrInternal)
|
|
||||||
}
|
|
||||||
client := pbGroup.NewGroupClient(etcdConn)
|
|
||||||
var reqPb pbGroup.TransferGroupOwnerReq
|
|
||||||
reqPb.OperationID = req.OperationID
|
|
||||||
reqPb.NewOwnerUserID = req.UserID
|
|
||||||
reqPb.GroupID = req.GroupID
|
|
||||||
reqPb.OpUserID = "cms admin"
|
|
||||||
reqPb.OldOwnerUserID = oldOwnerUserID.UserID
|
|
||||||
reply, err := client.TransferGroupOwner(context.Background(), &reqPb)
|
|
||||||
if reply.CommonResp.ErrCode != 0 || err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "TransferGroupOwner rpc failed")
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetGroups resp", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupMembersCMS(_ context.Context, req *pbGroup.GetGroupMembersCMSReq) (*pbGroup.GetGroupMembersCMSResp, error) {
|
func (s *groupServer) GetGroupMembersCMS(_ context.Context, req *pbGroup.GetGroupMembersCMSReq) (*pbGroup.GetGroupMembersCMSResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String())
|
||||||
resp := &pbGroup.GetGroupMembersCMSResp{}
|
resp := &pbGroup.GetGroupMembersCMSResp{CommonResp: &pbGroup.CommonResp{}}
|
||||||
groupMembers, err := imdb.GetGroupMembersByGroupIdCMS(req.GroupID, req.UserName, req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
groupMembers, err := imdb.GetGroupMembersByGroupIdCMS(req.GroupID, req.UserName, req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMembersByGroupIdCMS Error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMembersByGroupIdCMS Error", err.Error())
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
groupMembersCount, err := imdb.GetGroupMembersCount(req.GroupID, req.UserName)
|
groupMembersCount, err := imdb.GetGroupMembersCount(req.GroupID, req.UserName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMembersCMS Error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMembersCMS Error", err.Error())
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, groupMembersCount)
|
log.NewInfo(req.OperationID, groupMembersCount)
|
||||||
resp.MemberNums = int32(groupMembersCount)
|
resp.MemberNums = int32(groupMembersCount)
|
||||||
@ -1502,151 +1438,6 @@ func (s *groupServer) GetGroupMembersCMS(_ context.Context, req *pbGroup.GetGrou
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) RemoveGroupMembersCMS(_ context.Context, req *pbGroup.RemoveGroupMembersCMSReq) (*pbGroup.RemoveGroupMembersCMSResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String())
|
|
||||||
resp := &pbGroup.RemoveGroupMembersCMSResp{}
|
|
||||||
for _, userId := range req.UserIDList {
|
|
||||||
err := imdb.DeleteGroupMemberByGroupIDAndUserID(req.GroupID, userId)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
|
||||||
resp.Failed = append(resp.Failed, userId)
|
|
||||||
} else {
|
|
||||||
resp.Success = append(resp.Success, userId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
reqKick := &pbGroup.KickGroupMemberReq{
|
|
||||||
GroupID: req.GroupID,
|
|
||||||
KickedUserIDList: resp.Success,
|
|
||||||
Reason: "admin kick",
|
|
||||||
OperationID: req.OperationID,
|
|
||||||
OpUserID: req.OpUserID,
|
|
||||||
}
|
|
||||||
var reqPb pbUser.SetConversationReq
|
|
||||||
var c pbConversation.Conversation
|
|
||||||
for _, v := range resp.Success {
|
|
||||||
reqPb.OperationID = req.OperationID
|
|
||||||
c.OwnerUserID = v
|
|
||||||
c.ConversationID = utils.GetConversationIDBySessionType(req.GroupID, constant.GroupChatType)
|
|
||||||
c.ConversationType = constant.GroupChatType
|
|
||||||
c.GroupID = req.GroupID
|
|
||||||
c.IsNotInGroup = true
|
|
||||||
reqPb.Conversation = &c
|
|
||||||
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)
|
|
||||||
return resp, http.WrapError(constant.ErrInternal)
|
|
||||||
}
|
|
||||||
client := pbUser.NewUserClient(etcdConn)
|
|
||||||
respPb, err := client.SetConversation(context.Background(), &reqPb)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error(), v)
|
|
||||||
} else {
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "SetConversation success", respPb.String(), v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
cacheClient := pbCache.NewCacheClient(etcdConn)
|
|
||||||
cacheResp, err := cacheClient.DelGroupMemberIDListFromCache(context.Background(), &pbCache.DelGroupMemberIDListFromCacheReq{
|
|
||||||
GroupID: req.GroupID,
|
|
||||||
OperationID: req.OperationID,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc call failed ", err.Error())
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
if cacheResp.CommonResp.ErrCode != 0 {
|
|
||||||
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupID); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
|
||||||
}
|
|
||||||
if err := rocksCache.DelGroupMemberNumFromCache(req.GroupID); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, userID := range resp.Success {
|
|
||||||
if err := rocksCache.DelGroupMemberInfoFromCache(req.GroupID, userID); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID, userID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
chat.MemberKickedNotification(reqKick, resp.Success)
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *groupServer) AddGroupMembersCMS(_ context.Context, req *pbGroup.AddGroupMembersCMSReq) (*pbGroup.AddGroupMembersCMSResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "args:", req.String())
|
|
||||||
resp := &pbGroup.AddGroupMembersCMSResp{}
|
|
||||||
for _, userId := range req.UserIDList {
|
|
||||||
if isExist := imdb.IsExistGroupMember(req.GroupID, userId); isExist {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "user is exist in group", userId, req.GroupID)
|
|
||||||
resp.Failed = append(resp.Failed, userId)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
user, err := imdb.GetUserByUserID(userId)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserByUserID", err.Error())
|
|
||||||
resp.Failed = append(resp.Failed, userId)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
groupMember := db.GroupMember{
|
|
||||||
GroupID: req.GroupID,
|
|
||||||
UserID: userId,
|
|
||||||
Nickname: user.Nickname,
|
|
||||||
FaceURL: "",
|
|
||||||
RoleLevel: 1,
|
|
||||||
JoinTime: time.Time{},
|
|
||||||
JoinSource: constant.JoinByAdmin,
|
|
||||||
OperatorUserID: "CmsAdmin",
|
|
||||||
Ex: "",
|
|
||||||
}
|
|
||||||
if err := imdb.InsertIntoGroupMember(groupMember); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "InsertIntoGroupMember failed", req.String())
|
|
||||||
resp.Failed = append(resp.Failed, userId)
|
|
||||||
} else {
|
|
||||||
resp.Success = append(resp.Success, userId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, req.OperationID)
|
|
||||||
if etcdConn == nil {
|
|
||||||
errMsg := req.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(req.OperationID, errMsg)
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
cacheClient := pbCache.NewCacheClient(etcdConn)
|
|
||||||
cacheResp, err := cacheClient.DelGroupMemberIDListFromCache(context.Background(), &pbCache.DelGroupMemberIDListFromCacheReq{
|
|
||||||
GroupID: req.GroupID,
|
|
||||||
OperationID: req.OperationID,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc call failed ", err.Error())
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
if cacheResp.CommonResp.ErrCode != 0 {
|
|
||||||
log.NewError(req.OperationID, "DelGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
|
||||||
return resp, http.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
if err := rocksCache.DelGroupMemberListHashFromCache(req.GroupID); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
|
||||||
}
|
|
||||||
if err := rocksCache.DelGroupMemberNumFromCache(req.GroupID); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.GroupID)
|
|
||||||
}
|
|
||||||
|
|
||||||
chat.MemberInvitedNotification(req.OperationID, req.GroupID, req.OpUserID, "admin add you to group", resp.Success)
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *groupServer) GetUserReqApplicationList(_ context.Context, req *pbGroup.GetUserReqApplicationListReq) (*pbGroup.GetUserReqApplicationListResp, error) {
|
func (s *groupServer) GetUserReqApplicationList(_ context.Context, req *pbGroup.GetUserReqApplicationListReq) (*pbGroup.GetUserReqApplicationListResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbGroup.GetUserReqApplicationListResp{}
|
resp := &pbGroup.GetUserReqApplicationListResp{}
|
||||||
|
@ -1,182 +0,0 @@
|
|||||||
package messageCMS
|
|
||||||
|
|
||||||
import (
|
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"Open_IM/pkg/common/constant"
|
|
||||||
"Open_IM/pkg/common/db"
|
|
||||||
errors "Open_IM/pkg/common/http"
|
|
||||||
"context"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"Open_IM/pkg/common/log"
|
|
||||||
|
|
||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
|
||||||
pbMessageCMS "Open_IM/pkg/proto/message_cms"
|
|
||||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
|
||||||
|
|
||||||
"Open_IM/pkg/utils"
|
|
||||||
|
|
||||||
"net"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
)
|
|
||||||
|
|
||||||
type messageCMSServer struct {
|
|
||||||
rpcPort int
|
|
||||||
rpcRegisterName string
|
|
||||||
etcdSchema string
|
|
||||||
etcdAddr []string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewMessageCMSServer(port int) *messageCMSServer {
|
|
||||||
log.NewPrivateLog(constant.LogFileName)
|
|
||||||
return &messageCMSServer{
|
|
||||||
rpcPort: port,
|
|
||||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImMessageCMSName,
|
|
||||||
etcdSchema: config.Config.Etcd.EtcdSchema,
|
|
||||||
etcdAddr: config.Config.Etcd.EtcdAddr,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *messageCMSServer) Run() {
|
|
||||||
log.NewInfo("0", "messageCMS rpc start ")
|
|
||||||
|
|
||||||
listenIP := ""
|
|
||||||
if config.Config.ListenIP == "" {
|
|
||||||
listenIP = "0.0.0.0"
|
|
||||||
} else {
|
|
||||||
listenIP = config.Config.ListenIP
|
|
||||||
}
|
|
||||||
address := listenIP + ":" + strconv.Itoa(s.rpcPort)
|
|
||||||
|
|
||||||
//listener network
|
|
||||||
listener, err := net.Listen("tcp", address)
|
|
||||||
if err != nil {
|
|
||||||
panic("listening err:" + err.Error() + s.rpcRegisterName)
|
|
||||||
}
|
|
||||||
log.NewInfo("0", "listen network success, ", address, listener)
|
|
||||||
defer listener.Close()
|
|
||||||
//grpc server
|
|
||||||
srv := grpc.NewServer()
|
|
||||||
defer srv.GracefulStop()
|
|
||||||
//Service registers with etcd
|
|
||||||
pbMessageCMS.RegisterMessageCMSServer(srv, s)
|
|
||||||
rpcRegisterIP := config.Config.RpcRegisterIP
|
|
||||||
if config.Config.RpcRegisterIP == "" {
|
|
||||||
rpcRegisterIP, err = utils.GetLocalIP()
|
|
||||||
if err != nil {
|
|
||||||
log.Error("", "GetLocalIP failed ", err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.NewInfo("", "rpcRegisterIP", rpcRegisterIP)
|
|
||||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError("0", "RegisterEtcd failed ", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = srv.Serve(listener)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError("0", "Serve failed ", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo("0", "message cms rpc success")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *messageCMSServer) BoradcastMessage(_ context.Context, req *pbMessageCMS.BoradcastMessageReq) (*pbMessageCMS.BoradcastMessageResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "BoradcastMessage", req.String())
|
|
||||||
resp := &pbMessageCMS.BoradcastMessageResp{}
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *messageCMSServer) GetChatLogs(_ context.Context, req *pbMessageCMS.GetChatLogsReq) (*pbMessageCMS.GetChatLogsResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetChatLogs", req.String())
|
|
||||||
resp := &pbMessageCMS.GetChatLogsResp{}
|
|
||||||
time, err := utils.TimeStringToTime(req.Date)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "time string parse error", err.Error())
|
|
||||||
}
|
|
||||||
chatLog := db.ChatLog{
|
|
||||||
Content: req.Content,
|
|
||||||
SendTime: time,
|
|
||||||
ContentType: req.ContentType,
|
|
||||||
SessionType: req.SessionType,
|
|
||||||
}
|
|
||||||
switch chatLog.SessionType {
|
|
||||||
case constant.SingleChatType:
|
|
||||||
chatLog.SendID = req.UserId
|
|
||||||
case constant.GroupChatType:
|
|
||||||
chatLog.RecvID = req.GroupId
|
|
||||||
chatLog.SendID = req.UserId
|
|
||||||
}
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "chat_log: ", chatLog)
|
|
||||||
nums, err := imdb.GetChatLogCount(chatLog)
|
|
||||||
resp.ChatLogsNum = int32(nums)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetChatLogCount", err.Error())
|
|
||||||
}
|
|
||||||
chatLogs, err := imdb.GetChatLog(chatLog, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetChatLog", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
for _, chatLog := range chatLogs {
|
|
||||||
pbChatLog := &pbMessageCMS.ChatLogs{
|
|
||||||
SessionType: chatLog.SessionType,
|
|
||||||
ContentType: chatLog.ContentType,
|
|
||||||
SearchContent: req.Content,
|
|
||||||
WholeContent: chatLog.Content,
|
|
||||||
Date: chatLog.CreateTime.String(),
|
|
||||||
SenderNickName: chatLog.SenderNickname,
|
|
||||||
SenderId: chatLog.SendID,
|
|
||||||
}
|
|
||||||
if chatLog.SenderNickname == "" {
|
|
||||||
sendUser, err := imdb.GetUserByUserID(chatLog.SendID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserByUserID failed", err.Error())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
pbChatLog.SenderNickName = sendUser.Nickname
|
|
||||||
}
|
|
||||||
switch chatLog.SessionType {
|
|
||||||
case constant.SingleChatType:
|
|
||||||
recvUser, err := imdb.GetUserByUserID(chatLog.RecvID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserByUserID failed", err.Error())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
pbChatLog.ReciverId = recvUser.UserID
|
|
||||||
pbChatLog.ReciverNickName = recvUser.Nickname
|
|
||||||
|
|
||||||
case constant.GroupChatType:
|
|
||||||
group, err := imdb.GetGroupInfoByGroupID(chatLog.RecvID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupById failed")
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
pbChatLog.GroupId = group.GroupID
|
|
||||||
pbChatLog.GroupName = group.GroupName
|
|
||||||
}
|
|
||||||
resp.ChatLogs = append(resp.ChatLogs, pbChatLog)
|
|
||||||
}
|
|
||||||
resp.Pagination = &open_im_sdk.ResponsePagination{
|
|
||||||
CurrentPage: req.Pagination.PageNumber,
|
|
||||||
ShowNumber: req.Pagination.ShowNumber,
|
|
||||||
}
|
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp output: ", resp.String())
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *messageCMSServer) MassSendMessage(_ context.Context, req *pbMessageCMS.MassSendMessageReq) (*pbMessageCMS.MassSendMessageResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "MassSendMessage", req.String())
|
|
||||||
resp := &pbMessageCMS.MassSendMessageResp{}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *messageCMSServer) WithdrawMessage(_ context.Context, req *pbMessageCMS.WithdrawMessageReq) (*pbMessageCMS.WithdrawMessageResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "WithdrawMessage", req.String())
|
|
||||||
resp := &pbMessageCMS.WithdrawMessageResp{}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
@ -70,11 +70,12 @@ func ConversationChangeNotification(operationID, userID string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//会话未读数同步
|
//会话未读数同步
|
||||||
func ConversationUnreadChangeNotification(operationID, userID, conversationID string) {
|
func ConversationUnreadChangeNotification(operationID, userID, conversationID string, updateUnreadCountTime int64) {
|
||||||
log.NewInfo(operationID, utils.GetSelfFuncName())
|
log.NewInfo(operationID, utils.GetSelfFuncName())
|
||||||
ConversationChangedTips := &open_im_sdk.ConversationUpdateTips{
|
ConversationChangedTips := &open_im_sdk.ConversationUpdateTips{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
ConversationIDList: []string{conversationID},
|
ConversationIDList: []string{conversationID},
|
||||||
|
UpdateUnreadCountTime: updateUnreadCountTime,
|
||||||
}
|
}
|
||||||
var tips open_im_sdk.TipsComm
|
var tips open_im_sdk.TipsComm
|
||||||
tips.DefaultTips = config.Config.Notification.ConversationOptUpdate.DefaultTips.Tips
|
tips.DefaultTips = config.Config.Notification.ConversationOptUpdate.DefaultTips.Tips
|
||||||
|
@ -7,13 +7,15 @@ import (
|
|||||||
pbMsg "Open_IM/pkg/proto/msg"
|
pbMsg "Open_IM/pkg/proto/msg"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
goRedis "github.com/go-redis/redis/v8"
|
goRedis "github.com/go-redis/redis/v8"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (rpc *rpcChat) SetSendMsgFailedFlag(_ context.Context, req *pbMsg.SetSendMsgFailedFlagReq) (resp *pbMsg.SetSendMsgFailedFlagResp, err error) {
|
func (rpc *rpcChat) SetSendMsgStatus(_ context.Context, req *pbMsg.SetSendMsgStatusReq) (resp *pbMsg.SetSendMsgStatusResp, err error) {
|
||||||
resp = &pbMsg.SetSendMsgFailedFlagResp{}
|
resp = &pbMsg.SetSendMsgStatusResp{}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||||
if err := db.DB.SetSendMsgFailedFlag(req.OperationID); err != nil {
|
if err := db.DB.SetSendMsgStatus(req.Status, req.OperationID); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
resp.ErrCode = constant.ErrDB.ErrCode
|
resp.ErrCode = constant.ErrDB.ErrCode
|
||||||
resp.ErrMsg = err.Error()
|
resp.ErrMsg = err.Error()
|
||||||
return resp, nil
|
return resp, nil
|
||||||
@ -25,9 +27,11 @@ func (rpc *rpcChat) SetSendMsgFailedFlag(_ context.Context, req *pbMsg.SetSendMs
|
|||||||
func (rpc *rpcChat) GetSendMsgStatus(_ context.Context, req *pbMsg.GetSendMsgStatusReq) (resp *pbMsg.GetSendMsgStatusResp, err error) {
|
func (rpc *rpcChat) GetSendMsgStatus(_ context.Context, req *pbMsg.GetSendMsgStatusReq) (resp *pbMsg.GetSendMsgStatusResp, err error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||||
resp = &pbMsg.GetSendMsgStatusResp{}
|
resp = &pbMsg.GetSendMsgStatusResp{}
|
||||||
if err := db.DB.GetSendMsgStatus(req.OperationID); err != nil {
|
status, err := db.DB.GetSendMsgStatus(req.OperationID)
|
||||||
|
if err != nil {
|
||||||
|
resp.Status = constant.MsgStatusNotExist
|
||||||
if err == goRedis.Nil {
|
if err == goRedis.Nil {
|
||||||
resp.Status = 0
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.OperationID, "not exist")
|
||||||
return resp, nil
|
return resp, nil
|
||||||
} else {
|
} else {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
@ -36,7 +40,7 @@ func (rpc *rpcChat) GetSendMsgStatus(_ context.Context, req *pbMsg.GetSendMsgSta
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resp.Status = 1
|
resp.Status = int32(status)
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package msg
|
package msg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
utils2 "Open_IM/pkg/common/utils"
|
utils2 "Open_IM/pkg/common/utils"
|
||||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
|
|
||||||
"github.com/golang/protobuf/jsonpb"
|
"github.com/golang/protobuf/jsonpb"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
)
|
)
|
||||||
@ -29,7 +31,7 @@ func OrganizationNotificationToAll(opUserID string, operationID string) {
|
|||||||
|
|
||||||
for _, v := range userIDList {
|
for _, v := range userIDList {
|
||||||
log.Debug(operationID, "OrganizationNotification", opUserID, v, constant.OrganizationChangedNotification, &tips, operationID)
|
log.Debug(operationID, "OrganizationNotification", opUserID, v, constant.OrganizationChangedNotification, &tips, operationID)
|
||||||
OrganizationNotification(opUserID, v, constant.OrganizationChangedNotification, &tips, operationID)
|
OrganizationNotification(config.Config.Manager.AppManagerUid[0], v, constant.OrganizationChangedNotification, &tips, operationID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ func (rpc *rpcChat) Run() {
|
|||||||
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName, 10)
|
err = getcdv3.RegisterEtcd(rpc.etcdSchema, strings.Join(rpc.etcdAddr, ","), rpcRegisterIP, rpc.rpcPort, rpc.rpcRegisterName, 10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("", "register rpcChat to etcd failed ", err.Error())
|
log.Error("", "register rpcChat to etcd failed ", err.Error())
|
||||||
return
|
panic(utils.Wrap(err, "register chat module rpc to etcd err"))
|
||||||
}
|
}
|
||||||
go rpc.runCh()
|
go rpc.runCh()
|
||||||
err = srv.Serve(listener)
|
err = srv.Serve(listener)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package msg
|
package msg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
utils2 "Open_IM/internal/utils"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
@ -9,7 +10,6 @@ import (
|
|||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
cacheRpc "Open_IM/pkg/proto/cache"
|
cacheRpc "Open_IM/pkg/proto/cache"
|
||||||
pbCache "Open_IM/pkg/proto/cache"
|
|
||||||
pbConversation "Open_IM/pkg/proto/conversation"
|
pbConversation "Open_IM/pkg/proto/conversation"
|
||||||
pbChat "Open_IM/pkg/proto/msg"
|
pbChat "Open_IM/pkg/proto/msg"
|
||||||
pbRelay "Open_IM/pkg/proto/relay"
|
pbRelay "Open_IM/pkg/proto/relay"
|
||||||
@ -139,36 +139,45 @@ func messageVerification(data *pbChat.SendMsgReq) (bool, int32, string, []string
|
|||||||
if groupInfo.GroupType == constant.SuperGroup {
|
if groupInfo.GroupType == constant.SuperGroup {
|
||||||
return true, 0, "", nil
|
return true, 0, "", nil
|
||||||
} else {
|
} else {
|
||||||
getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: data.OperationID, GroupID: data.MsgData.GroupID}
|
userIDList, err := utils2.GetGroupMemberUserIDList(data.MsgData.GroupID, data.OperationID)
|
||||||
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, data.OperationID)
|
if err != nil {
|
||||||
if etcdConn == nil {
|
errMsg := data.OperationID + err.Error()
|
||||||
errMsg := data.OperationID + "getcdv3.GetDefaultConn == nil"
|
|
||||||
log.NewError(data.OperationID, errMsg)
|
log.NewError(data.OperationID, errMsg)
|
||||||
//return returnMsg(&replay, pb, 201, errMsg, "", 0)
|
|
||||||
return false, 201, errMsg, nil
|
return false, 201, errMsg, nil
|
||||||
}
|
}
|
||||||
client := pbCache.NewCacheClient(etcdConn)
|
|
||||||
cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq)
|
//
|
||||||
if err != nil {
|
//getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: data.OperationID, GroupID: data.MsgData.GroupID}
|
||||||
log.NewError(data.OperationID, "GetGroupMemberIDListFromCache rpc call failed ", err.Error())
|
//etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, data.OperationID)
|
||||||
//return returnMsg(&replay, pb, 201, "GetGroupMemberIDListFromCache failed", "", 0)
|
//if etcdConn == nil {
|
||||||
return false, 201, err.Error(), nil
|
// errMsg := data.OperationID + "getcdv3.GetDefaultConn == nil"
|
||||||
}
|
// log.NewError(data.OperationID, errMsg)
|
||||||
if cacheResp.CommonResp.ErrCode != 0 {
|
// return false, 201, errMsg, nil
|
||||||
log.NewError(data.OperationID, "GetGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
//}
|
||||||
//return returnMsg(&replay, pb, 201, "GetGroupMemberIDListFromCache logic failed", "", 0)
|
//client := pbCache.NewCacheClient(etcdConn)
|
||||||
return false, cacheResp.CommonResp.ErrCode, cacheResp.CommonResp.ErrMsg, nil
|
// cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq)
|
||||||
}
|
//
|
||||||
|
//
|
||||||
|
//if err != nil {
|
||||||
|
// log.NewError(data.OperationID, "GetGroupMemberIDListFromCache rpc call failed ", err.Error())
|
||||||
|
// //return returnMsg(&replay, pb, 201, "GetGroupMemberIDListFromCache failed", "", 0)
|
||||||
|
// return false, 201, err.Error(), nil
|
||||||
|
//}
|
||||||
|
//if cacheResp.CommonResp.ErrCode != 0 {
|
||||||
|
// log.NewError(data.OperationID, "GetGroupMemberIDListFromCache rpc logic call failed ", cacheResp.String())
|
||||||
|
// //return returnMsg(&replay, pb, 201, "GetGroupMemberIDListFromCache logic failed", "", 0)
|
||||||
|
// return false, cacheResp.CommonResp.ErrCode, cacheResp.CommonResp.ErrMsg, nil
|
||||||
|
//}
|
||||||
if !token_verify.IsManagerUserID(data.MsgData.SendID) {
|
if !token_verify.IsManagerUserID(data.MsgData.SendID) {
|
||||||
if data.MsgData.ContentType <= constant.NotificationEnd && data.MsgData.ContentType >= constant.NotificationBegin {
|
if data.MsgData.ContentType <= constant.NotificationEnd && data.MsgData.ContentType >= constant.NotificationBegin {
|
||||||
return true, 0, "", cacheResp.UserIDList
|
return true, 0, "", userIDList
|
||||||
}
|
}
|
||||||
if !utils.IsContain(data.MsgData.SendID, cacheResp.UserIDList) {
|
if !utils.IsContain(data.MsgData.SendID, userIDList) {
|
||||||
//return returnMsg(&replay, pb, 202, "you are not in group", "", 0)
|
//return returnMsg(&replay, pb, 202, "you are not in group", "", 0)
|
||||||
return false, 202, "you are not in group", nil
|
return false, 202, "you are not in group", nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true, 0, "", cacheResp.UserIDList
|
return true, 0, "", userIDList
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return true, 0, "", nil
|
return true, 0, "", nil
|
||||||
|
@ -82,7 +82,7 @@ func (s *officeServer) Run() {
|
|||||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("0", "RegisterEtcd failed ", err.Error())
|
log.NewError("0", "RegisterEtcd failed ", err.Error())
|
||||||
return
|
panic(utils.Wrap(err, "register office module rpc to etcd err"))
|
||||||
}
|
}
|
||||||
go s.sendTagMsgRoutine()
|
go s.sendTagMsgRoutine()
|
||||||
err = srv.Serve(listener)
|
err = srv.Serve(listener)
|
||||||
|
@ -73,7 +73,7 @@ func (s *organizationServer) Run() {
|
|||||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("", "RegisterEtcd failed ", err.Error())
|
log.NewError("", "RegisterEtcd failed ", err.Error())
|
||||||
return
|
panic(utils.Wrap(err, "register organization module rpc to etcd err"))
|
||||||
}
|
}
|
||||||
log.NewInfo("", "organization rpc RegisterEtcd success", rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
log.NewInfo("", "organization rpc RegisterEtcd success", rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
||||||
err = srv.Serve(listener)
|
err = srv.Serve(listener)
|
||||||
|
@ -1,399 +0,0 @@
|
|||||||
package statistics
|
|
||||||
|
|
||||||
import (
|
|
||||||
"Open_IM/pkg/common/config"
|
|
||||||
"Open_IM/pkg/common/constant"
|
|
||||||
"context"
|
|
||||||
"strconv"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
//"Open_IM/pkg/common/constant"
|
|
||||||
//"Open_IM/pkg/common/db"
|
|
||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
|
||||||
"Open_IM/pkg/common/log"
|
|
||||||
|
|
||||||
//cp "Open_IM/pkg/common/utils"
|
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
|
||||||
pbStatistics "Open_IM/pkg/proto/statistics"
|
|
||||||
|
|
||||||
//open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
|
||||||
"Open_IM/pkg/utils"
|
|
||||||
//"context"
|
|
||||||
errors "Open_IM/pkg/common/http"
|
|
||||||
"net"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
)
|
|
||||||
|
|
||||||
type statisticsServer struct {
|
|
||||||
rpcPort int
|
|
||||||
rpcRegisterName string
|
|
||||||
etcdSchema string
|
|
||||||
etcdAddr []string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewStatisticsServer(port int) *statisticsServer {
|
|
||||||
log.NewPrivateLog(constant.LogFileName)
|
|
||||||
return &statisticsServer{
|
|
||||||
rpcPort: port,
|
|
||||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImStatisticsName,
|
|
||||||
etcdSchema: config.Config.Etcd.EtcdSchema,
|
|
||||||
etcdAddr: config.Config.Etcd.EtcdAddr,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *statisticsServer) Run() {
|
|
||||||
log.NewInfo("0", "Statistics rpc start ")
|
|
||||||
|
|
||||||
listenIP := ""
|
|
||||||
if config.Config.ListenIP == "" {
|
|
||||||
listenIP = "0.0.0.0"
|
|
||||||
} else {
|
|
||||||
listenIP = config.Config.ListenIP
|
|
||||||
}
|
|
||||||
address := listenIP + ":" + strconv.Itoa(s.rpcPort)
|
|
||||||
|
|
||||||
//listener network
|
|
||||||
listener, err := net.Listen("tcp", address)
|
|
||||||
if err != nil {
|
|
||||||
panic("listening err:" + err.Error() + s.rpcRegisterName)
|
|
||||||
}
|
|
||||||
log.NewInfo("0", "listen network success, ", address, listener)
|
|
||||||
defer listener.Close()
|
|
||||||
//grpc server
|
|
||||||
srv := grpc.NewServer()
|
|
||||||
defer srv.GracefulStop()
|
|
||||||
//Service registers with etcd
|
|
||||||
pbStatistics.RegisterUserServer(srv, s)
|
|
||||||
rpcRegisterIP := config.Config.RpcRegisterIP
|
|
||||||
if config.Config.RpcRegisterIP == "" {
|
|
||||||
rpcRegisterIP, err = utils.GetLocalIP()
|
|
||||||
if err != nil {
|
|
||||||
log.Error("", "GetLocalIP failed ", err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError("0", "RegisterEtcd failed ", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = srv.Serve(listener)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError("0", "Serve failed ", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.NewInfo("0", "statistics rpc success")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *statisticsServer) GetActiveGroup(_ context.Context, req *pbStatistics.GetActiveGroupReq) (*pbStatistics.GetActiveGroupResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req", req.String())
|
|
||||||
resp := &pbStatistics.GetActiveGroupResp{}
|
|
||||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrArgs)
|
|
||||||
}
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
|
|
||||||
activeGroups, err := imdb.GetActiveGroups(fromTime, toTime, 12)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveGroups failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
for _, activeGroup := range activeGroups {
|
|
||||||
resp.Groups = append(resp.Groups,
|
|
||||||
&pbStatistics.GroupResp{
|
|
||||||
GroupName: activeGroup.Name,
|
|
||||||
GroupId: activeGroup.Id,
|
|
||||||
MessageNum: int32(activeGroup.MessageNum),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *statisticsServer) GetActiveUser(_ context.Context, req *pbStatistics.GetActiveUserReq) (*pbStatistics.GetActiveUserResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
|
||||||
resp := &pbStatistics.GetActiveUserResp{}
|
|
||||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "time: ", fromTime, toTime)
|
|
||||||
activeUsers, err := imdb.GetActiveUsers(fromTime, toTime, 12)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveUsers failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
for _, activeUser := range activeUsers {
|
|
||||||
resp.Users = append(resp.Users,
|
|
||||||
&pbStatistics.UserResp{
|
|
||||||
UserId: activeUser.Id,
|
|
||||||
NickName: activeUser.Name,
|
|
||||||
MessageNum: int32(activeUser.MessageNum),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp.String())
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseTimeFromTo(from, to string) (time.Time, time.Time, error) {
|
|
||||||
var fromTime time.Time
|
|
||||||
var toTime time.Time
|
|
||||||
fromTime, err := utils.TimeStringToTime(from)
|
|
||||||
if err != nil {
|
|
||||||
return fromTime, toTime, err
|
|
||||||
}
|
|
||||||
toTime, err = utils.TimeStringToTime(to)
|
|
||||||
if err != nil {
|
|
||||||
return fromTime, toTime, err
|
|
||||||
}
|
|
||||||
return fromTime, toTime, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func isInOneMonth(from, to time.Time) bool {
|
|
||||||
return from.Month() == to.Month() && from.Year() == to.Year()
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetRangeDate(from, to time.Time) [][2]time.Time {
|
|
||||||
interval := to.Sub(from)
|
|
||||||
var times [][2]time.Time
|
|
||||||
switch {
|
|
||||||
// today
|
|
||||||
case interval == 0:
|
|
||||||
times = append(times, [2]time.Time{
|
|
||||||
from, from.Add(time.Hour * 24),
|
|
||||||
})
|
|
||||||
// days
|
|
||||||
case isInOneMonth(from, to):
|
|
||||||
for i := 0; ; i++ {
|
|
||||||
fromTime := from.Add(time.Hour * 24 * time.Duration(i))
|
|
||||||
toTime := from.Add(time.Hour * 24 * time.Duration(i+1))
|
|
||||||
if toTime.After(to.Add(time.Hour * 24)) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
times = append(times, [2]time.Time{
|
|
||||||
fromTime, toTime,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// month
|
|
||||||
case !isInOneMonth(from, to):
|
|
||||||
if to.Sub(from) < time.Hour*24*30 {
|
|
||||||
for i := 0; ; i++ {
|
|
||||||
fromTime := from.Add(time.Hour * 24 * time.Duration(i))
|
|
||||||
toTime := from.Add(time.Hour * 24 * time.Duration(i+1))
|
|
||||||
if toTime.After(to.Add(time.Hour * 24)) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
times = append(times, [2]time.Time{
|
|
||||||
fromTime, toTime,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for i := 0; ; i++ {
|
|
||||||
if i == 0 {
|
|
||||||
fromTime := from
|
|
||||||
toTime := getFirstDateOfNextNMonth(fromTime, 1)
|
|
||||||
times = append(times, [2]time.Time{
|
|
||||||
fromTime, toTime,
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
fromTime := getFirstDateOfNextNMonth(from, i)
|
|
||||||
toTime := getFirstDateOfNextNMonth(fromTime, 1)
|
|
||||||
if toTime.After(to) {
|
|
||||||
toTime = to
|
|
||||||
times = append(times, [2]time.Time{
|
|
||||||
fromTime, toTime,
|
|
||||||
})
|
|
||||||
break
|
|
||||||
}
|
|
||||||
times = append(times, [2]time.Time{
|
|
||||||
fromTime, toTime,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return times
|
|
||||||
}
|
|
||||||
|
|
||||||
func getFirstDateOfNextNMonth(currentTime time.Time, n int) time.Time {
|
|
||||||
lastOfMonth := time.Date(currentTime.Year(), currentTime.Month(), 1, 0, 0, 0, 0, currentTime.Location()).AddDate(0, n, 0)
|
|
||||||
return lastOfMonth
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *statisticsServer) GetGroupStatistics(_ context.Context, req *pbStatistics.GetGroupStatisticsReq) (*pbStatistics.GetGroupStatisticsResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
|
||||||
resp := &pbStatistics.GetGroupStatisticsResp{}
|
|
||||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupStatistics failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrArgs)
|
|
||||||
}
|
|
||||||
increaseGroupNum, err := imdb.GetIncreaseGroupNum(fromTime, toTime.Add(time.Hour*24))
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum failed", err.Error(), fromTime, toTime)
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
totalGroupNum, err := imdb.GetTotalGroupNum()
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
resp.IncreaseGroupNum = increaseGroupNum
|
|
||||||
resp.TotalGroupNum = totalGroupNum
|
|
||||||
times := GetRangeDate(fromTime, toTime)
|
|
||||||
log.NewDebug(req.OperationID, "times:", times)
|
|
||||||
wg := &sync.WaitGroup{}
|
|
||||||
resp.IncreaseGroupNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
|
|
||||||
resp.TotalGroupNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
|
|
||||||
wg.Add(len(times))
|
|
||||||
for i, v := range times {
|
|
||||||
go func(wg *sync.WaitGroup, index int, v [2]time.Time) {
|
|
||||||
defer wg.Done()
|
|
||||||
num, err := imdb.GetIncreaseGroupNum(v[0], v[1])
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
|
||||||
}
|
|
||||||
resp.IncreaseGroupNumList[index] = &pbStatistics.DateNumList{
|
|
||||||
Date: v[0].String(),
|
|
||||||
Num: num,
|
|
||||||
}
|
|
||||||
num, err = imdb.GetGroupNum(v[1])
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
|
||||||
}
|
|
||||||
resp.TotalGroupNumList[index] = &pbStatistics.DateNumList{
|
|
||||||
Date: v[0].String(),
|
|
||||||
Num: num,
|
|
||||||
}
|
|
||||||
}(wg, i, v)
|
|
||||||
}
|
|
||||||
wg.Wait()
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *statisticsServer) GetMessageStatistics(_ context.Context, req *pbStatistics.GetMessageStatisticsReq) (*pbStatistics.GetMessageStatisticsResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
|
||||||
resp := &pbStatistics.GetMessageStatisticsResp{}
|
|
||||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "times: ", fromTime, toTime)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrArgs)
|
|
||||||
}
|
|
||||||
privateMessageNum, err := imdb.GetPrivateMessageNum(fromTime, toTime.Add(time.Hour*24))
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetPrivateMessageNum failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
groupMessageNum, err := imdb.GetGroupMessageNum(fromTime, toTime.Add(time.Hour*24))
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMessageNum failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), privateMessageNum, groupMessageNum)
|
|
||||||
resp.PrivateMessageNum = privateMessageNum
|
|
||||||
resp.GroupMessageNum = groupMessageNum
|
|
||||||
times := GetRangeDate(fromTime, toTime)
|
|
||||||
resp.GroupMessageNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
|
|
||||||
resp.PrivateMessageNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
|
|
||||||
wg := &sync.WaitGroup{}
|
|
||||||
wg.Add(len(times))
|
|
||||||
for i, v := range times {
|
|
||||||
go func(wg *sync.WaitGroup, index int, v [2]time.Time) {
|
|
||||||
defer wg.Done()
|
|
||||||
|
|
||||||
num, err := imdb.GetPrivateMessageNum(v[0], v[1])
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
|
||||||
}
|
|
||||||
resp.PrivateMessageNumList[index] = &pbStatistics.DateNumList{
|
|
||||||
Date: v[0].String(),
|
|
||||||
Num: num,
|
|
||||||
}
|
|
||||||
num, err = imdb.GetGroupMessageNum(v[0], v[1])
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
|
||||||
}
|
|
||||||
resp.GroupMessageNumList[index] = &pbStatistics.DateNumList{
|
|
||||||
Date: v[0].String(),
|
|
||||||
Num: num,
|
|
||||||
}
|
|
||||||
}(wg, i, v)
|
|
||||||
}
|
|
||||||
wg.Wait()
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *statisticsServer) GetUserStatistics(_ context.Context, req *pbStatistics.GetUserStatisticsReq) (*pbStatistics.GetUserStatisticsResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
|
||||||
resp := &pbStatistics.GetUserStatisticsResp{}
|
|
||||||
fromTime, toTime, err := ParseTimeFromTo(req.StatisticsReq.From, req.StatisticsReq.To)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "ParseTimeFromTo failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrArgs)
|
|
||||||
}
|
|
||||||
activeUserNum, err := imdb.GetActiveUserNum(fromTime, toTime.Add(time.Hour*24))
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetActiveUserNum failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
increaseUserNum, err := imdb.GetIncreaseUserNum(fromTime, toTime.Add(time.Hour*24))
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseUserNum failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
totalUserNum, err := imdb.GetTotalUserNum()
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetTotalUserNum failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
resp.ActiveUserNum = activeUserNum
|
|
||||||
resp.TotalUserNum = totalUserNum
|
|
||||||
resp.IncreaseUserNum = increaseUserNum
|
|
||||||
times := GetRangeDate(fromTime, toTime)
|
|
||||||
resp.TotalUserNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
|
|
||||||
resp.ActiveUserNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
|
|
||||||
resp.IncreaseUserNumList = make([]*pbStatistics.DateNumList, len(times), len(times))
|
|
||||||
wg := &sync.WaitGroup{}
|
|
||||||
wg.Add(len(times))
|
|
||||||
for i, v := range times {
|
|
||||||
go func(wg *sync.WaitGroup, index int, v [2]time.Time) {
|
|
||||||
defer wg.Done()
|
|
||||||
num, err := imdb.GetActiveUserNum(v[0], v[1])
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseGroupNum", v, err.Error())
|
|
||||||
}
|
|
||||||
resp.ActiveUserNumList[index] = &pbStatistics.DateNumList{
|
|
||||||
Date: v[0].String(),
|
|
||||||
Num: num,
|
|
||||||
}
|
|
||||||
|
|
||||||
num, err = imdb.GetTotalUserNumByDate(v[1])
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetTotalUserNumByDate", v, err.Error())
|
|
||||||
}
|
|
||||||
resp.TotalUserNumList[index] = &pbStatistics.DateNumList{
|
|
||||||
Date: v[0].String(),
|
|
||||||
Num: num,
|
|
||||||
}
|
|
||||||
num, err = imdb.GetIncreaseUserNum(v[0], v[1])
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetIncreaseUserNum", v, err.Error())
|
|
||||||
}
|
|
||||||
resp.IncreaseUserNumList[index] = &pbStatistics.DateNumList{
|
|
||||||
Date: v[0].String(),
|
|
||||||
Num: num,
|
|
||||||
}
|
|
||||||
}(wg, i, v)
|
|
||||||
}
|
|
||||||
wg.Wait()
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
@ -7,23 +7,22 @@ import (
|
|||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
rocksCache "Open_IM/pkg/common/db/rocks_cache"
|
rocksCache "Open_IM/pkg/common/db/rocks_cache"
|
||||||
errors "Open_IM/pkg/common/http"
|
|
||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
pbConversation "Open_IM/pkg/proto/conversation"
|
pbConversation "Open_IM/pkg/proto/conversation"
|
||||||
pbFriend "Open_IM/pkg/proto/friend"
|
pbFriend "Open_IM/pkg/proto/friend"
|
||||||
pbOrganization "Open_IM/pkg/proto/organization"
|
|
||||||
sdkws "Open_IM/pkg/proto/sdk_ws"
|
sdkws "Open_IM/pkg/proto/sdk_ws"
|
||||||
pbUser "Open_IM/pkg/proto/user"
|
pbUser "Open_IM/pkg/proto/user"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type userServer struct {
|
type userServer struct {
|
||||||
@ -76,7 +75,7 @@ func (s *userServer) Run() {
|
|||||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName, 10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError("0", "RegisterEtcd failed ", err.Error(), s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName)
|
log.NewError("0", "RegisterEtcd failed ", err.Error(), s.etcdSchema, strings.Join(s.etcdAddr, ","), rpcRegisterIP, s.rpcPort, s.rpcRegisterName)
|
||||||
return
|
panic(utils.Wrap(err, "register user module rpc to etcd err"))
|
||||||
}
|
}
|
||||||
err = srv.Serve(listener)
|
err = srv.Serve(listener)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -201,7 +200,7 @@ func (s *userServer) GetConversation(ctx context.Context, req *pbUser.GetConvers
|
|||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbUser.GetConversationResp{Conversation: &pbConversation.Conversation{}}
|
resp := &pbUser.GetConversationResp{Conversation: &pbConversation.Conversation{}}
|
||||||
conversation, err := rocksCache.GetConversationFromCache(req.OwnerUserID, req.ConversationID)
|
conversation, err := rocksCache.GetConversationFromCache(req.OwnerUserID, req.ConversationID)
|
||||||
log.NewDebug("", utils.GetSelfFuncName(), "conversation", conversation)
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "conversation", conversation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversation error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversation error", err.Error())
|
||||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
@ -219,7 +218,7 @@ func (s *userServer) GetConversations(ctx context.Context, req *pbUser.GetConver
|
|||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbUser.GetConversationsResp{Conversations: []*pbConversation.Conversation{}}
|
resp := &pbUser.GetConversationsResp{Conversations: []*pbConversation.Conversation{}}
|
||||||
conversations, err := rocksCache.GetConversationsFromCache(req.OwnerUserID, req.ConversationIDs)
|
conversations, err := rocksCache.GetConversationsFromCache(req.OwnerUserID, req.ConversationIDs)
|
||||||
log.NewDebug("", utils.GetSelfFuncName(), "conversations", conversations)
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "conversations", conversations)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversations error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversations error", err.Error())
|
||||||
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
@ -336,27 +335,6 @@ func (s *userServer) SetRecvMsgOpt(ctx context.Context, req *pbUser.SetRecvMsgOp
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) DeleteUsers(_ context.Context, req *pbUser.DeleteUsersReq) (*pbUser.DeleteUsersResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, "DeleteUsers args ", req.String())
|
|
||||||
if !token_verify.IsManagerUserID(req.OpUserID) {
|
|
||||||
log.NewError(req.OperationID, "IsManagerUserID false ", req.OpUserID)
|
|
||||||
return &pbUser.DeleteUsersResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, FailedUserIDList: req.DeleteUserIDList}, nil
|
|
||||||
}
|
|
||||||
var common pbUser.CommonResp
|
|
||||||
resp := pbUser.DeleteUsersResp{CommonResp: &common}
|
|
||||||
for _, userID := range req.DeleteUserIDList {
|
|
||||||
i := imdb.DeleteUser(userID)
|
|
||||||
if i == 0 {
|
|
||||||
log.NewError(req.OperationID, "delete user error", userID)
|
|
||||||
common.ErrCode = 201
|
|
||||||
common.ErrMsg = "some uid deleted failed"
|
|
||||||
resp.FailedUserIDList = append(resp.FailedUserIDList, userID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, "DeleteUsers rpc return ", resp.String())
|
|
||||||
return &resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *userServer) GetAllUserID(_ context.Context, req *pbUser.GetAllUserIDReq) (*pbUser.GetAllUserIDResp, error) {
|
func (s *userServer) GetAllUserID(_ context.Context, req *pbUser.GetAllUserIDReq) (*pbUser.GetAllUserIDResp, error) {
|
||||||
log.NewInfo(req.OperationID, "GetAllUserID args ", req.String())
|
log.NewInfo(req.OperationID, "GetAllUserID args ", req.String())
|
||||||
if !token_verify.IsManagerUserID(req.OpUserID) {
|
if !token_verify.IsManagerUserID(req.OpUserID) {
|
||||||
@ -456,35 +434,10 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserI
|
|||||||
chat.UserInfoUpdatedNotification(req.OperationID, req.UserInfo.UserID, req.OpUserID)
|
chat.UserInfoUpdatedNotification(req.OperationID, req.UserInfo.UserID, req.OpUserID)
|
||||||
log.Info(req.OperationID, "UserInfoUpdatedNotification ", req.UserInfo.UserID, req.OpUserID)
|
log.Info(req.OperationID, "UserInfoUpdatedNotification ", req.UserInfo.UserID, req.OpUserID)
|
||||||
if req.UserInfo.FaceURL != "" {
|
if req.UserInfo.FaceURL != "" {
|
||||||
go s.SyncJoinedGroupMemberFaceURL(req.UserInfo.UserID, req.UserInfo.FaceURL, req.OperationID, req.OpUserID)
|
s.SyncJoinedGroupMemberFaceURL(req.UserInfo.UserID, req.UserInfo.FaceURL, req.OperationID, req.OpUserID)
|
||||||
}
|
}
|
||||||
if req.UserInfo.Nickname != "" {
|
if req.UserInfo.Nickname != "" {
|
||||||
go s.SyncJoinedGroupMemberNickname(req.UserInfo.UserID, req.UserInfo.Nickname, oldNickname, req.OperationID, req.OpUserID)
|
s.SyncJoinedGroupMemberNickname(req.UserInfo.UserID, req.UserInfo.Nickname, oldNickname, req.OperationID, req.OpUserID)
|
||||||
}
|
|
||||||
etcdConn = getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOrganizationName, req.OperationID)
|
|
||||||
clientOrg := pbOrganization.NewOrganizationClient(etcdConn)
|
|
||||||
out, err := clientOrg.UpdateOrganizationUser(context.Background(), &pbOrganization.UpdateOrganizationUserReq{
|
|
||||||
OrganizationUser: &sdkws.OrganizationUser{
|
|
||||||
UserID: req.UserInfo.UserID,
|
|
||||||
Nickname: req.UserInfo.Nickname,
|
|
||||||
EnglishName: req.UserInfo.Nickname,
|
|
||||||
FaceURL: req.UserInfo.FaceURL,
|
|
||||||
Gender: req.UserInfo.Gender,
|
|
||||||
Mobile: req.UserInfo.PhoneNumber,
|
|
||||||
Telephone: req.UserInfo.PhoneNumber,
|
|
||||||
Birth: req.UserInfo.Birth,
|
|
||||||
Email: req.UserInfo.Email,
|
|
||||||
Ex: req.UserInfo.Ex,
|
|
||||||
},
|
|
||||||
OperationID: req.OperationID,
|
|
||||||
OpUserID: req.OpUserID,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateOrganizationUser failed", err.Error())
|
|
||||||
} else {
|
|
||||||
if out.ErrCode != 0 {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "grpc resp: ", out)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{}}, nil
|
return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{}}, nil
|
||||||
}
|
}
|
||||||
@ -569,217 +522,177 @@ func (s *userServer) SyncJoinedGroupMemberNickname(userID string, newNickname, o
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) GetUsersByName(ctx context.Context, req *pbUser.GetUsersByNameReq) (*pbUser.GetUsersByNameResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req.String())
|
|
||||||
resp := &pbUser.GetUsersByNameResp{}
|
|
||||||
users, err := imdb.GetUserByName(req.UserName, req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserByName failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
for _, user := range users {
|
|
||||||
isBlock, err := imdb.UserIsBlock(user.UserID)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
resp.Users = append(resp.Users, &pbUser.User{
|
|
||||||
ProfilePhoto: user.FaceURL,
|
|
||||||
Nickname: user.Nickname,
|
|
||||||
UserId: user.UserID,
|
|
||||||
CreateTime: user.CreateTime.Format("2006-01-02 15:04:05"),
|
|
||||||
CreateIp: user.CreateIp,
|
|
||||||
IsBlock: isBlock,
|
|
||||||
Birth: user.Birth.Format("2006-01-02"),
|
|
||||||
PhoneNumber: user.PhoneNumber,
|
|
||||||
Email: user.Email,
|
|
||||||
LastLoginIp: user.LastLoginIp,
|
|
||||||
LastLoginTime: user.LastLoginTime.Format("2006-01-02 15:04:05"),
|
|
||||||
LoginTimes: user.LoginTimes,
|
|
||||||
Gender: user.Gender,
|
|
||||||
LoginLimit: user.LoginLimit,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
user := db.User{Nickname: req.UserName}
|
|
||||||
userNums, err := imdb.GetUsersCount(user)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
resp.UserNums = userNums
|
|
||||||
resp.Pagination = &sdkws.ResponsePagination{
|
|
||||||
CurrentPage: req.Pagination.PageNumber,
|
|
||||||
ShowNumber: req.Pagination.ShowNumber,
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *userServer) GetUserById(ctx context.Context, req *pbUser.GetUserByIdReq) (*pbUser.GetUserByIdResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req.String())
|
|
||||||
resp := &pbUser.GetUserByIdResp{User: &pbUser.User{}}
|
|
||||||
user, err := imdb.GetUserByUserID(req.UserId)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
isBlock, err := imdb.UserIsBlock(req.UserId)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "req:", req.String())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
resp.User = &pbUser.User{
|
|
||||||
ProfilePhoto: user.FaceURL,
|
|
||||||
Nickname: user.Nickname,
|
|
||||||
UserId: user.UserID,
|
|
||||||
CreateTime: user.CreateTime.Format("2006-01-02 15:04:05"),
|
|
||||||
CreateIp: user.CreateIp,
|
|
||||||
IsBlock: isBlock,
|
|
||||||
Birth: user.Birth.Format("2006-01-02"),
|
|
||||||
PhoneNumber: user.PhoneNumber,
|
|
||||||
Email: user.Email,
|
|
||||||
LastLoginIp: user.LastLoginIp,
|
|
||||||
LastLoginTime: user.LastLoginTime.Format("2006-01-02 15:04:05"),
|
|
||||||
LoginTimes: user.LoginTimes,
|
|
||||||
Gender: user.Gender,
|
|
||||||
LoginLimit: user.LoginLimit,
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pbUser.GetUsersResp, error) {
|
func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pbUser.GetUsersResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbUser.GetUsersResp{User: []*pbUser.User{}}
|
var usersDB []db.User
|
||||||
users, err := imdb.GetUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
var err error
|
||||||
|
resp := &pbUser.GetUsersResp{CommonResp: &pbUser.CommonResp{}, Pagination: &sdkws.ResponsePagination{CurrentPage: req.Pagination.PageNumber, ShowNumber: req.Pagination.ShowNumber}}
|
||||||
|
if req.UserID != "" {
|
||||||
|
userDB, err := imdb.GetUserByUserID(req.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsers failed", err.Error())
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, v := range users {
|
|
||||||
isBlock, err := imdb.UserIsBlock(v.UserID)
|
|
||||||
if err == nil {
|
|
||||||
registerIP := ""
|
|
||||||
registerInfo, err := imdb.GetRegisterInfo(v.UserID)
|
|
||||||
if registerInfo != nil && err == nil {
|
|
||||||
registerIP = registerInfo.RegisterIP
|
|
||||||
}
|
|
||||||
|
|
||||||
user := &pbUser.User{
|
|
||||||
ProfilePhoto: v.FaceURL,
|
|
||||||
UserId: v.UserID,
|
|
||||||
CreateTime: v.CreateTime.Format("2006-01-02 15:04:05"),
|
|
||||||
CreateIp: v.CreateIp,
|
|
||||||
Nickname: v.Nickname,
|
|
||||||
Birth: v.Birth.Format("2006-01-02"),
|
|
||||||
PhoneNumber: v.PhoneNumber,
|
|
||||||
Email: v.Email,
|
|
||||||
IsBlock: isBlock,
|
|
||||||
LastLoginIp: v.LastLoginIp,
|
|
||||||
LastLoginTime: v.LastLoginTime.Format("2006-01-02 15:04:05"),
|
|
||||||
LoginTimes: v.LoginTimes,
|
|
||||||
Gender: v.Gender,
|
|
||||||
LoginLimit: v.LoginLimit,
|
|
||||||
RegisterIp: registerIP,
|
|
||||||
}
|
|
||||||
resp.User = append(resp.User, user)
|
|
||||||
} else {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UserIsBlock failed", err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
user := db.User{}
|
|
||||||
nums, err := imdb.GetUsersCount(user)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsersCount failed", err.Error(), user)
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
resp.UserNums = nums
|
|
||||||
resp.Pagination = &sdkws.ResponsePagination{ShowNumber: req.Pagination.ShowNumber, CurrentPage: req.Pagination.PageNumber}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.UserID, err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
usersDB = append(usersDB, *userDB)
|
||||||
|
resp.TotalNums = 1
|
||||||
|
} else if req.UserName != "" {
|
||||||
|
usersDB, err = imdb.GetUserByName(req.UserName, req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.UserName, req.Pagination.ShowNumber, req.Pagination.PageNumber, err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
resp.TotalNums, err = imdb.GetUsersCount(req.UserName)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.UserName, err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *userServer) ResignUser(ctx context.Context, req *pbUser.ResignUserReq) (*pbUser.ResignUserResp, error) {
|
} else if req.Content != "" {
|
||||||
log.NewInfo(req.OperationID, "ResignUser args ", req.String())
|
var count int64
|
||||||
return &pbUser.ResignUserResp{}, nil
|
usersDB, count, err = imdb.GetUsersByNameAndID(req.Content, req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||||
}
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsers failed", req.Pagination.ShowNumber, req.Pagination.PageNumber, err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
resp.TotalNums = int32(count)
|
||||||
|
} else {
|
||||||
|
usersDB, err = imdb.GetUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsers failed", req.Pagination.ShowNumber, req.Pagination.PageNumber, err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
resp.TotalNums, err = imdb.GetTotalUserNum()
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, userDB := range usersDB {
|
||||||
|
var user sdkws.UserInfo
|
||||||
|
utils.CopyStructFields(&user, userDB)
|
||||||
|
user.CreateTime = uint32(userDB.CreateTime.Unix())
|
||||||
|
user.Birth = uint32(userDB.Birth.Unix())
|
||||||
|
resp.UserList = append(resp.UserList, &pbUser.CmsUser{User: &user})
|
||||||
|
}
|
||||||
|
|
||||||
func (s *userServer) AlterUser(ctx context.Context, req *pbUser.AlterUserReq) (*pbUser.AlterUserResp, error) {
|
var userIDList []string
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
for _, v := range resp.UserList {
|
||||||
resp := &pbUser.AlterUserResp{}
|
userIDList = append(userIDList, v.User.UserID)
|
||||||
birth, _ := time.ParseInLocation("2006-01-02", req.Birth, time.Local)
|
|
||||||
gender, gendererr := strconv.Atoi(req.Gender)
|
|
||||||
if gendererr != nil {
|
|
||||||
gender = 0
|
|
||||||
}
|
}
|
||||||
user := db.User{
|
isBlockUser, err := imdb.UsersIsBlock(userIDList)
|
||||||
PhoneNumber: req.PhoneNumber,
|
if err != nil {
|
||||||
Nickname: req.Nickname,
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), userIDList)
|
||||||
Email: req.Email,
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
UserID: req.UserId,
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
Gender: int32(gender),
|
return resp, nil
|
||||||
FaceURL: req.Photo,
|
}
|
||||||
Birth: birth,
|
|
||||||
|
for _, v := range resp.UserList {
|
||||||
|
if utils.IsContain(v.User.UserID, isBlockUser) {
|
||||||
|
v.IsBlock = true
|
||||||
}
|
}
|
||||||
if err := imdb.UpdateUserInfo(user); err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateUserInfo", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
}
|
||||||
chat.UserInfoUpdatedNotification(req.OperationID, req.UserId, req.OpUserId)
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) AddUser(ctx context.Context, req *pbUser.AddUserReq) (*pbUser.AddUserResp, error) {
|
func (s *userServer) AddUser(ctx context.Context, req *pbUser.AddUserReq) (*pbUser.AddUserResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbUser.AddUserResp{}
|
resp := &pbUser.AddUserResp{CommonResp: &pbUser.CommonResp{}}
|
||||||
err := imdb.AddUser(req.UserId, req.PhoneNumber, req.Name, req.Email, req.Gender, req.Photo, req.Birth)
|
err := imdb.AddUser(req.UserInfo.UserID, req.UserInfo.PhoneNumber, req.UserInfo.Nickname, req.UserInfo.Email, req.UserInfo.Gender, req.UserInfo.FaceURL, req.UserInfo.Birth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "AddUser", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "AddUser", err.Error(), req.String())
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) BlockUser(ctx context.Context, req *pbUser.BlockUserReq) (*pbUser.BlockUserResp, error) {
|
func (s *userServer) BlockUser(ctx context.Context, req *pbUser.BlockUserReq) (*pbUser.BlockUserResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbUser.BlockUserResp{}
|
resp := &pbUser.BlockUserResp{CommonResp: &pbUser.CommonResp{}}
|
||||||
err := imdb.BlockUser(req.UserId, req.EndDisableTime)
|
err := imdb.BlockUser(req.UserID, req.EndDisableTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BlockUser", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BlockUser", err.Error(), req.UserID, req.EndDisableTime)
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) UnBlockUser(ctx context.Context, req *pbUser.UnBlockUserReq) (*pbUser.UnBlockUserResp, error) {
|
func (s *userServer) UnBlockUser(ctx context.Context, req *pbUser.UnBlockUserReq) (*pbUser.UnBlockUserResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbUser.UnBlockUserResp{}
|
resp := &pbUser.UnBlockUserResp{CommonResp: &pbUser.CommonResp{}}
|
||||||
err := imdb.UnBlockUser(req.UserId)
|
err := imdb.UnBlockUser(req.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "unBlockUser", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "unBlockUser", err.Error())
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp.String())
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUsersReq) (*pbUser.GetBlockUsersResp, error) {
|
func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUsersReq) (resp *pbUser.GetBlockUsersResp, err error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||||
resp := &pbUser.GetBlockUsersResp{}
|
resp = &pbUser.GetBlockUsersResp{CommonResp: &pbUser.CommonResp{}, Pagination: &sdkws.ResponsePagination{ShowNumber: req.Pagination.ShowNumber, CurrentPage: req.Pagination.PageNumber}}
|
||||||
blockUsers, err := imdb.GetBlockUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
var blockUsers []imdb.BlockUserInfo
|
||||||
|
if req.UserID != "" {
|
||||||
|
blockUser, err := imdb.GetBlockUserByID(req.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(req.OperationID, utils.GetSelfFuncName(), "GetBlockUsers", err.Error())
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
return resp, nil
|
||||||
|
}
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error(), req.UserID)
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
blockUsers = append(blockUsers, blockUser)
|
||||||
|
resp.UserNums = 1
|
||||||
|
} else {
|
||||||
|
blockUsers, err = imdb.GetBlockUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(req.OperationID, utils.GetSelfFuncName(), "GetBlockUsers", err.Error(), req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
nums, err := imdb.GetBlockUsersNumCount()
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetBlockUsersNumCount failed", err.Error())
|
||||||
|
resp.CommonResp.ErrCode = constant.ErrDB.ErrCode
|
||||||
|
resp.CommonResp.ErrMsg = err.Error()
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
resp.UserNums = nums
|
||||||
}
|
}
|
||||||
for _, v := range blockUsers {
|
for _, v := range blockUsers {
|
||||||
resp.BlockUsers = append(resp.BlockUsers, &pbUser.BlockUser{
|
resp.BlockUsers = append(resp.BlockUsers, &pbUser.BlockUser{
|
||||||
User: &pbUser.User{
|
UserInfo: &sdkws.UserInfo{
|
||||||
ProfilePhoto: v.User.FaceURL,
|
FaceURL: v.User.FaceURL,
|
||||||
Nickname: v.User.Nickname,
|
Nickname: v.User.Nickname,
|
||||||
UserId: v.User.UserID,
|
UserID: v.User.UserID,
|
||||||
IsBlock: true,
|
|
||||||
Birth: v.User.Birth.Format("2006-01-02"),
|
|
||||||
PhoneNumber: v.User.PhoneNumber,
|
PhoneNumber: v.User.PhoneNumber,
|
||||||
Email: v.User.Email,
|
Email: v.User.Email,
|
||||||
Gender: v.User.Gender,
|
Gender: v.User.Gender,
|
||||||
@ -788,51 +701,6 @@ func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUser
|
|||||||
EndDisableTime: (v.EndDisableTime).String(),
|
EndDisableTime: (v.EndDisableTime).String(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
resp.Pagination = &sdkws.ResponsePagination{}
|
|
||||||
resp.Pagination.ShowNumber = req.Pagination.ShowNumber
|
|
||||||
resp.Pagination.CurrentPage = req.Pagination.PageNumber
|
|
||||||
nums, err := imdb.GetBlockUsersNumCount()
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetBlockUsersNumCount failed", err.Error())
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
resp.UserNums = nums
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) GetBlockUserById(_ context.Context, req *pbUser.GetBlockUserByIdReq) (*pbUser.GetBlockUserByIdResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
|
||||||
resp := &pbUser.GetBlockUserByIdResp{}
|
|
||||||
user, err := imdb.GetBlockUserById(req.UserId)
|
|
||||||
if err != nil {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetBlockUserById", err)
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
resp.BlockUser = &pbUser.BlockUser{
|
|
||||||
User: &pbUser.User{
|
|
||||||
ProfilePhoto: user.User.FaceURL,
|
|
||||||
Nickname: user.User.Nickname,
|
|
||||||
UserId: user.User.UserID,
|
|
||||||
IsBlock: true,
|
|
||||||
Birth: user.User.Birth.Format("2006-01-02"),
|
|
||||||
PhoneNumber: user.User.PhoneNumber,
|
|
||||||
Email: user.User.Email,
|
|
||||||
Gender: user.User.Gender,
|
|
||||||
},
|
|
||||||
BeginDisableTime: (user.BeginDisableTime).String(),
|
|
||||||
EndDisableTime: (user.EndDisableTime).String(),
|
|
||||||
}
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", req.String())
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *userServer) DeleteUser(_ context.Context, req *pbUser.DeleteUserReq) (*pbUser.DeleteUserResp, error) {
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req.String())
|
|
||||||
resp := &pbUser.DeleteUserResp{}
|
|
||||||
if row := imdb.DeleteUser(req.UserId); row == 0 {
|
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "delete failed", "delete rows:", row)
|
|
||||||
return resp, errors.WrapError(constant.ErrDB)
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
75
internal/utils/local_cache.go
Normal file
75
internal/utils/local_cache.go
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"Open_IM/pkg/common/config"
|
||||||
|
rocksCache "Open_IM/pkg/common/db/rocks_cache"
|
||||||
|
"Open_IM/pkg/common/log"
|
||||||
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
|
pbCache "Open_IM/pkg/proto/cache"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GroupMemberUserIDListHash struct {
|
||||||
|
MemberListHash uint64
|
||||||
|
UserIDList []string
|
||||||
|
}
|
||||||
|
|
||||||
|
var CacheGroupMemberUserIDList = make(map[string]*GroupMemberUserIDListHash, 0)
|
||||||
|
var CacheGroupMtx sync.RWMutex
|
||||||
|
|
||||||
|
func GetGroupMemberUserIDList(groupID string, operationID string) ([]string, error) {
|
||||||
|
groupHashRemote, err := GetGroupMemberUserIDListHashFromRemote(groupID)
|
||||||
|
if err != nil {
|
||||||
|
CacheGroupMtx.Lock()
|
||||||
|
defer CacheGroupMtx.Unlock()
|
||||||
|
delete(CacheGroupMemberUserIDList, groupID)
|
||||||
|
log.Error(operationID, "GetGroupMemberUserIDListHashFromRemote failed ", err.Error(), groupID)
|
||||||
|
return nil, utils.Wrap(err, groupID)
|
||||||
|
}
|
||||||
|
|
||||||
|
CacheGroupMtx.Lock()
|
||||||
|
defer CacheGroupMtx.Unlock()
|
||||||
|
groupInLocalCache, ok := CacheGroupMemberUserIDList[groupID]
|
||||||
|
if ok && groupInLocalCache.MemberListHash == groupHashRemote {
|
||||||
|
log.Debug(operationID, "in local cache ", groupID)
|
||||||
|
return groupInLocalCache.UserIDList, nil
|
||||||
|
}
|
||||||
|
log.Debug(operationID, "not in local cache or hash changed", groupID, " remote hash ", groupHashRemote, " in cache ", ok)
|
||||||
|
memberUserIDListRemote, err := GetGroupMemberUserIDListFromRemote(groupID, operationID)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(operationID, "GetGroupMemberUserIDListFromRemote failed ", err.Error(), groupID)
|
||||||
|
return nil, utils.Wrap(err, groupID)
|
||||||
|
}
|
||||||
|
CacheGroupMemberUserIDList[groupID] = &GroupMemberUserIDListHash{MemberListHash: groupHashRemote, UserIDList: memberUserIDListRemote}
|
||||||
|
return memberUserIDListRemote, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetGroupMemberUserIDListHashFromRemote(groupID string) (uint64, error) {
|
||||||
|
return rocksCache.GetGroupMemberListHashFromCache(groupID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetGroupMemberUserIDListFromRemote(groupID string, operationID string) ([]string, error) {
|
||||||
|
getGroupMemberIDListFromCacheReq := &pbCache.GetGroupMemberIDListFromCacheReq{OperationID: operationID, GroupID: groupID}
|
||||||
|
etcdConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImCacheName, operationID)
|
||||||
|
if etcdConn == nil {
|
||||||
|
errMsg := operationID + "getcdv3.GetDefaultConn == nil"
|
||||||
|
log.NewError(operationID, errMsg)
|
||||||
|
return nil, errors.New("errMsg")
|
||||||
|
}
|
||||||
|
client := pbCache.NewCacheClient(etcdConn)
|
||||||
|
cacheResp, err := client.GetGroupMemberIDListFromCache(context.Background(), getGroupMemberIDListFromCacheReq)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(operationID, "GetGroupMemberIDListFromCache rpc call failed ", err.Error())
|
||||||
|
return nil, utils.Wrap(err, "GetGroupMemberIDListFromCache rpc call failed")
|
||||||
|
}
|
||||||
|
if cacheResp.CommonResp.ErrCode != 0 {
|
||||||
|
errMsg := operationID + "GetGroupMemberIDListFromCache rpc logic call failed " + cacheResp.CommonResp.ErrMsg
|
||||||
|
log.NewError(operationID, errMsg)
|
||||||
|
return nil, errors.New("errMsg")
|
||||||
|
}
|
||||||
|
return cacheResp.UserIDList, nil
|
||||||
|
}
|
11
pkg/base_info/common.go
Normal file
11
pkg/base_info/common.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package base_info
|
||||||
|
|
||||||
|
type RequestPagination struct {
|
||||||
|
PageNumber int `json:"pageNumber" binding:"required"`
|
||||||
|
ShowNumber int `json:"showNumber" binding:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ResponsePagination struct {
|
||||||
|
CurrentPage int `json:"currentPage"`
|
||||||
|
ShowNumber int `json:"showNumber"`
|
||||||
|
}
|
@ -16,7 +16,7 @@ type CommDataResp struct {
|
|||||||
|
|
||||||
type KickGroupMemberReq struct {
|
type KickGroupMemberReq struct {
|
||||||
GroupID string `json:"groupID" binding:"required"`
|
GroupID string `json:"groupID" binding:"required"`
|
||||||
KickedUserIDList []string `json:"kickedUserIDList" binding:"required"`
|
KickedUserIDList []string `json:"kickedUserIDList" binding:"required, min=1, max=100"`
|
||||||
Reason string `json:"reason"`
|
Reason string `json:"reason"`
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ type GetGroupMembersInfoResp struct {
|
|||||||
|
|
||||||
type InviteUserToGroupReq struct {
|
type InviteUserToGroupReq struct {
|
||||||
GroupID string `json:"groupID" binding:"required"`
|
GroupID string `json:"groupID" binding:"required"`
|
||||||
InvitedUserIDList []string `json:"invitedUserIDList" binding:"required"`
|
InvitedUserIDList []string `json:"invitedUserIDList" binding:"required, min=1, max=100"`
|
||||||
Reason string `json:"reason"`
|
Reason string `json:"reason"`
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
|
@ -93,3 +93,40 @@ type CheckMsgIsSendSuccessResp struct {
|
|||||||
CommResp
|
CommResp
|
||||||
Status int32 `json:"status"`
|
Status int32 `json:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetUsersReq struct {
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
UserName string `json:"userName"`
|
||||||
|
UserID string `json:"userID"`
|
||||||
|
Content string `json:"content"`
|
||||||
|
PageNumber int32 `json:"pageNumber" binding:"required"`
|
||||||
|
ShowNumber int32 `json:"showNumber" binding:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CMSUser struct {
|
||||||
|
UserID string `json:"userID"`
|
||||||
|
Nickname string `json:"nickname"`
|
||||||
|
FaceURL string `json:"faceURL"`
|
||||||
|
Gender int32 `json:"gender"`
|
||||||
|
PhoneNumber string `json:"phoneNumber"`
|
||||||
|
Birth uint32 `json:"birth"`
|
||||||
|
Email string `json:"email"`
|
||||||
|
Ex string `json:"ex"`
|
||||||
|
CreateIp string `json:"createIp"`
|
||||||
|
CreateTime uint32 `json:"createTime"`
|
||||||
|
LastLoginIp string `json:"LastLoginIp"`
|
||||||
|
LastLoginTime uint32 `json:"LastLoginTime"`
|
||||||
|
AppMangerLevel int32 `json:"appMangerLevel"`
|
||||||
|
GlobalRecvMsgOpt int32 `json:"globalRecvMsgOpt"`
|
||||||
|
IsBlock bool `json:"isBlock"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetUsersResp struct {
|
||||||
|
CommResp
|
||||||
|
Data struct {
|
||||||
|
UserList []*CMSUser `json:"userList"`
|
||||||
|
TotalNum int32 `json:"totalNum"`
|
||||||
|
CurrentPage int32 `json:"currentPage"`
|
||||||
|
ShowNumber int32 `json:"showNumber"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
@ -14,14 +14,9 @@ type ApiUserInfo struct {
|
|||||||
PhoneNumber string `json:"phoneNumber" binding:"omitempty,max=32"`
|
PhoneNumber string `json:"phoneNumber" binding:"omitempty,max=32"`
|
||||||
Birth uint32 `json:"birth" binding:"omitempty"`
|
Birth uint32 `json:"birth" binding:"omitempty"`
|
||||||
Email string `json:"email" binding:"omitempty,max=64"`
|
Email string `json:"email" binding:"omitempty,max=64"`
|
||||||
CreateIp string `json:"createIp" binding:"omitempty,max=15"`
|
|
||||||
CreateTime int64 `json:"createTime"`
|
CreateTime int64 `json:"createTime"`
|
||||||
LastLoginIp string `json:"LastLoginIp" binding:"omitempty,max=15"`
|
|
||||||
LastLoginTime int64 `json:"lastLoginTime"`
|
|
||||||
LoginTimes int32 `json:"loginTimes" binding:"omitempty"`
|
|
||||||
LoginLimit int32 `json:"loginLimit" binding:"omitempty"`
|
LoginLimit int32 `json:"loginLimit" binding:"omitempty"`
|
||||||
Ex string `json:"ex" binding:"omitempty,max=1024"`
|
Ex string `json:"ex" binding:"omitempty,max=1024"`
|
||||||
InvitationCode string `json:"invitationCode" binding:"omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//type Conversation struct {
|
//type Conversation struct {
|
||||||
|
@ -112,3 +112,12 @@ type FcmUpdateTokenReq struct {
|
|||||||
type FcmUpdateTokenResp struct {
|
type FcmUpdateTokenResp struct {
|
||||||
CommResp
|
CommResp
|
||||||
}
|
}
|
||||||
|
type SetAppBadgeReq struct {
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
FromUserID string `json:"fromUserID" binding:"required"`
|
||||||
|
AppUnreadCount int32 `json:"appUnreadCount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SetAppBadgeResp struct {
|
||||||
|
CommResp
|
||||||
|
}
|
||||||
|
@ -5,6 +5,7 @@ import commonPb "Open_IM/pkg/proto/sdk_ws"
|
|||||||
type CallbackBeforePushReq struct {
|
type CallbackBeforePushReq struct {
|
||||||
UserStatusBatchCallbackReq
|
UserStatusBatchCallbackReq
|
||||||
*commonPb.OfflinePushInfo
|
*commonPb.OfflinePushInfo
|
||||||
|
ClientMsgID string `json:"clientMsgID"`
|
||||||
SendID string `json:"sendID"`
|
SendID string `json:"sendID"`
|
||||||
GroupID string `json:"groupID"`
|
GroupID string `json:"groupID"`
|
||||||
ContentType int32 `json:"contentType"`
|
ContentType int32 `json:"contentType"`
|
||||||
@ -22,6 +23,7 @@ type CallbackBeforePushResp struct {
|
|||||||
type CallbackBeforeSuperGroupOnlinePushReq struct {
|
type CallbackBeforeSuperGroupOnlinePushReq struct {
|
||||||
*commonPb.OfflinePushInfo
|
*commonPb.OfflinePushInfo
|
||||||
UserStatusBaseCallback
|
UserStatusBaseCallback
|
||||||
|
ClientMsgID string `json:"clientMsgID"`
|
||||||
SendID string `json:"sendID"`
|
SendID string `json:"sendID"`
|
||||||
GroupID string `json:"groupID"`
|
GroupID string `json:"groupID"`
|
||||||
ContentType int32 `json:"contentType"`
|
ContentType int32 `json:"contentType"`
|
||||||
|
@ -1,14 +1,20 @@
|
|||||||
package cms_api_struct
|
package cms_api_struct
|
||||||
|
|
||||||
import server_api_params "Open_IM/pkg/proto/sdk_ws"
|
import (
|
||||||
|
"Open_IM/pkg/base_info"
|
||||||
|
server_api_params "Open_IM/pkg/proto/sdk_ws"
|
||||||
|
)
|
||||||
|
|
||||||
type AdminLoginRequest struct {
|
type AdminLoginRequest struct {
|
||||||
AdminName string `json:"admin_name" binding:"required"`
|
AdminName string `json:"adminID" binding:"required"`
|
||||||
Secret string `json:"secret" binding:"required"`
|
Secret string `json:"secret" binding:"required"`
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AdminLoginResponse struct {
|
type AdminLoginResponse struct {
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
|
UserName string `json:"userName"`
|
||||||
|
FaceURL string `json:"faceURL"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AddUserRegisterAddFriendIDListRequest struct {
|
type AddUserRegisterAddFriendIDListRequest struct {
|
||||||
@ -30,10 +36,10 @@ type ReduceUserRegisterAddFriendIDListResponse struct {
|
|||||||
|
|
||||||
type GetUserRegisterAddFriendIDListRequest struct {
|
type GetUserRegisterAddFriendIDListRequest struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
RequestPaginationBody
|
base_info.RequestPagination
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetUserRegisterAddFriendIDListResponse struct {
|
type GetUserRegisterAddFriendIDListResponse struct {
|
||||||
Users []*server_api_params.UserInfo `json:"users"`
|
Users []*server_api_params.UserInfo `json:"users"`
|
||||||
ResponsePagination
|
base_info.ResponsePagination
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
package cms_api_struct
|
package cms_api_struct
|
||||||
|
|
||||||
type RequestPagination struct {
|
type RequestPagination struct {
|
||||||
PageNumber int `form:"page_number" binding:"required"`
|
|
||||||
ShowNumber int `form:"show_number" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type RequestPaginationBody struct {
|
|
||||||
PageNumber int `json:"pageNumber" binding:"required"`
|
PageNumber int `json:"pageNumber" binding:"required"`
|
||||||
ShowNumber int `json:"showNumber" binding:"required"`
|
ShowNumber int `json:"showNumber" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResponsePagination struct {
|
type ResponsePagination struct {
|
||||||
CurrentPage int `json:"current_number" binding:"required"`
|
CurrentPage int `json:"currentPage"`
|
||||||
ShowNumber int `json:"show_number" binding:"required"`
|
ShowNumber int `json:"showNumber"`
|
||||||
}
|
}
|
||||||
|
25
pkg/cms_api_struct/friend.go
Normal file
25
pkg/cms_api_struct/friend.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package cms_api_struct
|
||||||
|
|
||||||
|
type GetFriendsReq struct {
|
||||||
|
OperationID string `json:"operationID"`
|
||||||
|
UserID string `json:"userID"`
|
||||||
|
FriendUserName string `json:"friendUserName"`
|
||||||
|
FriendUserID string `json:"friendUserID"`
|
||||||
|
RequestPagination
|
||||||
|
}
|
||||||
|
|
||||||
|
type FriendInfo struct {
|
||||||
|
OwnerUserID string `json:"ownerUserID"`
|
||||||
|
Remark string `json:"remark"`
|
||||||
|
CreateTime uint32 `json:"createTime"`
|
||||||
|
UserID string `json:"userID"`
|
||||||
|
Nickname string `json:"nickName"`
|
||||||
|
AddSource int32 `json:"addSource"`
|
||||||
|
OperatorUserID string `json:"operatorUserID"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetFriendsResp struct {
|
||||||
|
ResponsePagination
|
||||||
|
FriendInfoList []*FriendInfo `json:"friendInfoList"`
|
||||||
|
FriendNums int32 `json:"friendNums"`
|
||||||
|
}
|
@ -3,7 +3,6 @@ package cms_api_struct
|
|||||||
type GroupResponse struct {
|
type GroupResponse struct {
|
||||||
GroupOwnerName string `json:"GroupOwnerName"`
|
GroupOwnerName string `json:"GroupOwnerName"`
|
||||||
GroupOwnerID string `json:"GroupOwnerID"`
|
GroupOwnerID string `json:"GroupOwnerID"`
|
||||||
//*server_api_params.GroupInfo
|
|
||||||
GroupID string `json:"groupID"`
|
GroupID string `json:"groupID"`
|
||||||
GroupName string `json:"groupName"`
|
GroupName string `json:"groupName"`
|
||||||
Notification string `json:"notification"`
|
Notification string `json:"notification"`
|
||||||
@ -23,27 +22,11 @@ type GroupResponse struct {
|
|||||||
NotificationUserID string `json:"notificationUserID"`
|
NotificationUserID string `json:"notificationUserID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetGroupByIDRequest struct {
|
|
||||||
GroupID string `form:"groupID" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetGroupByIDResponse struct {
|
|
||||||
GroupResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetGroupRequest struct {
|
|
||||||
GroupName string `form:"groupName" binding:"required"`
|
|
||||||
RequestPagination
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetGroupResponse struct {
|
|
||||||
Groups []GroupResponse `json:"groups"`
|
|
||||||
GroupNums int `json:"groupNums"`
|
|
||||||
ResponsePagination
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetGroupsRequest struct {
|
type GetGroupsRequest struct {
|
||||||
RequestPagination
|
RequestPagination
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
GroupID string `json:"groupID"`
|
||||||
|
GroupName string `json:"groupName"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetGroupsResponse struct {
|
type GetGroupsResponse struct {
|
||||||
@ -52,55 +35,10 @@ type GetGroupsResponse struct {
|
|||||||
ResponsePagination
|
ResponsePagination
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateGroupRequest struct {
|
|
||||||
GroupName string `json:"groupName" binding:"required"`
|
|
||||||
GroupMasterId string `json:"groupOwnerID" binding:"required"`
|
|
||||||
GroupMembers []string `json:"groupMembers" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type CreateGroupResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type SetGroupMasterRequest struct {
|
|
||||||
GroupId string `json:"groupID" binding:"required"`
|
|
||||||
UserId string `json:"userID" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SetGroupMasterResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type SetGroupMemberRequest struct {
|
|
||||||
GroupId string `json:"groupID" binding:"required"`
|
|
||||||
UserId string `json:"userID" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SetGroupMemberRespones struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type BanGroupChatRequest struct {
|
|
||||||
GroupId string `json:"groupID" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type BanGroupChatResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type BanPrivateChatRequest struct {
|
|
||||||
GroupId string `json:"groupID" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type BanPrivateChatResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteGroupRequest struct {
|
|
||||||
GroupId string `json:"groupID" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteGroupResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetGroupMembersRequest struct {
|
type GetGroupMembersRequest struct {
|
||||||
GroupID string `form:"groupID" binding:"required"`
|
GroupID string `form:"groupID" binding:"required"`
|
||||||
UserName string `form:"userName"`
|
UserName string `form:"userName"`
|
||||||
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
RequestPagination
|
RequestPagination
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,41 +62,3 @@ type GetGroupMembersResponse struct {
|
|||||||
ResponsePagination
|
ResponsePagination
|
||||||
MemberNums int `json:"memberNums"`
|
MemberNums int `json:"memberNums"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GroupMemberRequest struct {
|
|
||||||
GroupId string `json:"groupID" binding:"required"`
|
|
||||||
Members []string `json:"members" binding:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GroupMemberOperateResponse struct {
|
|
||||||
Success []string `json:"success"`
|
|
||||||
Failed []string `json:"failed"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AddGroupMembersRequest struct {
|
|
||||||
GroupMemberRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type AddGroupMembersResponse struct {
|
|
||||||
GroupMemberOperateResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
type RemoveGroupMembersRequest struct {
|
|
||||||
GroupMemberRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
type RemoveGroupMembersResponse struct {
|
|
||||||
GroupMemberOperateResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
type AlterGroupInfoRequest struct {
|
|
||||||
GroupID string `json:"groupID"`
|
|
||||||
GroupName string `json:"groupName"`
|
|
||||||
Notification string `json:"notification"`
|
|
||||||
Introduction string `json:"introduction"`
|
|
||||||
ProfilePhoto string `json:"profilePhoto"`
|
|
||||||
GroupType int `json:"groupType"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AlterGroupInfoResponse struct {
|
|
||||||
}
|
|
||||||
|
@ -1,50 +1,48 @@
|
|||||||
package cms_api_struct
|
package cms_api_struct
|
||||||
|
|
||||||
type BroadcastRequest struct {
|
import (
|
||||||
Message string `json:"message"`
|
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||||
}
|
)
|
||||||
|
|
||||||
type BroadcastResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type MassSendMassageRequest struct {
|
|
||||||
Message string `json:"message"`
|
|
||||||
Users []string `json:"users"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type MassSendMassageResponse struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetChatLogsRequest struct {
|
|
||||||
SessionType int `form:"session_type"`
|
|
||||||
ContentType int `form:"content_type"`
|
|
||||||
Content string `form:"content"`
|
|
||||||
UserId string `form:"user_id"`
|
|
||||||
GroupId string `form:"group_id"`
|
|
||||||
Date string `form:"date"`
|
|
||||||
|
|
||||||
|
type GetChatLogsReq struct {
|
||||||
|
SessionType int `json:"sessionType"`
|
||||||
|
ContentType int `json:"contentType"`
|
||||||
|
Content string `json:"content"`
|
||||||
|
SendID string `json:"sendID"`
|
||||||
|
RecvID string `json:"recvID"`
|
||||||
|
GroupID string `json:"groupID"`
|
||||||
|
SendTime string `json:"sendTime"`
|
||||||
RequestPagination
|
RequestPagination
|
||||||
|
OperationID string `json:"operationID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChatLog struct {
|
type ChatLog struct {
|
||||||
SessionType int `json:"session_type"`
|
SendID string `json:"sendID,omitempty"`
|
||||||
ContentType int `json:"content_type"`
|
RecvID string `json:"recvID,omitempty"`
|
||||||
SenderNickName string `json:"sender_nick_name"`
|
GroupID string `json:"groupID,omitempty"`
|
||||||
SenderId string `json:"sender_id"`
|
ClientMsgID string `json:"clientMsgID,omitempty"`
|
||||||
SearchContent string `json:"search_content"`
|
ServerMsgID string `json:"serverMsgID,omitempty"`
|
||||||
WholeContent string `json:"whole_content"`
|
SenderPlatformID int32 `json:"senderPlatformID,omitempty"`
|
||||||
|
SenderNickname string `json:"senderNickname,omitempty"`
|
||||||
ReceiverNickName string `json:"receiver_nick_name,omitempty"`
|
SenderFaceURL string `json:"senderFaceURL,omitempty"`
|
||||||
ReceiverID string `json:"receiver_id,omitempty"`
|
SessionType int32 `json:"sessionType,omitempty"`
|
||||||
|
MsgFrom int32 `json:"msgFrom,omitempty"`
|
||||||
GroupName string `json:"group_name,omitempty"`
|
ContentType int32 `json:"contentType,omitempty"`
|
||||||
GroupId string `json:"group_id,omitempty"`
|
Content string `json:"content,omitempty"`
|
||||||
|
Seq uint32 `json:"seq,omitempty"`
|
||||||
Date string `json:"date"`
|
SendTime int64 `json:"sendTime,omitempty"`
|
||||||
|
CreateTime int64 `json:"createTime,omitempty"`
|
||||||
|
Status int32 `json:"status,omitempty"`
|
||||||
|
Options map[string]bool `json:"options,omitempty"`
|
||||||
|
OfflinePushInfo *pbCommon.OfflinePushInfo `json:"offlinePushInfo,omitempty"`
|
||||||
|
AtUserIDList []string `json:"atUserIDList,omitempty"`
|
||||||
|
MsgDataList []byte `json:"msgDataList,omitempty"`
|
||||||
|
AttachedInfo string `json:"attachedInfo,omitempty"`
|
||||||
|
Ex string `json:"ex,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetChatLogsResponse struct {
|
type GetChatLogsResp struct {
|
||||||
ChatLogs []ChatLog `json:"chat_logs"`
|
ChatLogs []*ChatLog `json:"chatLogs"`
|
||||||
ChatLogsNum int `json:"log_nums"`
|
ChatLogsNum int `json:"logNums"`
|
||||||
ResponsePagination
|
ResponsePagination
|
||||||
}
|
}
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
package cms_api_struct
|
|
||||||
|
|
||||||
type GetStaffsResponse struct {
|
|
||||||
StaffsList []struct {
|
|
||||||
ProfilePhoto string `json:"profile_photo"`
|
|
||||||
NickName string `json:"nick_name"`
|
|
||||||
StaffId int `json:"staff_id"`
|
|
||||||
Position string `json:"position"`
|
|
||||||
EntryTime string `json:"entry_time"`
|
|
||||||
} `json:"staffs_list"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetOrganizationsResponse struct {
|
|
||||||
OrganizationList []struct {
|
|
||||||
OrganizationId int `json:"organization_id"`
|
|
||||||
OrganizationName string `json:"organization_name"`
|
|
||||||
} `json:"organization_list"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SquadResponse struct {
|
|
||||||
SquadList []struct {
|
|
||||||
SquadId int `json:"squad_id"`
|
|
||||||
SquadName string `json:"squad_name"`
|
|
||||||
} `json:"squad_list"`
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user