Signed-off-by: kubbot & kubecub <3293172751ysy@gmail.com>pull/457/head
parent
2d41819008
commit
539e0fdfb6
@ -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
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,71 @@
|
||||
#more prometheus-compose.yml
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
evaluation_interval: 15s
|
||||
external_labels:
|
||||
monitor: 'openIM-monitor'
|
||||
|
||||
scrape_configs:
|
||||
- job_name: 'prometheus'
|
||||
static_configs:
|
||||
- targets: ['localhost:9091']
|
||||
|
||||
- job_name: 'openIM-server'
|
||||
metrics_path: /metrics
|
||||
static_configs:
|
||||
- targets: ['localhost:10002']
|
||||
labels:
|
||||
group: 'api'
|
||||
|
||||
- targets: ['localhost:20110']
|
||||
labels:
|
||||
group: 'user'
|
||||
|
||||
- targets: ['localhost:20120']
|
||||
labels:
|
||||
group: 'friend'
|
||||
|
||||
- targets: ['localhost:20130']
|
||||
labels:
|
||||
group: 'message'
|
||||
|
||||
- targets: ['localhost:20140']
|
||||
labels:
|
||||
group: 'msg-gateway'
|
||||
|
||||
- targets: ['localhost:20150']
|
||||
labels:
|
||||
group: 'group'
|
||||
|
||||
- targets: ['localhost:20160']
|
||||
labels:
|
||||
group: 'auth'
|
||||
|
||||
- targets: ['localhost:20170']
|
||||
labels:
|
||||
group: 'push'
|
||||
|
||||
- targets: ['localhost:20120']
|
||||
labels:
|
||||
group: 'friend'
|
||||
|
||||
|
||||
- targets: ['localhost:20230']
|
||||
labels:
|
||||
group: 'conversation'
|
||||
|
||||
|
||||
- targets: ['localhost:21400', 'localhost:21401', 'localhost:21402', 'localhost:21403']
|
||||
labels:
|
||||
group: 'msg-transfer'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
- job_name: 'node'
|
||||
scrape_interval: 8s
|
||||
static_configs:
|
||||
- targets: ['localhost:9100']
|
||||
|
@ -0,0 +1,34 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
NAME=open_im_api
|
||||
BIN_DIR=../../bin/
|
||||
|
||||
OS:= $(or $(os),linux)
|
||||
ARCH:=$(or $(arch),amd64)
|
||||
all: gotool build
|
||||
|
||||
ifeq ($(OS),windows)
|
||||
|
||||
BINARY_NAME=${NAME}.exe
|
||||
|
||||
else
|
||||
|
||||
BINARY_NAME=${NAME}
|
||||
|
||||
endif
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
install:build
|
||||
mv ${BINARY_NAME} ${BIN_DIR}
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
@ -0,0 +1,18 @@
|
||||
FROM ubuntu
|
||||
|
||||
WORKDIR /Open-IM-Server/bin
|
||||
|
||||
RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
|
||||
&&apt-get install net-tools
|
||||
#Non-interactive operation
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get install -y vim curl tzdata gawk
|
||||
#Time zone adjusted to East eighth District
|
||||
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||
COPY ./open_im_api ./
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
|
||||
|
||||
CMD ["./open_im_api","--port", "10002"]
|
@ -0,0 +1,83 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/internal/api"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
openKeeper "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry/zookeeper"
|
||||
)
|
||||
|
||||
func main() {
|
||||
apiCmd := cmd.NewApiCmd()
|
||||
apiCmd.AddPortFlag()
|
||||
apiCmd.AddApi(run)
|
||||
if err := apiCmd.Execute(); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func startPprof() {
|
||||
runtime.GOMAXPROCS(1)
|
||||
runtime.SetMutexProfileFraction(1)
|
||||
runtime.SetBlockProfileRate(1)
|
||||
if err := http.ListenAndServe(":6060", nil); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func run(port int) error {
|
||||
if port == 0 {
|
||||
return fmt.Errorf("port is empty")
|
||||
}
|
||||
rdb, err := cache.NewRedis()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("api start init discov client")
|
||||
var client discoveryregistry.SvcDiscoveryRegistry
|
||||
client, err = openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
|
||||
openKeeper.WithFreq(time.Hour), openKeeper.WithUserNameAndPassword(config.Config.Zookeeper.Username,
|
||||
config.Config.Zookeeper.Password), openKeeper.WithRoundRobin(), openKeeper.WithTimeout(10), openKeeper.WithLogger(log.NewZkLogger()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("api init discov client success")
|
||||
fmt.Println("api register public config to discov")
|
||||
if err := client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, config.EncodeConfig()); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("api register public config to discov success")
|
||||
router := api.NewGinRouter(client, rdb)
|
||||
fmt.Println("api init router success")
|
||||
var address string
|
||||
if config.Config.Api.ListenIP != "" {
|
||||
address = net.JoinHostPort(config.Config.Api.ListenIP, strconv.Itoa(port))
|
||||
} else {
|
||||
address = net.JoinHostPort("0.0.0.0", strconv.Itoa(port))
|
||||
}
|
||||
fmt.Println("start api server, address: ", address, ", OpenIM version: ", config.Version)
|
||||
log.ZInfo(context.Background(), "start server success", "address", address, "version", config.Version)
|
||||
go startPprof()
|
||||
err = router.Run(address)
|
||||
if err != nil {
|
||||
log.ZError(context.Background(), "api run failed ", err, "address", address)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
NAME=open_im_cmd_utils
|
||||
BIN_DIR=../../bin/
|
||||
|
||||
OS:= $(or $(os),linux)
|
||||
ARCH:=$(or $(arch),amd64)
|
||||
all: gotool build
|
||||
|
||||
ifeq ($(OS),windows)
|
||||
|
||||
BINARY_NAME=${NAME}.exe
|
||||
|
||||
else
|
||||
|
||||
BINARY_NAME=${NAME}
|
||||
|
||||
endif
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
install:build
|
||||
mv ${BINARY_NAME} ${BIN_DIR}
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
@ -0,0 +1,45 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
|
||||
)
|
||||
|
||||
func main() {
|
||||
msgUtilsCmd := cmd.NewMsgUtilsCmd("openIMCmdUtils", "openIM cmd utils", nil)
|
||||
getCmd := cmd.NewGetCmd()
|
||||
fixCmd := cmd.NewFixCmd()
|
||||
clearCmd := cmd.NewClearCmd()
|
||||
seqCmd := cmd.NewSeqCmd()
|
||||
msgCmd := cmd.NewMsgCmd()
|
||||
getCmd.AddCommand(seqCmd.GetSeqCmd(), msgCmd.GetMsgCmd())
|
||||
getCmd.AddSuperGroupIDFlag()
|
||||
getCmd.AddUserIDFlag()
|
||||
getCmd.AddBeginSeqFlag()
|
||||
getCmd.AddLimitFlag()
|
||||
// openIM get seq --userID=xxx
|
||||
// openIM get seq --superGroupID=xxx
|
||||
// openIM get msg --userID=xxx --beginSeq=100 --limit=10
|
||||
// openIM get msg --superGroupID=xxx --beginSeq=100 --limit=10
|
||||
|
||||
fixCmd.AddCommand(seqCmd.FixSeqCmd())
|
||||
fixCmd.AddSuperGroupIDFlag()
|
||||
fixCmd.AddUserIDFlag()
|
||||
fixCmd.AddFixAllFlag()
|
||||
// openIM fix seq --userID=xxx
|
||||
// openIM fix seq --superGroupID=xxx
|
||||
// openIM fix seq --fixAll
|
||||
|
||||
clearCmd.AddCommand(msgCmd.ClearMsgCmd())
|
||||
clearCmd.AddSuperGroupIDFlag()
|
||||
clearCmd.AddUserIDFlag()
|
||||
clearCmd.AddClearAllFlag()
|
||||
clearCmd.AddBeginSeqFlag()
|
||||
clearCmd.AddLimitFlag()
|
||||
// openIM clear msg --userID=xxx --beginSeq=100 --limit=10
|
||||
// openIM clear msg --superGroupID=xxx --beginSeq=100 --limit=10
|
||||
// openIM clear msg --clearAll
|
||||
msgUtilsCmd.AddCommand(&getCmd.Command, &fixCmd.Command, &clearCmd.Command)
|
||||
if err := msgUtilsCmd.Execute(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
NAME=open_im_cron_task
|
||||
BIN_DIR=../../bin/
|
||||
|
||||
OS:= $(or $(os),linux)
|
||||
ARCH:=$(or $(arch),amd64)
|
||||
all: gotool build
|
||||
|
||||
ifeq ($(OS),windows)
|
||||
|
||||
BINARY_NAME=${NAME}.exe
|
||||
|
||||
else
|
||||
|
||||
BINARY_NAME=${NAME}
|
||||
|
||||
endif
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
install:build
|
||||
mv ${BINARY_NAME} ${BIN_DIR}
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
@ -0,0 +1,18 @@
|
||||
FROM ubuntu
|
||||
|
||||
WORKDIR /Open-IM-Server/bin
|
||||
|
||||
RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
|
||||
&&apt-get install net-tools
|
||||
#Non-interactive operation
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get install -y vim curl tzdata gawk
|
||||
#Time zone adjusted to East eighth District
|
||||
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||
COPY ./open_im_cron_task ./
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
|
||||
|
||||
CMD ["./open_im_cron_task"]
|
@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/internal/tools"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cronTaskCmd := cmd.NewCronTaskCmd()
|
||||
if err := cronTaskCmd.Exec(tools.StartCronTask); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
NAME=open_im_msg_gateway
|
||||
BIN_DIR=../../bin/
|
||||
|
||||
OS:= $(or $(os),linux)
|
||||
ARCH:=$(or $(arch),amd64)
|
||||
all: gotool build
|
||||
|
||||
ifeq ($(OS),windows)
|
||||
|
||||
BINARY_NAME=${NAME}.exe
|
||||
|
||||
else
|
||||
|
||||
BINARY_NAME=${NAME}
|
||||
|
||||
endif
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
install:build
|
||||
mv ${BINARY_NAME} ${BIN_DIR}
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
||||
|
@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
|
||||
)
|
||||
|
||||
func main() {
|
||||
msgGatewayCmd := cmd.NewMsgGatewayCmd()
|
||||
msgGatewayCmd.AddWsPortFlag()
|
||||
msgGatewayCmd.AddPortFlag()
|
||||
msgGatewayCmd.AddPrometheusPortFlag()
|
||||
if err := msgGatewayCmd.Exec(); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
NAME=open_im_msg_transfer
|
||||
BIN_DIR=../../bin/
|
||||
|
||||
OS:= $(or $(os),linux)
|
||||
ARCH:=$(or $(arch),amd64)
|
||||
all: gotool build
|
||||
|
||||
ifeq ($(OS),windows)
|
||||
|
||||
BINARY_NAME=${NAME}.exe
|
||||
|
||||
else
|
||||
|
||||
BINARY_NAME=${NAME}
|
||||
|
||||
endif
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
install:build
|
||||
mv ${BINARY_NAME} ${BIN_DIR}
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
@ -0,0 +1,18 @@
|
||||
FROM ubuntu
|
||||
|
||||
WORKDIR /Open-IM-Server/bin
|
||||
|
||||
RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
|
||||
&&apt-get install net-tools
|
||||
#Non-interactive operation
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get install -y vim curl tzdata gawk
|
||||
#Time zone adjusted to East eighth District
|
||||
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||
COPY ./open_im_msg_transfer ./
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
|
||||
|
||||
CMD ["./open_im_msg_transfer","--prometheus_port", "21400"]
|
@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
|
||||
)
|
||||
|
||||
func main() {
|
||||
msgTransferCmd := cmd.NewMsgTransferCmd()
|
||||
msgTransferCmd.AddPrometheusPortFlag()
|
||||
if err := msgTransferCmd.Exec(); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_api
|
||||
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,188 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
apiAuth "Open_IM/internal/api/auth"
|
||||
apiChat "Open_IM/internal/api/chat"
|
||||
"Open_IM/internal/api/conversation"
|
||||
"Open_IM/internal/api/friend"
|
||||
"Open_IM/internal/api/group"
|
||||
"Open_IM/internal/api/manage"
|
||||
"Open_IM/internal/api/office"
|
||||
"Open_IM/internal/api/organization"
|
||||
apiThird "Open_IM/internal/api/third"
|
||||
"Open_IM/internal/api/user"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/utils"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
//"syscall"
|
||||
"Open_IM/pkg/common/constant"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("api start ")
|
||||
log.NewPrivateLog(constant.LogFileName)
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
f, _ := os.Create("../logs/api.log")
|
||||
gin.DefaultWriter = io.MultiWriter(f)
|
||||
gin.SetMode(gin.DebugMode)
|
||||
r := gin.Default()
|
||||
r.Use(utils.CorsHandler())
|
||||
log.Info("load config: ", config.Config)
|
||||
// user routing group, which handles user registration and login services
|
||||
userRouterGroup := r.Group("/user")
|
||||
{
|
||||
userRouterGroup.POST("/update_user_info", user.UpdateUserInfo) //1
|
||||
userRouterGroup.POST("/get_users_info", user.GetUsersInfo) //1
|
||||
userRouterGroup.POST("/get_self_user_info", user.GetSelfUserInfo) //1
|
||||
userRouterGroup.POST("/get_users_online_status", user.GetUsersOnlineStatus) //1
|
||||
userRouterGroup.POST("/get_users_info_from_cache", user.GetUsersInfoFromCache)
|
||||
}
|
||||
//friend routing group
|
||||
friendRouterGroup := r.Group("/friend")
|
||||
{
|
||||
// friendRouterGroup.POST("/get_friends_info", friend.GetFriendsInfo)
|
||||
friendRouterGroup.POST("/add_friend", friend.AddFriend) //1
|
||||
friendRouterGroup.POST("/delete_friend", friend.DeleteFriend) //1
|
||||
friendRouterGroup.POST("/get_friend_apply_list", friend.GetFriendApplyList) //1
|
||||
friendRouterGroup.POST("/get_self_friend_apply_list", friend.GetSelfFriendApplyList) //1
|
||||
friendRouterGroup.POST("/get_friend_list", friend.GetFriendList) //1
|
||||
friendRouterGroup.POST("/add_friend_response", friend.AddFriendResponse) //1
|
||||
friendRouterGroup.POST("/set_friend_remark", friend.SetFriendRemark) //1
|
||||
|
||||
friendRouterGroup.POST("/add_black", friend.AddBlack) //1
|
||||
friendRouterGroup.POST("/get_black_list", friend.GetBlacklist) //1
|
||||
friendRouterGroup.POST("/remove_black", friend.RemoveBlack) //1
|
||||
|
||||
friendRouterGroup.POST("/import_friend", friend.ImportFriend) //1
|
||||
friendRouterGroup.POST("/is_friend", friend.IsFriend) //1
|
||||
}
|
||||
//group related routing group
|
||||
groupRouterGroup := r.Group("/group")
|
||||
{
|
||||
groupRouterGroup.POST("/create_group", group.CreateGroup) //1
|
||||
groupRouterGroup.POST("/set_group_info", group.SetGroupInfo) //1
|
||||
groupRouterGroup.POST("join_group", group.JoinGroup) //1
|
||||
groupRouterGroup.POST("/quit_group", group.QuitGroup) //1
|
||||
groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse) //1
|
||||
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner) //1
|
||||
groupRouterGroup.POST("/get_recv_group_applicationList", group.GetRecvGroupApplicationList) //1
|
||||
groupRouterGroup.POST("/get_user_req_group_applicationList", group.GetUserReqGroupApplicationList)
|
||||
groupRouterGroup.POST("/get_groups_info", group.GetGroupsInfo) //1
|
||||
groupRouterGroup.POST("/kick_group", group.KickGroupMember) //1
|
||||
groupRouterGroup.POST("/get_group_member_list", group.GetGroupMemberList) //no use
|
||||
groupRouterGroup.POST("/get_group_all_member_list", group.GetGroupAllMemberList) //1
|
||||
groupRouterGroup.POST("/get_group_members_info", group.GetGroupMembersInfo) //1
|
||||
groupRouterGroup.POST("/invite_user_to_group", group.InviteUserToGroup) //1
|
||||
groupRouterGroup.POST("/get_joined_group_list", group.GetJoinedGroupList) //1
|
||||
groupRouterGroup.POST("/dismiss_group", group.DismissGroup) //
|
||||
groupRouterGroup.POST("/mute_group_member", group.MuteGroupMember)
|
||||
groupRouterGroup.POST("/cancel_mute_group_member", group.CancelMuteGroupMember) //MuteGroup
|
||||
groupRouterGroup.POST("/mute_group", group.MuteGroup)
|
||||
groupRouterGroup.POST("/cancel_mute_group", group.CancelMuteGroup)
|
||||
|
||||
groupRouterGroup.POST("/set_group_member_nickname", group.SetGroupMemberNickname)
|
||||
|
||||
}
|
||||
//certificate
|
||||
authRouterGroup := r.Group("/auth")
|
||||
{
|
||||
authRouterGroup.POST("/user_register", apiAuth.UserRegister) //1
|
||||
authRouterGroup.POST("/user_token", apiAuth.UserToken) //1
|
||||
authRouterGroup.POST("/parse_token", apiAuth.ParseToken) //1
|
||||
}
|
||||
//Third service
|
||||
thirdGroup := r.Group("/third")
|
||||
{
|
||||
thirdGroup.POST("/tencent_cloud_storage_credential", apiThird.TencentCloudStorageCredential)
|
||||
thirdGroup.POST("/ali_oss_credential", apiThird.AliOSSCredential)
|
||||
thirdGroup.POST("/minio_storage_credential", apiThird.MinioStorageCredential)
|
||||
thirdGroup.POST("/minio_upload", apiThird.MinioUploadFile)
|
||||
thirdGroup.POST("/upload_update_app", apiThird.UploadUpdateApp)
|
||||
thirdGroup.POST("/get_download_url", apiThird.GetDownloadURL)
|
||||
}
|
||||
//Message
|
||||
chatGroup := r.Group("/msg")
|
||||
{
|
||||
chatGroup.POST("/newest_seq", apiChat.GetSeq)
|
||||
chatGroup.POST("/send_msg", apiChat.SendMsg)
|
||||
chatGroup.POST("/pull_msg_by_seq", apiChat.PullMsgBySeqList)
|
||||
chatGroup.POST("/del_msg", apiChat.DelMsg)
|
||||
}
|
||||
//Manager
|
||||
managementGroup := r.Group("/manager")
|
||||
{
|
||||
managementGroup.POST("/delete_user", manage.DeleteUser) //1
|
||||
managementGroup.POST("/send_msg", manage.ManagementSendMsg)
|
||||
managementGroup.POST("/batch_send_msg", manage.ManagementBatchSendMsg)
|
||||
managementGroup.POST("/get_all_users_uid", manage.GetAllUsersUid) //1
|
||||
managementGroup.POST("/account_check", manage.AccountCheck) //1
|
||||
managementGroup.POST("/get_users_online_status", manage.GetUsersOnlineStatus) //1
|
||||
}
|
||||
//Conversation
|
||||
conversationGroup := r.Group("/conversation")
|
||||
{ //1
|
||||
conversationGroup.POST("/get_all_conversations", conversation.GetAllConversations)
|
||||
conversationGroup.POST("/get_conversation", conversation.GetConversation)
|
||||
conversationGroup.POST("/get_conversations", conversation.GetConversations)
|
||||
conversationGroup.POST("/set_conversation", conversation.SetConversation)
|
||||
conversationGroup.POST("/batch_set_conversation", conversation.BatchSetConversations)
|
||||
conversationGroup.POST("/set_recv_msg_opt", conversation.SetRecvMsgOpt)
|
||||
conversationGroup.POST("/modify_conversation_field", conversation.ModifyConversationField)
|
||||
}
|
||||
// office
|
||||
officeGroup := r.Group("/office")
|
||||
{
|
||||
officeGroup.POST("/get_user_tags", office.GetUserTags)
|
||||
officeGroup.POST("/get_user_tag_by_id", office.GetUserTagByID)
|
||||
officeGroup.POST("/create_tag", office.CreateTag)
|
||||
officeGroup.POST("/delete_tag", office.DeleteTag)
|
||||
officeGroup.POST("/set_tag", office.SetTag)
|
||||
officeGroup.POST("/send_msg_to_tag", office.SendMsg2Tag)
|
||||
officeGroup.POST("/get_send_tag_log", office.GetTagSendLogs)
|
||||
|
||||
officeGroup.POST("/create_one_work_moment", office.CreateOneWorkMoment)
|
||||
officeGroup.POST("/delete_one_work_moment", office.DeleteOneWorkMoment)
|
||||
officeGroup.POST("/like_one_work_moment", office.LikeOneWorkMoment)
|
||||
officeGroup.POST("/comment_one_work_moment", office.CommentOneWorkMoment)
|
||||
officeGroup.POST("/get_user_work_moments", office.GetUserWorkMoments)
|
||||
officeGroup.POST("/get_user_friend_work_moments", office.GetUserFriendWorkMoments)
|
||||
officeGroup.POST("/set_user_work_moments_level", office.SetUserWorkMomentsLevel)
|
||||
}
|
||||
|
||||
organizationGroup := r.Group("/organization")
|
||||
{
|
||||
organizationGroup.POST("/create_department", organization.CreateDepartment)
|
||||
organizationGroup.POST("/update_department", organization.UpdateDepartment)
|
||||
organizationGroup.POST("/get_sub_department", organization.GetSubDepartment)
|
||||
organizationGroup.POST("/delete_department", organization.DeleteDepartment)
|
||||
organizationGroup.POST("/get_all_department", organization.GetAllDepartment)
|
||||
|
||||
organizationGroup.POST("/create_organization_user", organization.CreateOrganizationUser)
|
||||
organizationGroup.POST("/update_organization_user", organization.UpdateOrganizationUser)
|
||||
organizationGroup.POST("/delete_organization_user", organization.DeleteOrganizationUser)
|
||||
|
||||
organizationGroup.POST("/create_department_member", organization.CreateDepartmentMember)
|
||||
organizationGroup.POST("/get_user_in_department", organization.GetUserInDepartment)
|
||||
organizationGroup.POST("/update_user_in_department", organization.UpdateUserInDepartment)
|
||||
|
||||
organizationGroup.POST("/get_department_member", organization.GetDepartmentMember)
|
||||
organizationGroup.POST("/delete_user_in_department", organization.DeleteUserInDepartment)
|
||||
organizationGroup.POST("/get_user_in_organization", organization.GetUserInOrganization)
|
||||
}
|
||||
|
||||
go apiThird.MinioInit()
|
||||
ginPort := flag.Int("port", 10000, "get ginServerPort from cmd,default 10000 as port")
|
||||
flag.Parse()
|
||||
fmt.Println("start api server, port: ", *ginPort)
|
||||
err := r.Run(":" + strconv.Itoa(*ginPort))
|
||||
if err != nil {
|
||||
log.Error("", "api run failed ", *ginPort, err.Error())
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_cms_api
|
||||
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,22 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/cms_api"
|
||||
"Open_IM/pkg/utils"
|
||||
"flag"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
router := cms_api.NewGinRouter()
|
||||
router.Use(utils.CorsHandler())
|
||||
ginPort := flag.Int("port", 8000, "get ginServerPort from cmd,default 10000 as port")
|
||||
fmt.Println("start cms api server, port: ", ginPort)
|
||||
router.Run(":" + strconv.Itoa(*ginPort))
|
||||
}
|
||||
|
||||
//
|
@ -1,25 +0,0 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_demo
|
||||
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,42 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/demo/register"
|
||||
"Open_IM/pkg/utils"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.NewPrivateLog(constant.LogFileName)
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
f, _ := os.Create("../logs/api.log")
|
||||
gin.DefaultWriter = io.MultiWriter(f)
|
||||
|
||||
r := gin.Default()
|
||||
r.Use(utils.CorsHandler())
|
||||
|
||||
authRouterGroup := r.Group("/auth")
|
||||
{
|
||||
authRouterGroup.POST("/code", register.SendVerificationCode)
|
||||
authRouterGroup.POST("/verify", register.Verify)
|
||||
authRouterGroup.POST("/password", register.SetPassword)
|
||||
authRouterGroup.POST("/login", register.Login)
|
||||
authRouterGroup.POST("/reset_password", register.ResetPassword)
|
||||
}
|
||||
|
||||
ginPort := flag.Int("port", 42233, "get ginServerPort from cmd,default 42233 as port")
|
||||
flag.Parse()
|
||||
fmt.Println("start demo api server, port: ", *ginPort)
|
||||
err := r.Run(":" + strconv.Itoa(*ginPort))
|
||||
if err != nil {
|
||||
log.Error("", "run failed ", *ginPort, err.Error())
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_msg_gateway
|
||||
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,23 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/msg_gateway/gate"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"flag"
|
||||
"fmt"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.NewPrivateLog(constant.LogFileName)
|
||||
rpcPort := flag.Int("rpc_port", 10400, "rpc listening port")
|
||||
wsPort := flag.Int("ws_port", 17778, "ws listening port")
|
||||
flag.Parse()
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
fmt.Println("start rpc/msg_gateway server, port: ", *rpcPort, *wsPort)
|
||||
gate.Init(*rpcPort, *wsPort)
|
||||
gate.Run()
|
||||
wg.Wait()
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_msg_transfer
|
||||
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,19 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/msg_transfer/logic"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"fmt"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
log.NewPrivateLog(constant.LogFileName)
|
||||
logic.Init()
|
||||
fmt.Println("start msg_transfer server")
|
||||
logic.Run()
|
||||
wg.Wait()
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_push
|
||||
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,22 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/push/logic"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"flag"
|
||||
"fmt"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcPort := flag.Int("port", 10700, "rpc listening port")
|
||||
flag.Parse()
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
log.NewPrivateLog(constant.LogFileName)
|
||||
fmt.Println("start push rpc server, port: ", *rpcPort)
|
||||
logic.Init(*rpcPort)
|
||||
logic.Run()
|
||||
wg.Wait()
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_timer_task
|
||||
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,63 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.NewPrivateLog(constant.LogFileName)
|
||||
//for {
|
||||
// fmt.Println("start delete mongodb expired record")
|
||||
// timeUnixBegin := time.Now().Unix()
|
||||
// count, _ := db.DB.MgoUserCount()
|
||||
// fmt.Println("mongodb record count: ", count)
|
||||
// for i := 0; i < count; i++ {
|
||||
// time.Sleep(1 * time.Millisecond)
|
||||
// uid, _ := db.DB.MgoSkipUID(i)
|
||||
// fmt.Println("operate uid: ", uid)
|
||||
// err := db.DB.DelUserChat(uid)
|
||||
// if err != nil {
|
||||
// fmt.Println("operate uid failed: ", uid, err.Error())
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// timeUnixEnd := time.Now().Unix()
|
||||
// costTime := timeUnixEnd - timeUnixBegin
|
||||
// if costTime > int64(config.Config.Mongo.DBRetainChatRecords*24*3600) {
|
||||
// continue
|
||||
// } else {
|
||||
// sleepTime := 0
|
||||
// if int64(config.Config.Mongo.DBRetainChatRecords*24*3600)-costTime > 24*3600 {
|
||||
// sleepTime = 24 * 3600
|
||||
// } else {
|
||||
// sleepTime = config.Config.Mongo.DBRetainChatRecords*24*3600 - int(costTime)
|
||||
// }
|
||||
// fmt.Println("sleep: ", sleepTime)
|
||||
// time.Sleep(time.Duration(sleepTime) * time.Second)
|
||||
// }
|
||||
//}
|
||||
//for {
|
||||
// uidList, err := im_mysql_model.SelectAllUserID()
|
||||
// if err != nil {
|
||||
// //log.NewError("999999", err.Error())
|
||||
// } else {
|
||||
// for _, v := range uidList {
|
||||
// minSeq, err := commonDB.DB.GetMinSeqFromMongo(v)
|
||||
// if err != nil {
|
||||
// //log.NewError("999999", "get user minSeq err", err.Error(), v)
|
||||
// continue
|
||||
// } else {
|
||||
// err := commonDB.DB.SetUserMinSeq(v, minSeq)
|
||||
// if err != nil {
|
||||
// //log.NewError("999999", "set user minSeq err", err.Error(), v)
|
||||
// }
|
||||
// }
|
||||
// time.Sleep(time.Duration(100) * time.Millisecond)
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
}
|
@ -1 +0,0 @@
|
||||
Subproject commit 4ce07f10e42ac2d6a6bc85a34f05c1ada6f4e5a3
|
@ -0,0 +1,34 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
NAME=open_im_push
|
||||
BIN_DIR=../../bin/
|
||||
|
||||
OS:= $(or $(os),linux)
|
||||
ARCH:=$(or $(arch),amd64)
|
||||
all: gotool build
|
||||
|
||||
ifeq ($(OS),windows)
|
||||
|
||||
BINARY_NAME=${NAME}.exe
|
||||
|
||||
else
|
||||
|
||||
BINARY_NAME=${NAME}
|
||||
|
||||
endif
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
install:build
|
||||
mv ${BINARY_NAME} ${BIN_DIR}
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
@ -0,0 +1,18 @@
|
||||
FROM ubuntu
|
||||
|
||||
WORKDIR /Open-IM-Server/bin
|
||||
|
||||
RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
|
||||
&&apt-get install net-tools
|
||||
#Non-interactive operation
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get install -y vim curl tzdata gawk
|
||||
#Time zone adjusted to East eighth District
|
||||
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||
COPY ./open_im_push ./
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
|
||||
|
||||
CMD ["./open_im_push", "--port", "10170", "--prometheus_port", "20170"]
|
@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/internal/push"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
pushCmd := cmd.NewRpcCmd("push")
|
||||
pushCmd.AddPortFlag()
|
||||
pushCmd.AddPrometheusPortFlag()
|
||||
if err := pushCmd.Exec(); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
if err := pushCmd.StartSvr(config.Config.RpcRegisterName.OpenImPushName, push.Start); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
FROM ubuntu
|
||||
|
||||
WORKDIR /Open-IM-Server/bin
|
||||
|
||||
RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
|
||||
&&apt-get install net-tools
|
||||
#Non-interactive operation
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get install -y vim curl tzdata gawk
|
||||
#Time zone adjusted to East eighth District
|
||||
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||
COPY ./open_im_auth ./
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
|
||||
|
||||
CMD ["./open_im_auth", "--port", "10160"]
|
@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/internal/rpc/auth"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
authCmd := cmd.NewRpcCmd("auth")
|
||||
authCmd.AddPortFlag()
|
||||
authCmd.AddPrometheusPortFlag()
|
||||
if err := authCmd.Exec(); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
if err := authCmd.StartSvr(config.Config.RpcRegisterName.OpenImAuthName, auth.Start); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
NAME=open_im_conversation
|
||||
BIN_DIR=../../../bin/
|
||||
|
||||
OS:= $(or $(os),linux)
|
||||
ARCH:=$(or $(arch),amd64)
|
||||
all: gotool build
|
||||
|
||||
ifeq ($(OS),windows)
|
||||
|
||||
BINARY_NAME=${NAME}.exe
|
||||
|
||||
else
|
||||
|
||||
BINARY_NAME=${NAME}
|
||||
|
||||
endif
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
install:build
|
||||
mv ${BINARY_NAME} ${BIN_DIR}
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
@ -0,0 +1,18 @@
|
||||
FROM ubuntu
|
||||
|
||||
WORKDIR /Open-IM-Server/bin
|
||||
|
||||
RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
|
||||
&&apt-get install net-tools
|
||||
#Non-interactive operation
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get install -y vim curl tzdata gawk
|
||||
#Time zone adjusted to East eighth District
|
||||
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||
COPY ./open_im_conversation ./
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
|
||||
|
||||
CMD ["./open_im_conversation", "--port", "10230", "--prometheus_port","20230"]
|
@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/internal/rpc/conversation"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcCmd := cmd.NewRpcCmd("conversation")
|
||||
rpcCmd.AddPortFlag()
|
||||
rpcCmd.AddPrometheusPortFlag()
|
||||
if err := rpcCmd.Exec(); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImConversationName, conversation.Start); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
NAME=open_im_friend
|
||||
BIN_DIR=../../../bin/
|
||||
|
||||
OS:= $(or $(os),linux)
|
||||
ARCH:=$(or $(arch),amd64)
|
||||
all: gotool build
|
||||
|
||||
ifeq ($(OS),windows)
|
||||
|
||||
BINARY_NAME=${NAME}.exe
|
||||
|
||||
else
|
||||
|
||||
BINARY_NAME=${NAME}
|
||||
|
||||
endif
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
install:build
|
||||
mv ${BINARY_NAME} ${BIN_DIR}
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
||||
|
||||
|
@ -0,0 +1,18 @@
|
||||
FROM ubuntu
|
||||
|
||||
WORKDIR /Open-IM-Server/bin
|
||||
|
||||
RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
|
||||
&&apt-get install net-tools
|
||||
#Non-interactive operation
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get install -y vim curl tzdata gawk
|
||||
#Time zone adjusted to East eighth District
|
||||
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||
COPY ./open_im_friend ./
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
|
||||
|
||||
CMD ["./open_im_friend", "--port", "10120", "--prometheus_port","20120"]
|
@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/internal/rpc/friend"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcCmd := cmd.NewRpcCmd("friend")
|
||||
rpcCmd.AddPortFlag()
|
||||
rpcCmd.AddPrometheusPortFlag()
|
||||
if err := rpcCmd.Exec(); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImFriendName, friend.Start); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
NAME=open_im_group
|
||||
BIN_DIR=../../../bin/
|
||||
|
||||
OS:= $(or $(os),linux)
|
||||
ARCH:=$(or $(arch),amd64)
|
||||
all: gotool build
|
||||
|
||||
ifeq ($(OS),windows)
|
||||
|
||||
BINARY_NAME=${NAME}.exe
|
||||
|
||||
else
|
||||
|
||||
BINARY_NAME=${NAME}
|
||||
|
||||
endif
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
install:build
|
||||
mv ${BINARY_NAME} ${BIN_DIR}
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,18 @@
|
||||
FROM ubuntu
|
||||
|
||||
WORKDIR /Open-IM-Server/bin
|
||||
|
||||
RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
|
||||
&&apt-get install net-tools
|
||||
#Non-interactive operation
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get install -y vim curl tzdata gawk
|
||||
#Time zone adjusted to East eighth District
|
||||
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||
COPY ./open_im_group ./
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
|
||||
|
||||
CMD ["./open_im_group", "--port", "10150", "--prometheus_port","20150"]
|
@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/internal/rpc/group"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcCmd := cmd.NewRpcCmd("group")
|
||||
rpcCmd.AddPortFlag()
|
||||
rpcCmd.AddPrometheusPortFlag()
|
||||
if err := rpcCmd.Exec(); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImGroupName, group.Start); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
FROM ubuntu
|
||||
|
||||
WORKDIR /Open-IM-Server/bin
|
||||
|
||||
RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
|
||||
&&apt-get install net-tools
|
||||
#Non-interactive operation
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get install -y vim curl tzdata gawk
|
||||
#Time zone adjusted to East eighth District
|
||||
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||
COPY ./open_im_msg ./
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
|
||||
|
||||
CMD ["./open_im_msg", "--port", "10130", "--prometheus_port","20130"]
|
@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/internal/rpc/msg"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcCmd := cmd.NewRpcCmd("msg")
|
||||
rpcCmd.AddPortFlag()
|
||||
rpcCmd.AddPrometheusPortFlag()
|
||||
if err := rpcCmd.Exec(); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImMsgName, msg.Start); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_admin_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,15 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
rpcMessageCMS "Open_IM/internal/rpc/admin_cms"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcPort := flag.Int("port", 11000, "rpc listening port")
|
||||
flag.Parse()
|
||||
fmt.Println("start cms rpc server, port: ", *rpcPort)
|
||||
rpcServer := rpcMessageCMS.NewAdminCMSServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_auth
|
||||
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,16 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
rpcAuth "Open_IM/internal/rpc/auth"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcPort := flag.Int("port", 10600, "RpcToken default listen port 10800")
|
||||
flag.Parse()
|
||||
fmt.Println("start auth rpc server, port: ", *rpcPort)
|
||||
rpcServer := rpcAuth.NewRpcAuthServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_conversation
|
||||
BIN_DIR=../../../bin/
|
||||
|
||||
all: gotool build
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
install:
|
||||
make build
|
||||
mv ${BINARY_NAME} ${BIN_DIR}
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
||||
|
@ -1,16 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
rpcConversation "Open_IM/internal/rpc/conversation"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcPort := flag.Int("port", 11400, "RpcConversation default listen port 11300")
|
||||
flag.Parse()
|
||||
fmt.Println("start conversation rpc server, port: ", *rpcPort)
|
||||
rpcServer := rpcConversation.NewRpcConversationServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_friend
|
||||
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,16 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/rpc/friend"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
rpcPort := flag.Int("port", 10200, "get RpcFriendPort from cmd,default 12000 as port")
|
||||
flag.Parse()
|
||||
fmt.Println("start friend rpc server, port: ", *rpcPort)
|
||||
rpcServer := friend.NewFriendServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/rpc/group"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcPort := flag.Int("port", 10500, "get RpcGroupPort from cmd,default 16000 as port")
|
||||
flag.Parse()
|
||||
fmt.Println("start group rpc server, port: ", *rpcPort)
|
||||
rpcServer := group.NewGroupServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
}
|
@ -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,15 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
rpcMessageCMS "Open_IM/internal/rpc/message_cms"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcPort := flag.Int("port", 10900, "rpc listening port")
|
||||
flag.Parse()
|
||||
fmt.Println("start msg cms rpc server, port: ", *rpcPort)
|
||||
rpcServer := rpcMessageCMS.NewMessageCMSServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_msg
|
||||
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,15 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
rpcChat "Open_IM/internal/rpc/msg"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcPort := flag.Int("port", 10300, "rpc listening port")
|
||||
flag.Parse()
|
||||
fmt.Println("start msg rpc server, port: ", *rpcPort)
|
||||
rpcServer := rpcChat.NewRpcChatServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_office
|
||||
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,15 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
rpc "Open_IM/internal/rpc/office"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcPort := flag.Int("port", 11100, "rpc listening port")
|
||||
flag.Parse()
|
||||
fmt.Println("start office rpc server, port: ", *rpcPort)
|
||||
rpcServer := rpc.NewOfficeServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/rpc/organization"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcPort := flag.Int("port", 11200, "get RpcOrganizationPort from cmd,default 11200 as port")
|
||||
flag.Parse()
|
||||
fmt.Println("start organization rpc server, port: ", *rpcPort)
|
||||
rpcServer := organization.NewServer(*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,15 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/rpc/statistics"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcPort := flag.Int("port", 10800, "rpc listening port")
|
||||
flag.Parse()
|
||||
fmt.Println("start statistics rpc server, port: ", *rpcPort)
|
||||
rpcServer := statistics.NewStatisticsServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
BINARY_NAME=open_im_user
|
||||
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,15 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/internal/rpc/user"
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcPort := flag.Int("port", 10100, "rpc listening port")
|
||||
flag.Parse()
|
||||
fmt.Println("start user rpc server, port: ", *rpcPort)
|
||||
rpcServer := user.NewUserServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
NAME=open_im_third
|
||||
BIN_DIR=../../../bin/
|
||||
|
||||
OS:= $(or $(os),linux)
|
||||
ARCH:=$(or $(arch),amd64)
|
||||
all: gotool build
|
||||
|
||||
ifeq ($(OS),windows)
|
||||
|
||||
BINARY_NAME=${NAME}.exe
|
||||
|
||||
else
|
||||
|
||||
BINARY_NAME=${NAME}
|
||||
|
||||
endif
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
install:build
|
||||
mv ${BINARY_NAME} ${BIN_DIR}
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,18 @@
|
||||
FROM ubuntu
|
||||
|
||||
WORKDIR /Open-IM-Server/bin
|
||||
|
||||
RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
|
||||
&&apt-get install net-tools
|
||||
#Non-interactive operation
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get install -y vim curl tzdata gawk
|
||||
#Time zone adjusted to East eighth District
|
||||
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||
COPY ./open_im_third ./
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
|
||||
|
||||
CMD ["./open_im_third", "--port", "10200"]
|
@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/internal/rpc/third"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcCmd := cmd.NewRpcCmd("third")
|
||||
rpcCmd.AddPortFlag()
|
||||
rpcCmd.AddPrometheusPortFlag()
|
||||
if err := rpcCmd.Exec(); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImThirdName, third.Start); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
.PHONY: all build run gotool install clean help
|
||||
|
||||
NAME=open_im_user
|
||||
BIN_DIR=../../../bin/
|
||||
|
||||
OS:= $(or $(os),linux)
|
||||
ARCH:=$(or $(arch),amd64)
|
||||
all: gotool build
|
||||
|
||||
ifeq ($(OS),windows)
|
||||
|
||||
BINARY_NAME=${NAME}.exe
|
||||
|
||||
else
|
||||
|
||||
BINARY_NAME=${NAME}
|
||||
|
||||
endif
|
||||
|
||||
build:
|
||||
CGO_ENABLED=0 GOOS=${OS} GOARCH=${ARCH}; go build -ldflags="-w -s" -o ${BINARY_NAME}
|
||||
|
||||
run:
|
||||
@go run ./
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
install:build
|
||||
mv ${BINARY_NAME} ${BIN_DIR}
|
||||
|
||||
clean:
|
||||
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,18 @@
|
||||
FROM ubuntu
|
||||
|
||||
WORKDIR /Open-IM-Server/bin
|
||||
|
||||
RUN apt-get update && apt-get install apt-transport-https && apt-get install procps\
|
||||
&&apt-get install net-tools
|
||||
#Non-interactive operation
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get install -y vim curl tzdata gawk
|
||||
#Time zone adjusted to East eighth District
|
||||
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get -qq install -y --no-install-recommends ca-certificates curl
|
||||
COPY ./open_im_user ./
|
||||
|
||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config"]
|
||||
|
||||
CMD ["./open_im_user", "--port", "10110"]
|
@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/internal/rpc/user"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/cmd"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcCmd := cmd.NewRpcCmd("user")
|
||||
rpcCmd.AddPortFlag()
|
||||
rpcCmd.AddPrometheusPortFlag()
|
||||
if err := rpcCmd.Exec(); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImUserName, user.Start); err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"fmt"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"time"
|
||||
)
|
||||
|
||||
type MongoMsg struct {
|
||||
UID string
|
||||
Msg []string
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
//"mongodb://%s:%s@%s/%s/?maxPoolSize=%d"
|
||||
uri := "mongodb://user:pass@sample.host:27017/?maxPoolSize=20&w=majority"
|
||||
DBAddress := "127.0.0.1:37017"
|
||||
DBDatabase := "new-test-db"
|
||||
Collection := "new-test-collection"
|
||||
DBMaxPoolSize := 100
|
||||
uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d",
|
||||
DBAddress,DBDatabase,
|
||||
DBMaxPoolSize)
|
||||
|
||||
mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
filter := bson.M{"uid":"my_uid"}
|
||||
ctx, _ := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
for i:=0; i < 2; i++{
|
||||
|
||||
if err = mongoClient.Database(DBDatabase).Collection(Collection).FindOneAndUpdate(ctx, filter,
|
||||
bson.M{"$push": bson.M{"msg": utils.Int32ToString(int32(i))}}).Err(); err != nil{
|
||||
fmt.Println("FindOneAndUpdate failed ", i, )
|
||||
var mmsg MongoMsg
|
||||
mmsg.UID = "my_uid"
|
||||
mmsg.Msg = append(mmsg.Msg, utils.Int32ToString(int32(i)))
|
||||
_, err := mongoClient.Database(DBDatabase).Collection(Collection).InsertOne(ctx, &mmsg)
|
||||
if err != nil {
|
||||
fmt.Println("insertone failed ", err.Error(), i)
|
||||
} else{
|
||||
fmt.Println("insertone ok ", i)
|
||||
}
|
||||
|
||||
}else {
|
||||
fmt.Println("FindOneAndUpdate ok ", i)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var mmsg MongoMsg
|
||||
|
||||
if err = mongoClient.Database(DBDatabase).Collection(Collection).FindOne(ctx, filter).Decode(&mmsg); err != nil {
|
||||
fmt.Println("findone failed ", err.Error())
|
||||
}else{
|
||||
fmt.Println("findone ok ", mmsg.UID)
|
||||
for i, v:=range mmsg.Msg{
|
||||
fmt.Println("find value: ", i, v)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,177 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Welcome to the Open-IM-Server installation script."
|
||||
echo "Please select an deploy option:"
|
||||
echo "1. docker-compose install"
|
||||
echo "2. exit"
|
||||
|
||||
clear_openimlog() {
|
||||
rm -rf ./logs/*
|
||||
}
|
||||
|
||||
is_path() {
|
||||
if [ -e "$1" ]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
is_empty() {
|
||||
if [ -z "$1" ]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
is_directory_exists() {
|
||||
if [ -d "$1" ]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
edit_config() {
|
||||
echo "Is edit config.yaml?"
|
||||
echo "1. vi edit config"
|
||||
echo "2. do not edit config"
|
||||
read choice
|
||||
case $choice in
|
||||
1)
|
||||
vi config/config.yaml
|
||||
;;
|
||||
2)
|
||||
echo "do not edit config"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
edit_enterprise_config() {
|
||||
echo "Is edit enterprise config.yaml?"
|
||||
echo "1. vi edit enterprise config"
|
||||
echo "2. do not edit enterprise config"
|
||||
read choice
|
||||
case $choice in
|
||||
1)
|
||||
vi ./.docker-compose_cfg/config.yaml
|
||||
;;
|
||||
2)
|
||||
echo "Do not edit enterprise config"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
install_docker_compose() {
|
||||
echo "Please input the installation path, default is $(pwd)/Open-IM-Server, press enter to use default"
|
||||
read install_path
|
||||
is_empty $install_path
|
||||
if [ $? -eq 1 ]; then
|
||||
install_path="."
|
||||
fi
|
||||
echo "Installing Open-IM-Server to ${install_path}/Open-IM-Server..."
|
||||
is_path $install_path
|
||||
mkdir -p $install_path
|
||||
cd $install_path
|
||||
is_directory_exists "${install_path}/Open-IM-Server"
|
||||
if [ $? -eq 1 ]; then
|
||||
echo "WARNING: Directory $install_path/Open-IM-Server exist, please ensure your path"
|
||||
echo "1. delete the directory and install"
|
||||
echo "2. exit"
|
||||
read choice
|
||||
case $choice in
|
||||
1)
|
||||
rm -rf "${install_path}/Open-IM-Server"
|
||||
;;
|
||||
2)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
rm -rf ./Open-IM-Server
|
||||
set -e
|
||||
git clone https://github.com/OpenIMSDK/Open-IM-Server.git --recursive;
|
||||
set +e
|
||||
cd ./Open-IM-Server
|
||||
git checkout errcode
|
||||
echo "======== git clone success ========"
|
||||
source .env
|
||||
if [ $DATA_DIR = "./" ]; then
|
||||
DATA_DIR=$(pwd)/components
|
||||
fi
|
||||
echo "Please input the components data directory, deault is ${DATA_DIR}, press enter to use default"
|
||||
read NEW_DATA_DIR
|
||||
is_empty $NEW_DATA_DIR
|
||||
if [ $? -eq 0 ]; then
|
||||
DATA_DIR=$NEW_DATA_DIR
|
||||
fi
|
||||
echo "Please input the user, deault is root, press enter to use default"
|
||||
read NEW_USER
|
||||
is_empty $NEW_USER
|
||||
if [ $? -eq 0 ]; then
|
||||
USER=$NEW_USER
|
||||
fi
|
||||
|
||||
echo "Please input the password, default is openIM123, press enter to use default"
|
||||
read NEW_PASSWORD
|
||||
is_empty $NEW_PASSWORD
|
||||
if [ $? -eq 0 ]; then
|
||||
PASSWORD=$NEW_PASSWORD
|
||||
fi
|
||||
|
||||
echo "Please input the minio_endpoint, default will detect auto, press enter to use default"
|
||||
read NEW_MINIO_ENDPOINT
|
||||
is_empty $NEW_MINIO_ENDPOINT
|
||||
if [ $? -eq 1 ]; then
|
||||
internet_ip=`curl ifconfig.me -s`
|
||||
MINIO_ENDPOINT="http://${internet_ip}:10005"
|
||||
else
|
||||
MINIO_ENDPOINT=$NEW_MINIO_ENDPOINT
|
||||
fi
|
||||
set -e
|
||||
export MINIO_ENDPOINT
|
||||
export USER
|
||||
export PASSWORD
|
||||
export DATA_DIR
|
||||
|
||||
cat <<EOF > .env
|
||||
USER=${USER}
|
||||
PASSWORD=${PASSWORD}
|
||||
MINIO_ENDPOINT=${MINIO_ENDPOINT}
|
||||
DATA_DIR=${DATA_DIR}
|
||||
EOF
|
||||
|
||||
edit_config
|
||||
edit_enterprise_config
|
||||
|
||||
cd script;
|
||||
chmod +x *.sh;
|
||||
./init_pwd.sh;
|
||||
./env_check.sh;
|
||||
cd ..;
|
||||
docker-compose up -d;
|
||||
cd script;
|
||||
./docker_check_service.sh;
|
||||
}
|
||||
|
||||
read choice
|
||||
|
||||
case $choice in
|
||||
1)
|
||||
install_docker_compose
|
||||
;;
|
||||
2)
|
||||
|
||||
;;
|
||||
3)
|
||||
;;
|
||||
4)
|
||||
echo "Exiting installation script..."
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Invalid option, please try again."
|
||||
;;
|
||||
esac
|
||||
|
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
internet_ip=`curl ifconfig.me -s`
|
||||
echo $internet_ip
|
||||
|
||||
source .env
|
||||
echo $MINIO_ENDPOINT
|
||||
if [ $MINIO_ENDPOINT == "http://127.0.0.1:10005" ]; then
|
||||
sed -i "s/127.0.0.1/${internet_ip}/" .env
|
||||
|
||||
fi
|
||||
|
||||
cd script ;
|
||||
chmod +x *.sh ;
|
||||
./init_pwd.sh
|
||||
./env_check.sh;
|
||||
cd .. ;
|
||||
docker-compose -f im-compose.yaml up -d
|
||||
docker ps
|
||||
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/auth"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type AuthApi rpcclient.Auth
|
||||
|
||||
func NewAuthApi(discov discoveryregistry.SvcDiscoveryRegistry) AuthApi {
|
||||
return AuthApi(*rpcclient.NewAuth(discov))
|
||||
}
|
||||
|
||||
func (o *AuthApi) UserToken(c *gin.Context) {
|
||||
a2r.Call(auth.AuthClient.UserToken, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *AuthApi) ParseToken(c *gin.Context) {
|
||||
a2r.Call(auth.AuthClient.ParseToken, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *AuthApi) ForceLogout(c *gin.Context) {
|
||||
a2r.Call(auth.AuthClient.ForceLogout, o.Client, c)
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
package apiAuth
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
rpc "Open_IM/pkg/proto/auth"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func UserRegister(c *gin.Context) {
|
||||
params := api.UserRegisterReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
errMsg := " BindJSON failed " + err.Error()
|
||||
log.NewError("0", errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
if params.Secret != config.Config.Secret {
|
||||
errMsg := " params.Secret != config.Config.Secret "
|
||||
log.NewError(params.OperationID, errMsg, params.Secret, config.Config.Secret)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
req := &rpc.UserRegisterReq{UserInfo: &open_im_sdk.UserInfo{}}
|
||||
utils.CopyStructFields(req.UserInfo, ¶ms)
|
||||
//copier.Copy(req.UserInfo, ¶ms)
|
||||
req.OperationID = params.OperationID
|
||||
log.NewInfo(req.OperationID, "UserRegister args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
|
||||
client := rpc.NewAuthClient(etcdConn)
|
||||
reply, err := client.UserRegister(context.Background(), req)
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " " + "client.UserRegister failed " + err.Error() + req.String()
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
if reply.CommonResp.ErrCode != 0 {
|
||||
errMsg := req.OperationID + " " + " client.UserRegister failed " + reply.CommonResp.ErrMsg + req.String()
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
pbDataToken := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}
|
||||
replyToken, err := client.UserToken(context.Background(), pbDataToken)
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " " + " client.UserToken failed " + err.Error() + pbDataToken.String()
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
resp := api.UserRegisterResp{CommResp: api.CommResp{ErrCode: replyToken.CommonResp.ErrCode, ErrMsg: replyToken.CommonResp.ErrMsg},
|
||||
UserToken: api.UserTokenInfo{UserID: req.UserInfo.UserID, Token: replyToken.Token, ExpiredTime: replyToken.ExpiredTime}}
|
||||
log.NewInfo(req.OperationID, "UserRegister return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
|
||||
}
|
||||
|
||||
func UserToken(c *gin.Context) {
|
||||
params := api.UserTokenReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
errMsg := " BindJSON failed " + err.Error()
|
||||
log.NewError("0", errMsg)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
|
||||
if params.Secret != config.Config.Secret {
|
||||
errMsg := params.OperationID + " params.Secret != config.Config.Secret "
|
||||
log.NewError(params.OperationID, "params.Secret != config.Config.Secret", params.Secret, config.Config.Secret)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
req := &rpc.UserTokenReq{Platform: params.Platform, FromUserID: params.UserID, OperationID: params.OperationID}
|
||||
log.NewInfo(req.OperationID, "UserToken args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
|
||||
client := rpc.NewAuthClient(etcdConn)
|
||||
reply, err := client.UserToken(context.Background(), req)
|
||||
if err != nil {
|
||||
errMsg := req.OperationID + " UserToken failed " + err.Error() + req.String()
|
||||
log.NewError(req.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
resp := api.UserTokenResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg},
|
||||
UserToken: api.UserTokenInfo{UserID: req.FromUserID, Token: reply.Token, ExpiredTime: reply.ExpiredTime}}
|
||||
log.NewInfo(req.OperationID, "UserToken return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
package apiChat
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
pbCommon "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func DelMsg(c *gin.Context) {
|
||||
var (
|
||||
req api.DelMsgReq
|
||||
resp api.DelMsgResp
|
||||
reqPb pbCommon.DelMsgListReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
msgClient := pbChat.NewChatClient(grpcConn)
|
||||
respPb, err := msgClient.DelMsgList(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsgList failed", err.Error(), reqPb)
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.ErrServer.ErrCode, "errMsg": constant.ErrServer.ErrMsg + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.ErrCode = respPb.ErrCode
|
||||
resp.ErrMsg = respPb.ErrMsg
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package apiChat
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbMsg "Open_IM/pkg/proto/chat"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsUserNewestSeq struct {
|
||||
ReqIdentifier int `json:"reqIdentifier" binding:"required"`
|
||||
SendID string `json:"sendID" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
MsgIncr int `json:"msgIncr" binding:"required"`
|
||||
}
|
||||
|
||||
func GetSeq(c *gin.Context) {
|
||||
params := paramsUserNewestSeq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
token := c.Request.Header.Get("token")
|
||||
if ok, err := token_verify.VerifyToken(token, params.SendID); !ok {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err" + err.Error()})
|
||||
return
|
||||
}
|
||||
pbData := pbMsg.GetMaxAndMinSeqReq{}
|
||||
pbData.UserID = params.SendID
|
||||
pbData.OperationID = params.OperationID
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
|
||||
if grpcConn == nil {
|
||||
log.ErrorByKv("get grpcConn err", pbData.OperationID, "args", params)
|
||||
}
|
||||
msgClient := pbMsg.NewChatClient(grpcConn)
|
||||
reply, err := msgClient.GetMaxAndMinSeq(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "UserGetSeq rpc failed, ", params, err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "UserGetSeq rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": reply.ErrCode,
|
||||
"errMsg": reply.ErrMsg,
|
||||
"msgIncr": params.MsgIncr,
|
||||
"reqIdentifier": params.ReqIdentifier,
|
||||
"data": gin.H{
|
||||
"maxSeq": reply.MaxSeq,
|
||||
"minSeq": reply.MinSeq,
|
||||
},
|
||||
})
|
||||
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
package apiChat
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"Open_IM/pkg/proto/msg"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsUserPullMsg struct {
|
||||
ReqIdentifier *int `json:"reqIdentifier" binding:"required"`
|
||||
SendID string `json:"sendID" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
Data struct {
|
||||
SeqBegin *int64 `json:"seqBegin" binding:"required"`
|
||||
SeqEnd *int64 `json:"seqEnd" binding:"required"`
|
||||
}
|
||||
}
|
||||
|
||||
type paramsUserPullMsgBySeqList struct {
|
||||
ReqIdentifier int `json:"reqIdentifier" binding:"required"`
|
||||
SendID string `json:"sendID" binding:"required"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
SeqList []uint32 `json:"seqList"`
|
||||
}
|
||||
|
||||
func PullMsgBySeqList(c *gin.Context) {
|
||||
params := paramsUserPullMsgBySeqList{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
token := c.Request.Header.Get("token")
|
||||
if ok, err := token_verify.VerifyToken(token, params.SendID); !ok {
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, utils.GetSelfFuncName(), err.Error(), token, params.SendID)
|
||||
}
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
|
||||
return
|
||||
}
|
||||
pbData := open_im_sdk.PullMessageBySeqListReq{}
|
||||
pbData.UserID = params.SendID
|
||||
pbData.OperationID = params.OperationID
|
||||
pbData.SeqList = params.SeqList
|
||||
|
||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, pbData.OperationID)
|
||||
if grpcConn == nil {
|
||||
errMsg := pbData.OperationID + "getcdv3.GetConn == nil"
|
||||
log.NewError(pbData.OperationID, errMsg)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
|
||||
return
|
||||
}
|
||||
msgClient := msg.NewMsgClient(grpcConn)
|
||||
reply, err := msgClient.PullMessageBySeqList(context.Background(), &pbData)
|
||||
if err != nil {
|
||||
log.ErrorByKv("PullMessageBySeqList error", pbData.OperationID, "err", err.Error())
|
||||
return
|
||||
}
|
||||
log.InfoByKv("rpc call success to PullMessageBySeqList", pbData.OperationID, "ReplyArgs", reply.String(), len(reply.List))
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": reply.ErrCode,
|
||||
"errMsg": reply.ErrMsg,
|
||||
"reqIdentifier": params.ReqIdentifier,
|
||||
"data": reply.List,
|
||||
})
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
package apiChat
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"context"
|
||||
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type paramsUserSendMsg struct {
|
||||
SenderPlatformID int32 `json:"senderPlatformID" binding:"required"`
|
||||
SendID string `json:"sendID" binding:"required"`
|
||||
SenderNickName string `json:"senderNickName"`
|
||||
SenderFaceURL string `json:"senderFaceUrl"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
Data struct {
|
||||
SessionType int32 `json:"sessionType" binding:"required"`
|
||||
MsgFrom int32 `json:"msgFrom" binding:"required"`
|
||||
ContentType int32 `json:"contentType" binding:"required"`
|
||||
RecvID string `json:"recvID" `
|
||||
GroupID string `json:"groupID" `
|
||||
ForceList []string `json:"forceList"`
|
||||
Content []byte `json:"content" binding:"required"`
|
||||
Options map[string]bool `json:"options" `
|
||||
ClientMsgID string `json:"clientMsgID" binding:"required"`
|
||||
CreateTime int64 `json:"createTime" binding:"required"`
|
||||
OffLineInfo *open_im_sdk.OfflinePushInfo `json:"offlineInfo" `
|
||||
}
|
||||
}
|
||||
|
||||
func newUserSendMsgReq(token string, params *paramsUserSendMsg) *pbChat.SendMsgReq {
|
||||
pbData := pbChat.SendMsgReq{
|
||||
Token: token,
|
||||
OperationID: params.OperationID,
|
||||
MsgData: &open_im_sdk.MsgData{
|
||||
SendID: params.SendID,
|
||||
RecvID: params.Data.RecvID,
|
||||
GroupID: params.Data.GroupID,
|
||||
ClientMsgID: params.Data.ClientMsgID,
|
||||
SenderPlatformID: params.SenderPlatformID,
|
||||
SenderNickname: params.SenderNickName,
|
||||
SenderFaceURL: params.SenderFaceURL,
|
||||
SessionType: params.Data.SessionType,
|
||||
MsgFrom: params.Data.MsgFrom,
|
||||
ContentType: params.Data.ContentType,
|
||||
Content: params.Data.Content,
|
||||
CreateTime: params.Data.CreateTime,
|
||||
Options: params.Data.Options,
|
||||
OfflinePushInfo: params.Data.OffLineInfo,
|
||||
},
|
||||
}
|
||||
return &pbData
|
||||
}
|
||||
|
||||
func SendMsg(c *gin.Context) {
|
||||
params := paramsUserSendMsg{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
log.ErrorByKv("json unmarshal err", "", "err", err.Error(), "data", c.PostForm("data"))
|
||||
return
|
||||
}
|
||||
|
||||
token := c.Request.Header.Get("token")
|
||||
|
||||
log.InfoByKv("api call success to sendMsgReq", params.OperationID, "Parameters", params)
|
||||
|
||||
pbData := newUserSendMsgReq(token, ¶ms)
|
||||
log.Info("", "", "api SendMsg call start..., [data: %s]", pbData.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
client := pbChat.NewChatClient(etcdConn)
|
||||
|
||||
log.Info("", "", "api SendMsg call, api call rpc...")
|
||||
|
||||
reply, err := client.SendMsg(context.Background(), pbData)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "SendMsg rpc failed, ", params, err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": "SendMsg rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
log.Info("", "", "api SendMsg call end..., [data: %s] [reply: %s]", pbData.String(), reply.String())
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"errCode": reply.ErrCode,
|
||||
"errMsg": reply.ErrMsg,
|
||||
"data": gin.H{
|
||||
"clientMsgID": reply.ClientMsgID,
|
||||
"serverMsgID": reply.ServerMsgID,
|
||||
"sendTime": reply.SendTime,
|
||||
},
|
||||
})
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ConversationApi rpcclient.Conversation
|
||||
|
||||
func NewConversationApi(discov discoveryregistry.SvcDiscoveryRegistry) ConversationApi {
|
||||
return ConversationApi(*rpcclient.NewConversation(discov))
|
||||
}
|
||||
|
||||
func (o *ConversationApi) GetAllConversations(c *gin.Context) {
|
||||
a2r.Call(conversation.ConversationClient.GetAllConversations, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *ConversationApi) GetConversation(c *gin.Context) {
|
||||
a2r.Call(conversation.ConversationClient.GetConversation, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *ConversationApi) GetConversations(c *gin.Context) {
|
||||
a2r.Call(conversation.ConversationClient.GetConversations, o.Client, c)
|
||||
}
|
||||
|
||||
// deprecated
|
||||
func (o *ConversationApi) SetConversation(c *gin.Context) {
|
||||
a2r.Call(conversation.ConversationClient.SetConversation, o.Client, c)
|
||||
}
|
||||
|
||||
// deprecated
|
||||
func (o *ConversationApi) BatchSetConversations(c *gin.Context) {
|
||||
a2r.Call(conversation.ConversationClient.BatchSetConversations, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *ConversationApi) SetRecvMsgOpt(c *gin.Context) {
|
||||
a2r.Call(conversation.ConversationClient.SetRecvMsgOpt, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *ConversationApi) ModifyConversationField(c *gin.Context) {
|
||||
a2r.Call(conversation.ConversationClient.ModifyConversationField, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *ConversationApi) SetConversations(c *gin.Context) {
|
||||
a2r.Call(conversation.ConversationClient.SetConversations, o.Client, c)
|
||||
}
|
@ -1,250 +0,0 @@
|
||||
package conversation
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbConversation "Open_IM/pkg/proto/conversation"
|
||||
pbUser "Open_IM/pkg/proto/user"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func SetConversation(c *gin.Context) {
|
||||
var (
|
||||
req api.SetConversationReq
|
||||
resp api.SetConversationResp
|
||||
reqPb pbUser.SetConversationReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
reqPb.Conversation = &pbUser.Conversation{}
|
||||
err := utils.CopyStructFields(&reqPb, req)
|
||||
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
|
||||
if err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.SetConversation(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
func ModifyConversationField(c *gin.Context) {
|
||||
var (
|
||||
req api.ModifyConversationFieldReq
|
||||
resp api.ModifyConversationFieldResp
|
||||
reqPb pbConversation.ModifyConversationFieldReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
reqPb.Conversation = &pbConversation.Conversation{}
|
||||
err := utils.CopyStructFields(&reqPb, req)
|
||||
err = utils.CopyStructFields(reqPb.Conversation, req.Conversation)
|
||||
if err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImConversationName)
|
||||
client := pbConversation.NewConversationClient(etcdConn)
|
||||
respPb, err := client.ModifyConversationField(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func BatchSetConversations(c *gin.Context) {
|
||||
var (
|
||||
req api.BatchSetConversationsReq
|
||||
resp api.BatchSetConversationsResp
|
||||
reqPb pbUser.BatchSetConversationsReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.BatchSetConversations(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
if err := utils.CopyStructFields(&resp.Data, respPb); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetAllConversations(c *gin.Context) {
|
||||
var (
|
||||
req api.GetAllConversationsReq
|
||||
resp api.GetAllConversationsResp
|
||||
reqPb pbUser.GetAllConversationsReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetAllConversations(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
||||
if err := utils.CopyStructFields(&resp.Conversations, respPb.Conversations); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed, ", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetConversation(c *gin.Context) {
|
||||
var (
|
||||
req api.GetConversationReq
|
||||
resp api.GetConversationResp
|
||||
reqPb pbUser.GetConversationReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetConversation(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetConversation rpc failed, ", reqPb.String(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
||||
if err := utils.CopyStructFields(&resp.Conversation, respPb.Conversation); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetConversations(c *gin.Context) {
|
||||
var (
|
||||
req api.GetConversationsReq
|
||||
resp api.GetConversationsResp
|
||||
reqPb pbUser.GetConversationsReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetConversations(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation rpc failed, ", reqPb.String(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
||||
if err := utils.CopyStructFields(&resp.Conversations, respPb.Conversations); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func SetRecvMsgOpt(c *gin.Context) {
|
||||
var (
|
||||
req api.SetRecvMsgOptReq
|
||||
resp api.SetRecvMsgOptResp
|
||||
reqPb pbUser.SetRecvMsgOptReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "bind json failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "bind json failed " + err.Error()})
|
||||
return
|
||||
}
|
||||
if err := utils.CopyStructFields(&reqPb, req); err != nil {
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", reqPb.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
|
||||
client := pbUser.NewUserClient(etcdConn)
|
||||
respPb, err := client.SetRecvMsgOpt(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetRecvMsgOpt rpc failed, ", reqPb.String(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": "GetAllConversationMsgOpt rpc failed, " + err.Error()})
|
||||
return
|
||||
}
|
||||
resp.ErrMsg = respPb.CommonResp.ErrMsg
|
||||
resp.ErrCode = respPb.CommonResp.ErrCode
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func SetReceiveMessageOpt(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func GetReceiveMessageOpt(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
//Deprecated
|
||||
func GetAllConversationMessageOpt(c *gin.Context) {
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
||||
"github.com/go-playground/validator/v10"
|
||||
)
|
||||
|
||||
func RequiredIf(fl validator.FieldLevel) bool {
|
||||
sessionType := fl.Parent().FieldByName("SessionType").Int()
|
||||
switch sessionType {
|
||||
case constant.SingleChatType, constant.NotificationChatType:
|
||||
if fl.FieldName() == "RecvID" {
|
||||
return fl.Field().String() != ""
|
||||
}
|
||||
case constant.GroupChatType, constant.SuperGroupChatType:
|
||||
if fl.FieldName() == "GroupID" {
|
||||
return fl.Field().String() != ""
|
||||
}
|
||||
default:
|
||||
return true
|
||||
}
|
||||
return true
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/friend"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type FriendApi rpcclient.Friend
|
||||
|
||||
func NewFriendApi(discov discoveryregistry.SvcDiscoveryRegistry) FriendApi {
|
||||
return FriendApi(*rpcclient.NewFriend(discov))
|
||||
}
|
||||
|
||||
func (o *FriendApi) ApplyToAddFriend(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.ApplyToAddFriend, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *FriendApi) RespondFriendApply(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.RespondFriendApply, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *FriendApi) DeleteFriend(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.DeleteFriend, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *FriendApi) GetFriendApplyList(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.GetPaginationFriendsApplyTo, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *FriendApi) GetSelfApplyList(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.GetPaginationFriendsApplyFrom, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *FriendApi) GetFriendList(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.GetPaginationFriends, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *FriendApi) SetFriendRemark(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.SetFriendRemark, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *FriendApi) AddBlack(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.AddBlack, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *FriendApi) GetPaginationBlacks(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.GetPaginationBlacks, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *FriendApi) RemoveBlack(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.RemoveBlack, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *FriendApi) ImportFriends(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.ImportFriends, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *FriendApi) IsFriend(c *gin.Context) {
|
||||
a2r.Call(friend.FriendClient.IsFriend, o.Client, c)
|
||||
}
|
@ -1,456 +0,0 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
jsonData "Open_IM/internal/utils"
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
rpc "Open_IM/pkg/proto/friend"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func AddBlack(c *gin.Context) {
|
||||
params := api.AddBlacklistReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.AddBlacklistReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms)
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(params.OperationID, "AddBlacklist args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.AddBlacklist(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "AddBlacklist failed ", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call add blacklist rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.AddBlacklistResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.CommID.OperationID, "AddBlacklist api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func ImportFriend(c *gin.Context) {
|
||||
params := api.ImportFriendReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.ImportFriendReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "ImportFriend args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.ImportFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "ImportFriend failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "ImportFriend failed "})
|
||||
return
|
||||
}
|
||||
resp := api.ImportFriendResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
if resp.ErrCode == 0 {
|
||||
for _, v := range RpcResp.UserIDResultList {
|
||||
resp.UserIDResultList = append(resp.UserIDResultList, api.UserIDResult{UserID: v.UserID, Result: v.Result})
|
||||
}
|
||||
}
|
||||
if len(resp.UserIDResultList) == 0 {
|
||||
resp.UserIDResultList = []api.UserIDResult{}
|
||||
}
|
||||
log.NewInfo(req.OperationID, "ImportFriend api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func AddFriend(c *gin.Context) {
|
||||
params := api.AddFriendReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.AddFriendReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
req.ReqMsg = params.ReqMsg
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "AddFriend args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.AddFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "AddFriend failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call AddFriend rpc server failed"})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.AddFriendResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.CommID.OperationID, "AddFriend api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func AddFriendResponse(c *gin.Context) {
|
||||
params := api.AddFriendResponseReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.AddFriendResponseReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
req.HandleMsg = params.HandleMsg
|
||||
req.HandleResult = params.Flag
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
log.NewInfo(req.CommID.OperationID, "AddFriendResponse args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.AddFriendResponse(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "AddFriendResponse failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call add_friend_response rpc server failed"})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.AddFriendResponseResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.CommID.OperationID, "AddFriendResponse api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func DeleteFriend(c *gin.Context) {
|
||||
params := api.DeleteFriendReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.DeleteFriendReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "DeleteFriend args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.DeleteFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "DeleteFriend failed ", err, req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call delete_friend rpc server failed"})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.DeleteFriendResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.CommID.OperationID, "DeleteFriend api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetBlacklist(c *gin.Context) {
|
||||
params := api.GetBlackListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetBlacklistReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms)
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "GetBlacklist args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.GetBlacklist(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "GetBlacklist failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call get blacklist rpc server failed"})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.GetBlackListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||
for _, v := range RpcResp.BlackUserInfoList {
|
||||
black := open_im_sdk.PublicUserInfo{}
|
||||
utils.CopyStructFields(&black, v)
|
||||
resp.BlackUserInfoList = append(resp.BlackUserInfoList, &black)
|
||||
}
|
||||
resp.Data = jsonData.JsonDataList(resp.BlackUserInfoList)
|
||||
log.NewInfo(req.CommID.OperationID, "GetBlacklist api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func SetFriendRemark(c *gin.Context) {
|
||||
params := api.SetFriendRemarkReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.SetFriendRemarkReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
req.Remark = params.Remark
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "SetFriendComment args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.SetFriendRemark(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "SetFriendComment failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call set friend comment rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.SetFriendRemarkResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "SetFriendComment api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func RemoveBlack(c *gin.Context) {
|
||||
params := api.RemoveBlackListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.RemoveBlacklistReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "RemoveBlacklist args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.RemoveBlacklist(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "RemoveBlacklist failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call remove blacklist rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.RemoveBlackListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.CommID.OperationID, "RemoveBlacklist api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func IsFriend(c *gin.Context) {
|
||||
params := api.IsFriendReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.IsFriendReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms.ParamsCommFriend)
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "IsFriend args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.IsFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "IsFriend failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call add friend rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.IsFriendResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||
resp.Response.Friend = RpcResp.Response
|
||||
|
||||
log.NewInfo(req.CommID.OperationID, "IsFriend api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
//
|
||||
//func GetFriendsInfo(c *gin.Context) {
|
||||
// params := api.GetFriendsInfoReq{}
|
||||
// if err := c.BindJSON(¶ms); err != nil {
|
||||
// log.NewError("0", "BindJSON failed ", err.Error())
|
||||
// c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
// return
|
||||
// }
|
||||
// req := &rpc.GetFriendsInfoReq{}
|
||||
// utils.CopyStructFields(req.CommID, params)
|
||||
// var ok bool
|
||||
// ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
||||
// if !ok {
|
||||
// log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
// return
|
||||
// }
|
||||
// log.NewInfo(req.CommID.OperationID, "GetFriendsInfo args ", req.String())
|
||||
//
|
||||
// etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
// client := rpc.NewFriendClient(etcdConn)
|
||||
// RpcResp, err := client.GetFriendsInfo(context.Background(), req)
|
||||
// if err != nil {
|
||||
// log.NewError(req.CommID.OperationID, "GetFriendsInfo failed ", err.Error(), req.String())
|
||||
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call search friend rpc server failed"})
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// resp := api.GetFriendsInfoResp{CommResp:api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||
// utils.CopyStructFields(&resp, RpcResp)
|
||||
// c.JSON(http.StatusOK, resp)
|
||||
// log.NewInfo(req.CommID.OperationID, "GetFriendsInfo api return ", resp)
|
||||
//}
|
||||
|
||||
func GetFriendList(c *gin.Context) {
|
||||
params := api.GetFriendListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetFriendListReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms)
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "GetFriendList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.GetFriendList(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "GetFriendList failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call get friend list rpc server failed"})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.GetFriendListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, FriendInfoList: RpcResp.FriendInfoList}
|
||||
resp.Data = jsonData.JsonDataList(resp.FriendInfoList)
|
||||
log.NewInfo(req.CommID.OperationID, "GetFriendList api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
//c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetFriendApplyList(c *gin.Context) {
|
||||
params := api.GetFriendApplyListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetFriendApplyListReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms)
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "GetFriendApplyList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
|
||||
RpcResp, err := client.GetFriendApplyList(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "GetFriendApplyList failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call get friend apply list rpc server failed"})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.GetFriendApplyListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, FriendRequestList: RpcResp.FriendRequestList}
|
||||
resp.Data = jsonData.JsonDataList(resp.FriendRequestList)
|
||||
log.NewInfo(req.CommID.OperationID, "GetFriendApplyList api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetSelfFriendApplyList(c *gin.Context) {
|
||||
params := api.GetSelfApplyListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetSelfApplyListReq{CommID: &rpc.CommID{}}
|
||||
utils.CopyStructFields(req.CommID, ¶ms)
|
||||
var ok bool
|
||||
ok, req.CommID.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.CommID.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.CommID.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.CommID.OperationID, "GetSelfApplyList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
|
||||
client := rpc.NewFriendClient(etcdConn)
|
||||
RpcResp, err := client.GetSelfApplyList(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.CommID.OperationID, "GetSelfApplyList failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call get self apply list rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.GetSelfApplyListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, FriendRequestList: RpcResp.FriendRequestList}
|
||||
resp.Data = jsonData.JsonDataList(resp.FriendRequestList)
|
||||
log.NewInfo(req.CommID.OperationID, "GetSelfApplyList api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/group"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type GroupApi rpcclient.Group
|
||||
|
||||
func NewGroupApi(discov discoveryregistry.SvcDiscoveryRegistry) GroupApi {
|
||||
return GroupApi(*rpcclient.NewGroup(discov))
|
||||
}
|
||||
|
||||
func (o *GroupApi) CreateGroup(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.CreateGroup, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) SetGroupInfo(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.SetGroupInfo, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) JoinGroup(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.JoinGroup, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) QuitGroup(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.QuitGroup, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) ApplicationGroupResponse(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GroupApplicationResponse, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) TransferGroupOwner(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.TransferGroupOwner, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) GetRecvGroupApplicationList(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GetGroupApplicationList, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) GetUserReqGroupApplicationList(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GetUserReqApplicationList, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) GetGroupsInfo(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GetGroupsInfo, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) KickGroupMember(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.KickGroupMember, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) GetGroupMembersInfo(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GetGroupMembersInfo, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) GetGroupMemberList(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GetGroupMemberList, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) InviteUserToGroup(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.InviteUserToGroup, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) GetJoinedGroupList(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GetJoinedGroupList, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) DismissGroup(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.DismissGroup, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) MuteGroupMember(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.MuteGroupMember, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) CancelMuteGroupMember(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.CancelMuteGroupMember, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) MuteGroup(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.MuteGroup, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) CancelMuteGroup(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.CancelMuteGroup, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) SetGroupMemberInfo(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.SetGroupMemberInfo, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) GetGroupAbstractInfo(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GetGroupAbstractInfo, o.Client, c)
|
||||
}
|
||||
|
||||
//func (g *Group) SetGroupMemberNickname(c *gin.Context) {
|
||||
// a2r.Call(group.GroupClient.SetGroupMemberNickname, g.userClient, c)
|
||||
//}
|
||||
//
|
||||
//func (g *Group) GetGroupAllMemberList(c *gin.Context) {
|
||||
// a2r.Call(group.GroupClient.GetGroupAllMember, g.userClient, c)
|
||||
//}
|
||||
|
||||
func (o *GroupApi) GetJoinedSuperGroupList(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GetJoinedSuperGroupList, o.Client, c)
|
||||
}
|
||||
|
||||
func (o *GroupApi) GetSuperGroupsInfo(c *gin.Context) {
|
||||
a2r.Call(group.GroupClient.GetSuperGroupsInfo, o.Client, c)
|
||||
}
|
@ -1,745 +0,0 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
rpc "Open_IM/pkg/proto/group"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
jsonData "Open_IM/internal/utils"
|
||||
)
|
||||
|
||||
func KickGroupMember(c *gin.Context) {
|
||||
params := api.KickGroupMemberReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
req := &rpc.KickGroupMemberReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, "KickGroupMember args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
RpcResp, err := client.KickGroupMember(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetGroupMemberList failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
var memberListResp api.KickGroupMemberResp
|
||||
memberListResp.ErrMsg = RpcResp.ErrMsg
|
||||
memberListResp.ErrCode = RpcResp.ErrCode
|
||||
for _, v := range RpcResp.Id2ResultList {
|
||||
memberListResp.UserIDResultList = append(memberListResp.UserIDResultList, &api.UserIDResult{UserID: v.UserID, Result: v.Result})
|
||||
}
|
||||
if len(memberListResp.UserIDResultList) == 0 {
|
||||
memberListResp.UserIDResultList = []*api.UserIDResult{}
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, "KickGroupMember api return ", memberListResp)
|
||||
c.JSON(http.StatusOK, memberListResp)
|
||||
}
|
||||
|
||||
func GetGroupMembersInfo(c *gin.Context) {
|
||||
params := api.GetGroupMembersInfoReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetGroupMembersInfoReq{}
|
||||
utils.CopyStructFields(req, params)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
//c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
api.SetErrCodeMsg(c, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetGroupMembersInfo args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
|
||||
RpcResp, err := client.GetGroupMembersInfo(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetGroupMemberList failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
memberListResp := api.GetGroupMembersInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, MemberList: RpcResp.MemberList}
|
||||
memberListResp.Data = jsonData.JsonDataList(RpcResp.MemberList)
|
||||
log.NewInfo(req.OperationID, "GetGroupMembersInfo api return ", memberListResp)
|
||||
c.JSON(http.StatusOK, memberListResp)
|
||||
}
|
||||
|
||||
func GetGroupMemberList(c *gin.Context) {
|
||||
params := api.GetGroupMemberListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetGroupMemberListReq{}
|
||||
utils.CopyStructFields(req, params)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetGroupMemberList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
|
||||
RpcResp, err := client.GetGroupMemberList(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetGroupMemberList failed, ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
memberListResp := api.GetGroupMemberListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, MemberList: RpcResp.MemberList, NextSeq: RpcResp.NextSeq}
|
||||
memberListResp.Data = jsonData.JsonDataList(memberListResp.MemberList)
|
||||
|
||||
log.NewInfo(req.OperationID, "GetGroupMemberList api return ", memberListResp)
|
||||
c.JSON(http.StatusOK, memberListResp)
|
||||
}
|
||||
|
||||
func GetGroupAllMemberList(c *gin.Context) {
|
||||
params := api.GetGroupAllMemberReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetGroupAllMemberReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetGroupAllMember args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
RpcResp, err := client.GetGroupAllMember(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetGroupAllMember failed err", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
memberListResp := api.GetGroupAllMemberResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, MemberList: RpcResp.MemberList}
|
||||
memberListResp.Data = jsonData.JsonDataList(memberListResp.MemberList)
|
||||
log.NewInfo(req.OperationID, "GetGroupAllMember api return ", memberListResp)
|
||||
c.JSON(http.StatusOK, memberListResp)
|
||||
}
|
||||
|
||||
func GetJoinedGroupList(c *gin.Context) {
|
||||
params := api.GetJoinedGroupListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetJoinedGroupListReq{}
|
||||
utils.CopyStructFields(req, params)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetJoinedGroupList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
RpcResp, err := client.GetJoinedGroupList(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetJoinedGroupList failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
GroupListResp := api.GetJoinedGroupListResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, GroupInfoList: RpcResp.GroupList}
|
||||
GroupListResp.Data = jsonData.JsonDataList(GroupListResp.GroupInfoList)
|
||||
log.NewInfo(req.OperationID, "GetJoinedGroupList api return ", GroupListResp)
|
||||
c.JSON(http.StatusOK, GroupListResp)
|
||||
}
|
||||
|
||||
func InviteUserToGroup(c *gin.Context) {
|
||||
params := api.InviteUserToGroupReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.InviteUserToGroupReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "InviteUserToGroup args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
RpcResp, err := client.InviteUserToGroup(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "InviteUserToGroup failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.InviteUserToGroupResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||
for _, v := range RpcResp.Id2ResultList {
|
||||
resp.UserIDResultList = append(resp.UserIDResultList, &api.UserIDResult{UserID: v.UserID, Result: v.Result})
|
||||
}
|
||||
|
||||
if len(resp.UserIDResultList) == 0 {
|
||||
resp.UserIDResultList = *new([]*api.UserIDResult)
|
||||
}
|
||||
|
||||
log.NewInfo(req.OperationID, "InviteUserToGroup api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func CreateGroup(c *gin.Context) {
|
||||
params := api.CreateGroupReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
//
|
||||
req := &rpc.CreateGroupReq{GroupInfo: &open_im_sdk.GroupInfo{}}
|
||||
utils.CopyStructFields(req.GroupInfo, ¶ms)
|
||||
|
||||
for _, v := range params.MemberList {
|
||||
req.InitMemberList = append(req.InitMemberList, &rpc.GroupAddMemberInfo{UserID: v.UserID, RoleLevel: v.RoleLevel})
|
||||
}
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
req.OwnerUserID = params.OwnerUserID
|
||||
req.OperationID = params.OperationID
|
||||
log.NewInfo(req.OperationID, "CreateGroup args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
RpcResp, err := client.CreateGroup(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "CreateGroup failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.CreateGroupResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||
if RpcResp.ErrCode == 0 {
|
||||
utils.CopyStructFields(&resp.GroupInfo, RpcResp.GroupInfo)
|
||||
resp.Data = jsonData.JsonDataOne(&resp.GroupInfo)
|
||||
}
|
||||
log.NewInfo(req.OperationID, "CreateGroup api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// 群主或管理员收到的
|
||||
func GetRecvGroupApplicationList(c *gin.Context) {
|
||||
params := api.GetGroupApplicationListReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetGroupApplicationListReq{}
|
||||
utils.CopyStructFields(req, params)
|
||||
//var ok bool
|
||||
//ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
||||
//if !ok {
|
||||
// log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
// return
|
||||
//}
|
||||
log.NewInfo(req.OperationID, "GetGroupApplicationList args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
reply, err := client.GetGroupApplicationList(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetGroupApplicationList failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: reply.ErrCode, ErrMsg: reply.ErrMsg}, GroupRequestList: reply.GroupRequestList}
|
||||
resp.Data = jsonData.JsonDataList(resp.GroupRequestList)
|
||||
log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetUserReqGroupApplicationList(c *gin.Context) {
|
||||
var params api.GetUserReqGroupApplicationListReq
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", utils.GetSelfFuncName(), err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetUserReqApplicationListReq{}
|
||||
utils.CopyStructFields(req, params)
|
||||
//ok, req.OpUserID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
||||
//if !ok {
|
||||
// log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
// return
|
||||
//}
|
||||
log.NewInfo(req.OperationID, "GetGroupsInfo args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
RpcResp, err := client.GetUserReqApplicationList(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetGroupsInfo failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, RpcResp)
|
||||
resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}, GroupRequestList: RpcResp.GroupRequestList}
|
||||
resp.Data = jsonData.JsonDataList(resp.GroupRequestList)
|
||||
log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func GetGroupsInfo(c *gin.Context) {
|
||||
params := api.GetGroupInfoReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GetGroupsInfoReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "GetGroupsInfo args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
RpcResp, err := client.GetGroupsInfo(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GetGroupsInfo failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.GetGroupInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, GroupInfoList: RpcResp.GroupInfoList}
|
||||
resp.Data = jsonData.JsonDataList(resp.GroupInfoList)
|
||||
log.NewInfo(req.OperationID, "GetGroupsInfo api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
//func transferGroupInfo(input []*open_im_sdk.GroupInfo) []*api.GroupInfoAlias {
|
||||
// var result []*api.GroupInfoAlias
|
||||
// for _, v := range input {
|
||||
// t := &api.GroupInfoAlias{}
|
||||
// utils.CopyStructFields(t, &v)
|
||||
// if v.NeedVerification != nil {
|
||||
// t.NeedVerification = v.NeedVerification.Value
|
||||
// }
|
||||
// result = append(result, t)
|
||||
// }
|
||||
// return result
|
||||
//}
|
||||
|
||||
//process application
|
||||
func ApplicationGroupResponse(c *gin.Context) {
|
||||
params := api.ApplicationGroupResponseReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.GroupApplicationResponseReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "ApplicationGroupResponse args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
reply, err := client.GroupApplicationResponse(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "GroupApplicationResponse failed ", req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.ApplicationGroupResponseResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.OperationID, "ApplicationGroupResponse api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func JoinGroup(c *gin.Context) {
|
||||
params := api.JoinGroupReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.JoinGroupReq{}
|
||||
utils.CopyStructFields(req, params)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "JoinGroup args ", req.String())
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
|
||||
RpcResp, err := client.JoinGroup(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "JoinGroup failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}
|
||||
log.NewInfo(req.OperationID, "JoinGroup api return", RpcResp.String())
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func QuitGroup(c *gin.Context) {
|
||||
params := api.QuitGroupReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.QuitGroupReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "QuitGroup args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
RpcResp, err := client.QuitGroup(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "call quit group rpc server failed,err=%s", err.Error())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}
|
||||
log.NewInfo(req.OperationID, "QuitGroup api return", RpcResp.String())
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func SetGroupInfo(c *gin.Context) {
|
||||
params := api.SetGroupInfoReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.SetGroupInfoReq{GroupInfo: &open_im_sdk.GroupInfo{}}
|
||||
utils.CopyStructFields(req.GroupInfo, ¶ms)
|
||||
req.OperationID = params.OperationID
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "SetGroupInfo args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
RpcResp, err := client.SetGroupInfo(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "SetGroupInfo failed ", err.Error(), req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"})
|
||||
return
|
||||
}
|
||||
resp := api.SetGroupInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
log.NewInfo(req.OperationID, "SetGroupInfo api return ", resp)
|
||||
}
|
||||
|
||||
func TransferGroupOwner(c *gin.Context) {
|
||||
params := api.TransferGroupOwnerReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.TransferGroupOwnerReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, "TransferGroupOwner args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
reply, err := client.TransferGroupOwner(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, "TransferGroupOwner failed ", req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.TransferGroupOwnerResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.OperationID, "TransferGroupOwner api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func DismissGroup(c *gin.Context) {
|
||||
params := api.DismissGroupReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.DismissGroupReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
reply, err := client.DismissGroup(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.DismissGroupResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func MuteGroupMember(c *gin.Context) {
|
||||
params := api.MuteGroupMemberReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.MuteGroupMemberReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
reply, err := client.MuteGroupMember(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.MuteGroupMemberResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func CancelMuteGroupMember(c *gin.Context) {
|
||||
params := api.CancelMuteGroupMemberReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.CancelMuteGroupMemberReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
reply, err := client.CancelMuteGroupMember(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.CancelMuteGroupMemberResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func MuteGroup(c *gin.Context) {
|
||||
params := api.MuteGroupReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.MuteGroupReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
reply, err := client.MuteGroup(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.MuteGroupResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
func CancelMuteGroup(c *gin.Context) {
|
||||
params := api.CancelMuteGroupReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.CancelMuteGroupReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
reply, err := client.CancelMuteGroup(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.CancelMuteGroupResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
//SetGroupMemberNickname
|
||||
|
||||
func SetGroupMemberNickname(c *gin.Context) {
|
||||
params := api.SetGroupMemberNicknameReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
log.NewError("0", "BindJSON failed ", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
req := &rpc.SetGroupMemberNicknameReq{}
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
|
||||
if !ok {
|
||||
log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||
return
|
||||
}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api args ", req.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||
client := rpc.NewGroupClient(etcdConn)
|
||||
reply, err := client.SetGroupMemberNickname(context.Background(), req)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), " failed ", req.String())
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.SetGroupMemberNicknameResp{CommResp: api.CommResp{ErrCode: reply.CommonResp.ErrCode, ErrMsg: reply.CommonResp.ErrMsg}}
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " api return ", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
@ -1,300 +0,0 @@
|
||||
/*
|
||||
** description("").
|
||||
** copyright('open-im,www.open-im.io').
|
||||
** author("fg,Gordon@tuoyun.net").
|
||||
** time(2021/9/15 15:23).
|
||||
*/
|
||||
package manage
|
||||
|
||||
import (
|
||||
api "Open_IM/pkg/base_info"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbChat "Open_IM/pkg/proto/chat"
|
||||
"Open_IM/pkg/proto/sdk_ws"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-playground/validator/v10"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var validate *validator.Validate
|
||||
|
||||
func newUserSendMsgReq(params *ManagementSendMsgReq) *pbChat.SendMsgReq {
|
||||
var newContent string
|
||||
var err error
|
||||
switch params.ContentType {
|
||||
case constant.Text:
|
||||
newContent = params.Content["text"].(string)
|
||||
case constant.Picture:
|
||||
fallthrough
|
||||
case constant.Custom:
|
||||
fallthrough
|
||||
case constant.Voice:
|
||||
fallthrough
|
||||
case constant.Video:
|
||||
fallthrough
|
||||
case constant.File:
|
||||
newContent = utils.StructToJsonString(params.Content)
|
||||
case constant.Revoke:
|
||||
newContent = params.Content["revokeMsgClientID"].(string)
|
||||
default:
|
||||
}
|
||||
options := make(map[string]bool, 5)
|
||||
if params.IsOnlineOnly {
|
||||
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsHistory, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsPersistent, false)
|
||||
utils.SetSwitchFromOptions(options, constant.IsSenderSync, false)
|
||||
}
|
||||
pbData := pbChat.SendMsgReq{
|
||||
OperationID: params.OperationID,
|
||||
MsgData: &open_im_sdk.MsgData{
|
||||
SendID: params.SendID,
|
||||
RecvID: params.RecvID,
|
||||
GroupID: params.GroupID,
|
||||
ClientMsgID: utils.GetMsgID(params.SendID),
|
||||
SenderPlatformID: params.SenderPlatformID,
|
||||
SenderNickname: params.SenderNickname,
|
||||
SenderFaceURL: params.SenderFaceURL,
|
||||
SessionType: params.SessionType,
|
||||
MsgFrom: constant.SysMsgType,
|
||||
ContentType: params.ContentType,
|
||||
Content: []byte(newContent),
|
||||
// ForceList: params.ForceList,
|
||||
CreateTime: utils.GetCurrentTimestampByMill(),
|
||||
Options: options,
|
||||
OfflinePushInfo: params.OfflinePushInfo,
|
||||
},
|
||||
}
|
||||
if params.ContentType == constant.OANotification {
|
||||
var tips open_im_sdk.TipsComm
|
||||
tips.JsonDetail = utils.StructToJsonString(params.Content)
|
||||
pbData.MsgData.Content, err = proto.Marshal(&tips)
|
||||
if err != nil {
|
||||
log.Error(params.OperationID, "Marshal failed ", err.Error(), tips.String())
|
||||
}
|
||||
}
|
||||
return &pbData
|
||||
}
|
||||
func init() {
|
||||
validate = validator.New()
|
||||
}
|
||||
|
||||
func ManagementSendMsg(c *gin.Context) {
|
||||
var data interface{}
|
||||
params := ManagementSendMsgReq{}
|
||||
if err := c.BindJSON(¶ms); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||
log.ErrorByKv("json unmarshal err", c.PostForm("operationID"), "err", err.Error(), "content", c.PostForm("content"))
|
||||
return
|
||||
}
|
||||
switch params.ContentType {
|
||||
case constant.Text:
|
||||
data = TextElem{}
|
||||
case constant.Picture:
|
||||
data = PictureElem{}
|
||||
case constant.Voice:
|
||||
data = SoundElem{}
|
||||
case constant.Video:
|
||||
data = VideoElem{}
|
||||
case constant.File:
|
||||
data = FileElem{}
|
||||
//case constant.AtText:
|
||||
// data = AtElem{}
|
||||
//case constant.Merger:
|
||||
// data =
|
||||
//case constant.Card:
|
||||
//case constant.Location:
|
||||
case constant.Custom:
|
||||
data = CustomElem{}
|
||||
case constant.Revoke:
|
||||
data = RevokeElem{}
|
||||
case constant.OANotification:
|
||||
data = OANotificationElem{}
|
||||
params.SessionType = constant.NotificationChatType
|
||||
//case constant.HasReadReceipt:
|
||||
//case constant.Typing:
|
||||
//case constant.Quote:
|
||||
default:
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 404, "errMsg": "contentType err"})
|
||||
log.ErrorByKv("contentType err", c.PostForm("operationID"), "content", c.PostForm("content"))
|
||||
return
|
||||
}
|
||||
if err := mapstructure.WeakDecode(params.Content, &data); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": err.Error()})
|
||||
log.ErrorByKv("content to Data struct err", "", "err", err.Error())
|
||||
return
|
||||
} else if err := validate.Struct(data); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 403, "errMsg": err.Error()})
|
||||
log.ErrorByKv("data args validate err", "", "err", err.Error())
|
||||
return
|
||||
}
|
||||
log.NewInfo(params.OperationID, data, params)
|
||||
token := c.Request.Header.Get("token")
|
||||
claims, err := token_verify.ParseToken(token, params.OperationID)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "parse token failed", err.Error())
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "parse token failed", "sendTime": 0, "MsgID": ""})
|
||||
return
|
||||
}
|
||||
if !utils.IsContain(claims.UID, config.Config.Manager.AppManagerUid) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "not authorized", "sendTime": 0, "MsgID": ""})
|
||||
return
|
||||
|
||||
}
|
||||
switch params.SessionType {
|
||||
case constant.SingleChatType:
|
||||
if len(params.RecvID) == 0 {
|
||||
log.NewError(params.OperationID, "recvID is a null string")
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 405, "errMsg": "recvID is a null string", "sendTime": 0, "MsgID": ""})
|
||||
return
|
||||
}
|
||||
case constant.GroupChatType:
|
||||
if len(params.GroupID) == 0 {
|
||||
log.NewError(params.OperationID, "groupID is a null string")
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 405, "errMsg": "groupID is a null string", "sendTime": 0, "MsgID": ""})
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
log.InfoByKv("Ws call success to ManagementSendMsgReq", params.OperationID, "Parameters", params)
|
||||
|
||||
pbData := newUserSendMsgReq(¶ms)
|
||||
log.Info(params.OperationID, "api ManagementSendMsg call start..., [data: %s]", pbData.String())
|
||||
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||
client := pbChat.NewChatClient(etcdConn)
|
||||
|
||||
log.Info(params.OperationID, "api ManagementSendMsg call, api call rpc...")
|
||||
|
||||
RpcResp, err := client.SendMsg(context.Background(), pbData)
|
||||
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
|
||||
}
|
||||
log.Info("", "", "api ManagementSendMsg call end..., [data: %s] [reply: %s]", pbData.String(), RpcResp.String())
|
||||
resp := api.ManagementSendMsgResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, ResultList: server_api_params.UserSendMsgResp{ServerMsgID: RpcResp.ServerMsgID, ClientMsgID: RpcResp.ClientMsgID, SendTime: RpcResp.SendTime}}
|
||||
log.Info(params.OperationID, "ManagementSendMsg return", resp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
//type MergeElem struct {
|
||||
// Title string `json:"title"`
|
||||
// AbstractList []string `json:"abstractList"`
|
||||
// MultiMessage []*MsgStruct `json:"multiMessage"`
|
||||
//}
|
||||
//
|
||||
//type QuoteElem struct {
|
||||
// Text string `json:"text"`
|
||||
// QuoteMessage *MsgStruct `json:"quoteMessage"`
|
||||
//}
|
||||
type ManagementSendMsgReq struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
SendID string `json:"sendID" binding:"required"`
|
||||
RecvID string `json:"recvID" `
|
||||
GroupID string `json:"groupID" `
|
||||
SenderNickname string `json:"senderNickname" `
|
||||
SenderFaceURL string `json:"senderFaceURL" `
|
||||
SenderPlatformID int32 `json:"senderPlatformID"`
|
||||
ForceList []string `json:"forceList" `
|
||||
Content map[string]interface{} `json:"content" binding:"required"`
|
||||
ContentType int32 `json:"contentType" binding:"required"`
|
||||
SessionType int32 `json:"sessionType" binding:"required"`
|
||||
IsOnlineOnly bool `json:"isOnlineOnly"`
|
||||
OfflinePushInfo *open_im_sdk.OfflinePushInfo `json:"offlinePushInfo"`
|
||||
}
|
||||
|
||||
type PictureBaseInfo struct {
|
||||
UUID string `mapstructure:"uuid"`
|
||||
Type string `mapstructure:"type" `
|
||||
Size int64 `mapstructure:"size" `
|
||||
Width int32 `mapstructure:"width" `
|
||||
Height int32 `mapstructure:"height"`
|
||||
Url string `mapstructure:"url" `
|
||||
}
|
||||
|
||||
type PictureElem struct {
|
||||
SourcePath string `mapstructure:"sourcePath"`
|
||||
SourcePicture PictureBaseInfo `mapstructure:"sourcePicture"`
|
||||
BigPicture PictureBaseInfo `mapstructure:"bigPicture" `
|
||||
SnapshotPicture PictureBaseInfo `mapstructure:"snapshotPicture"`
|
||||
}
|
||||
type SoundElem struct {
|
||||
UUID string `mapstructure:"uuid"`
|
||||
SoundPath string `mapstructure:"soundPath"`
|
||||
SourceURL string `mapstructure:"sourceUrl"`
|
||||
DataSize int64 `mapstructure:"dataSize"`
|
||||
Duration int64 `mapstructure:"duration"`
|
||||
}
|
||||
type VideoElem struct {
|
||||
VideoPath string `mapstructure:"videoPath"`
|
||||
VideoUUID string `mapstructure:"videoUUID"`
|
||||
VideoURL string `mapstructure:"videoUrl"`
|
||||
VideoType string `mapstructure:"videoType"`
|
||||
VideoSize int64 `mapstructure:"videoSize"`
|
||||
Duration int64 `mapstructure:"duration"`
|
||||
SnapshotPath string `mapstructure:"snapshotPath"`
|
||||
SnapshotUUID string `mapstructure:"snapshotUUID"`
|
||||
SnapshotSize int64 `mapstructure:"snapshotSize"`
|
||||
SnapshotURL string `mapstructure:"snapshotUrl"`
|
||||
SnapshotWidth int32 `mapstructure:"snapshotWidth"`
|
||||
SnapshotHeight int32 `mapstructure:"snapshotHeight"`
|
||||
}
|
||||
type FileElem struct {
|
||||
FilePath string `mapstructure:"filePath"`
|
||||
UUID string `mapstructure:"uuid"`
|
||||
SourceURL string `mapstructure:"sourceUrl"`
|
||||
FileName string `mapstructure:"fileName"`
|
||||
FileSize int64 `mapstructure:"fileSize"`
|
||||
}
|
||||
type AtElem struct {
|
||||
Text string `mapstructure:"text"`
|
||||
AtUserList []string `mapstructure:"atUserList"`
|
||||
AtUsersInfo []struct {
|
||||
AtUserID string `json:"atUserID,omitempty"`
|
||||
GroupNickname string `json:"groupNickname,omitempty"`
|
||||
} `json:"atUsersInfo,omitempty"`
|
||||
IsAtSelf bool `mapstructure:"isAtSelf"`
|
||||
}
|
||||
type LocationElem struct {
|
||||
Description string `mapstructure:"description"`
|
||||
Longitude float64 `mapstructure:"longitude"`
|
||||
Latitude float64 `mapstructure:"latitude"`
|
||||
}
|
||||
type CustomElem struct {
|
||||
Data string `mapstructure:"data" validate:"required"`
|
||||
Description string `mapstructure:"description"`
|
||||
Extension string `mapstructure:"extension"`
|
||||
}
|
||||
type TextElem struct {
|
||||
Text string `mapstructure:"text" validate:"required"`
|
||||
}
|
||||
|
||||
type RevokeElem struct {
|
||||
RevokeMsgClientID string `mapstructure:"revokeMsgClientID" validate:"required"`
|
||||
}
|
||||
type OANotificationElem struct {
|
||||
NotificationName string `mapstructure:"notificationName" json:"notificationName" validate:"required"`
|
||||
NotificationFaceURL string `mapstructure:"notificationFaceURL" json:"notificationFaceURL"`
|
||||
NotificationType int32 `mapstructure:"notificationType" json:"notificationType" validate:"required"`
|
||||
Text string `mapstructure:"text" json:"text" validate:"required"`
|
||||
Url string `mapstructure:"url" json:"url"`
|
||||
MixType int32 `mapstructure:"mixType" json:"mixType"`
|
||||
PictureElem PictureElem `mapstructure:"pictureElem" json:"pictureElem"`
|
||||
SoundElem SoundElem `mapstructure:"soundElem" json:"soundElem"`
|
||||
VideoElem VideoElem `mapstructure:"videoElem" json:"videoElem"`
|
||||
FileElem FileElem `mapstructure:"fileElem" json:"fileElem"`
|
||||
Ex string `mapstructure:"ex" json:"ex"`
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue