mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-08-08 04:06:31 +08:00
Merge remote-tracking branch 'upstream/main'
This commit is contained in:
commit
dbe58fac04
31
.dockerignore
Normal file
31
.dockerignore
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# Ignore files and directories starting with a dot
|
||||||
|
|
||||||
|
# Ignore specific files
|
||||||
|
.dockerignore
|
||||||
|
|
||||||
|
# Ignore build artifacts
|
||||||
|
_output/
|
||||||
|
logs/
|
||||||
|
|
||||||
|
# Ignore non-essential documentation
|
||||||
|
README.md
|
||||||
|
README-zh_CN.md
|
||||||
|
CONTRIBUTING.md
|
||||||
|
CHANGELOG/
|
||||||
|
# LICENSE
|
||||||
|
|
||||||
|
# Ignore testing and linting configuration
|
||||||
|
.golangci.yml
|
||||||
|
|
||||||
|
# Ignore deployment-related files
|
||||||
|
docker-compose.yaml
|
||||||
|
deployments/
|
||||||
|
|
||||||
|
# Ignore assets
|
||||||
|
assets/
|
||||||
|
|
||||||
|
# Ignore components
|
||||||
|
components/
|
||||||
|
|
||||||
|
# Ignore tools and scripts
|
||||||
|
.github/
|
36
.github/workflows/build-docker-image.yml
vendored
Normal file
36
.github/workflows/build-docker-image.yml
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
name: OpenIM Build Docker Images
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- v*
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
bin:
|
||||||
|
- ssserver
|
||||||
|
- sslocal
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Setup Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
- name: Login to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Docker metadata
|
||||||
|
id: metadata
|
||||||
|
uses: docker/metadata-action@v4
|
||||||
|
with:
|
||||||
|
images: ghcr.io/${{ github.repository_owner }}/openim-${{ matrix.bin }}
|
||||||
|
- name: Build and release Docker images
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
platforms: linux/386,linux/amd64,linux/arm64/v8
|
||||||
|
target: ${{ matrix.bin }}
|
||||||
|
tags: ${{ steps.metadata.outputs.tags }}
|
||||||
|
push: true
|
21
.github/workflows/openim-ci.yml
vendored
21
.github/workflows/openim-ci.yml
vendored
@ -83,7 +83,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Build source code for host platform
|
- name: Build source code for host platform
|
||||||
run: |
|
run: |
|
||||||
make multiarch
|
make build
|
||||||
echo "Build source code for host platform successfully"
|
echo "Build source code for host platform successfully"
|
||||||
|
|
||||||
# - name: Collect Test Coverage File
|
# - name: Collect Test Coverage File
|
||||||
@ -132,22 +132,3 @@ jobs:
|
|||||||
# - name: Test docker image
|
# - name: Test docker image
|
||||||
# run: |
|
# run: |
|
||||||
# docker build -t openim:ci-build .
|
# docker build -t openim:ci-build .
|
||||||
|
|
||||||
# goreleaser-test:
|
|
||||||
# runs-on: ubuntu-20.04
|
|
||||||
# steps:
|
|
||||||
# - name: Checkout
|
|
||||||
# uses: actions/checkout@v3
|
|
||||||
# with:
|
|
||||||
# fetch-depth: 0
|
|
||||||
|
|
||||||
# - name: Set up Go
|
|
||||||
# uses: actions/setup-go@v3
|
|
||||||
# with:
|
|
||||||
# go-version: ${{ env.GO_VERSION }}
|
|
||||||
|
|
||||||
# - name: Run GoReleaser
|
|
||||||
# uses: goreleaser/goreleaser-action@v4
|
|
||||||
# with:
|
|
||||||
# version: latest
|
|
||||||
# args: release --clean --skip-publish --snapshot
|
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -163,7 +163,6 @@ go.work
|
|||||||
|
|
||||||
# User-specific stuff
|
# User-specific stuff
|
||||||
.idea/
|
.idea/
|
||||||
.idea
|
|
||||||
.idea/**/workspace.xml
|
.idea/**/workspace.xml
|
||||||
.idea/**/tasks.xml
|
.idea/**/tasks.xml
|
||||||
.idea/**/usage.statistics.xml
|
.idea/**/usage.statistics.xml
|
||||||
@ -353,7 +352,6 @@ cscope.po.out
|
|||||||
*testsdir
|
*testsdir
|
||||||
*testsfile
|
*testsfile
|
||||||
*testsfiles
|
*testsfiles
|
||||||
*test
|
|
||||||
*testdir
|
*testdir
|
||||||
*testfile
|
*testfile
|
||||||
*testfiles
|
*testfiles
|
||||||
|
39
Dockerfile
39
Dockerfile
@ -1,38 +1,31 @@
|
|||||||
|
# Build Stage
|
||||||
FROM golang as build
|
FROM golang as build
|
||||||
|
|
||||||
# go mod Installation source, container environment variable addition will override the default variable value
|
# Set go mod installation source and proxy
|
||||||
ENV GO111MODULE=on
|
ARG GO111MODULE=on
|
||||||
ENV GOPROXY=https://goproxy.cn,direct
|
ARG GOPROXY=https://goproxy.cn,direct
|
||||||
|
ENV GO111MODULE=$GO111MODULE
|
||||||
|
ENV GOPROXY=$GOPROXY
|
||||||
|
|
||||||
# Set up the working directory
|
# Set up the working directory
|
||||||
WORKDIR /Open-IM-Server
|
WORKDIR /Open-IM-Server
|
||||||
# add all files to the container
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
WORKDIR /Open-IM-Server/scripts
|
# Copy all files to the container
|
||||||
RUN chmod +x *.sh
|
ADD . .
|
||||||
|
|
||||||
RUN /bin/sh -c ./build_all_service.sh
|
RUN /bin/sh -c "make build"
|
||||||
|
|
||||||
#Blank image Multi-Stage Build
|
# Production Stage
|
||||||
FROM ubuntu
|
FROM alpine
|
||||||
|
|
||||||
RUN rm -rf /var/lib/apt/lists/*
|
RUN apk --no-cache add tzdata
|
||||||
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
|
|
||||||
|
|
||||||
|
# Set directory to map logs, config files, scripts, and SDK
|
||||||
|
VOLUME ["/Open-IM-Server/logs", "/Open-IM-Server/config", "/Open-IM-Server/scripts", "/Open-IM-Server/db/sdk"]
|
||||||
|
|
||||||
#set directory to map logs,config file,scripts file.
|
# Copy scripts and binary files to the production image
|
||||||
VOLUME ["/Open-IM-Server/logs","/Open-IM-Server/config","/Open-IM-Server/scripts","/Open-IM-Server/db/sdk"]
|
|
||||||
|
|
||||||
#Copy scripts files and binary files to the blank image
|
|
||||||
COPY --from=build /Open-IM-Server/scripts /Open-IM-Server/scripts
|
COPY --from=build /Open-IM-Server/scripts /Open-IM-Server/scripts
|
||||||
COPY --from=build /Open-IM-Server/_output/bin/platforms/linux/amd64 /Open-IM-Server/_output/bin/platforms/linux/amd64
|
COPY --from=build /Open-IM-Server/_output/bin/platforms/linux/arm64 /Open-IM-Server/_output/bin/platforms/linux/arm64
|
||||||
|
|
||||||
WORKDIR /Open-IM-Server/scripts
|
WORKDIR /Open-IM-Server/scripts
|
||||||
|
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -36,7 +36,7 @@ mysql:
|
|||||||
mongo:
|
mongo:
|
||||||
uri: #不为空则直接使用该值
|
uri: #不为空则直接使用该值
|
||||||
address: [ 127.0.0.1:37017 ] #单机时为mongo地址,使用分片集群时,为mongos地址
|
address: [ 127.0.0.1:37017 ] #单机时为mongo地址,使用分片集群时,为mongos地址
|
||||||
database: openIM_v3 #mongo db 默认即可
|
database: openIM_v3 #mongo db 默认即可
|
||||||
username: root #用户名
|
username: root #用户名
|
||||||
password: openIM123 #密码
|
password: openIM123 #密码
|
||||||
maxPoolSize: 100
|
maxPoolSize: 100
|
||||||
@ -56,14 +56,11 @@ kafka:
|
|||||||
topic: "offlineMsgToMongoMysql" #不建议修改
|
topic: "offlineMsgToMongoMysql" #不建议修改
|
||||||
msgToPush:
|
msgToPush:
|
||||||
topic: "msgToPush" #不建议修改
|
topic: "msgToPush" #不建议修改
|
||||||
msgToModify:
|
|
||||||
topic: "msgToModify" #不建议修改
|
|
||||||
consumerGroupID: #消费者组,不建议修改
|
consumerGroupID: #消费者组,不建议修改
|
||||||
msgToRedis: redis #
|
msgToRedis: redis #
|
||||||
msgToMongo: mongo #
|
msgToMongo: mongo #
|
||||||
msgToMySql: mysql #
|
msgToMySql: mysql #
|
||||||
msgToPush: push #
|
msgToPush: push #
|
||||||
msgToModify: modify #
|
|
||||||
|
|
||||||
|
|
||||||
rpc:
|
rpc:
|
||||||
@ -76,41 +73,26 @@ api:
|
|||||||
listenIP: #默认为0.0.0.0
|
listenIP: #默认为0.0.0.0
|
||||||
|
|
||||||
object:
|
object:
|
||||||
enable: minio #使用minio
|
enable: "minio" #使用minio
|
||||||
apiURL: http://127.0.0.1:10002/third/object
|
apiURL: "http://127.0.0.1:10002/object/"
|
||||||
minio:
|
minio:
|
||||||
tempBucket: "openim" #不建议修改
|
bucket: "openim" #不建议修改
|
||||||
dataBucket: "openim" #不建议修改
|
endpoint: "http://127.0.0.1:10005" #minio对外服务的ip和端口,app要能访问此ip和端口
|
||||||
location: us-east-1 #不建议修改
|
accessKeyID: "root" #ID
|
||||||
endpoint: http://127.0.0.1:10005 #minio对外服务的ip和端口,app要能访问此ip和端口
|
secretAccessKey: "openIM123" #秘钥
|
||||||
accessKeyID: root #ID
|
sessionToken: "" #token
|
||||||
secretAccessKey: openIM123 #秘钥
|
cos: #tencent cos
|
||||||
isDistributedMod: false #是否分布式多硬盘部署,如果是多硬盘部署,需要修改为true
|
bucketURL: "https://temp-1252357374.cos.ap-chengdu.myqcloud.com"
|
||||||
tencent: #tencent cos
|
secretID: ""
|
||||||
appID:
|
secretKey: ""
|
||||||
region:
|
sessionToken: ""
|
||||||
bucket:
|
oss: #ali oss
|
||||||
secretID:
|
endpoint: "https://oss-cn-chengdu.aliyuncs.com"
|
||||||
secretKey:
|
bucket: "demo-9999999"
|
||||||
ali: #ali oss
|
bucketURL: "https://demo-9999999.oss-cn-chengdu.aliyuncs.com"
|
||||||
regionID:
|
accessKeyID: ""
|
||||||
accessKeyID:
|
accessKeySecret: ""
|
||||||
accessKeySecret:
|
sessionToken: ""
|
||||||
stsEndpoint:
|
|
||||||
ossEndpoint:
|
|
||||||
bucket:
|
|
||||||
finalHost:
|
|
||||||
stsDurationSeconds:
|
|
||||||
OssRoleArn:
|
|
||||||
aws:
|
|
||||||
accessKeyID:
|
|
||||||
accessKeySecret:
|
|
||||||
region:
|
|
||||||
bucket:
|
|
||||||
finalHost:
|
|
||||||
roleArn:
|
|
||||||
externalId:
|
|
||||||
roleSessionName:
|
|
||||||
|
|
||||||
rpcPort: #rpc服务端口,不建议修改,端口由脚本读取后传入程序,如启动多个程序,只需要填入多个端口,用逗号隔开,如 [10110, 10111]
|
rpcPort: #rpc服务端口,不建议修改,端口由脚本读取后传入程序,如启动多个程序,只需要填入多个端口,用逗号隔开,如 [10110, 10111]
|
||||||
openImUserPort: [ 10110 ]
|
openImUserPort: [ 10110 ]
|
||||||
@ -135,7 +117,7 @@ rpcRegisterName: #rpc注册服务名,不建议修改
|
|||||||
openImThirdName: Third
|
openImThirdName: Third
|
||||||
|
|
||||||
log:
|
log:
|
||||||
storageLocation: ../../../../../logs/ #TODO: 存放目录
|
storageLocation: ../logs/ #存放目录
|
||||||
rotationTime: 24 #日志旋转时间
|
rotationTime: 24 #日志旋转时间
|
||||||
remainRotationCount: 2 #日志数量
|
remainRotationCount: 2 #日志数量
|
||||||
remainLogLevel: 6 #日志级别 6表示全都打印,
|
remainLogLevel: 6 #日志级别 6表示全都打印,
|
||||||
@ -182,7 +164,8 @@ groupMessageHasReadReceiptEnable: true #群聊已读是否开
|
|||||||
singleMessageHasReadReceiptEnable: true #单聊已读是否开启
|
singleMessageHasReadReceiptEnable: true #单聊已读是否开启
|
||||||
|
|
||||||
retainChatRecords: 365 #mongo保存离线消息时间(天)
|
retainChatRecords: 365 #mongo保存离线消息时间(天)
|
||||||
chatRecordsClearTime: "0 2 * * 3" #每周三凌晨2点清理mongo中的过期(超过retainChatRecords时间)消息
|
chatRecordsClearTime: "0 2 * * 3" #每周三凌晨2点清理mongo中的过期(超过retainChatRecords时间)消息,这个删除是为了清理满足上个配置retainChatRecords的过期消息,不会发送通知,仅仅作为清理磁盘使用
|
||||||
|
msgDestructTime: "0 2 * * *" #消息自动删除时间,每天凌晨2点删除过期消息,这个删除是为了删除保留时间超过超过会话字段msg_destruct_time(秒)的消息。
|
||||||
|
|
||||||
secret: tuoyun #秘钥,获取token时校验
|
secret: tuoyun #秘钥,获取token时校验
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ services:
|
|||||||
|
|
||||||
|
|
||||||
openim_server:
|
openim_server:
|
||||||
image: ghcr.io/openimsdk/openim-server:v3.0.0-alpha.0
|
image: ghcr.io/openimsdk/openim-server:v3.0.0-alpha.1
|
||||||
container_name: openim-server
|
container_name: openim-server
|
||||||
volumes:
|
volumes:
|
||||||
- ./logs:/Open-IM-Server/logs
|
- ./logs:/Open-IM-Server/logs
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package msgtransfer
|
package msgtransfer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -5,9 +19,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
"google.golang.org/grpc/credentials/insecure"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
|
||||||
@ -19,6 +30,8 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/prome"
|
||||||
openKeeper "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry/zookeeper"
|
openKeeper "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry/zookeeper"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MsgTransfer struct {
|
type MsgTransfer struct {
|
||||||
@ -47,18 +60,9 @@ func StartTransfer(prometheusPort int) error {
|
|||||||
if err := mongo.CreateMsgIndex(); err != nil {
|
if err := mongo.CreateMsgIndex(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
client, err := openKeeper.NewClient(
|
client, err := openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
|
||||||
config.Config.Zookeeper.ZkAddr,
|
openKeeper.WithFreq(time.Hour), openKeeper.WithRoundRobin(), openKeeper.WithUserNameAndPassword(config.Config.Zookeeper.Username,
|
||||||
config.Config.Zookeeper.Schema,
|
config.Config.Zookeeper.Password), openKeeper.WithTimeout(10), openKeeper.WithLogger(log.NewZkLogger()))
|
||||||
openKeeper.WithFreq(
|
|
||||||
time.Hour,
|
|
||||||
),
|
|
||||||
openKeeper.WithRoundRobin(),
|
|
||||||
openKeeper.WithUserNameAndPassword(config.Config.Zookeeper.Username,
|
|
||||||
config.Config.Zookeeper.Password),
|
|
||||||
openKeeper.WithTimeout(10),
|
|
||||||
openKeeper.WithLogger(log.NewZkLogger()),
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -81,11 +85,8 @@ func StartTransfer(prometheusPort int) error {
|
|||||||
func NewMsgTransfer(chatLogDatabase controller.ChatLogDatabase,
|
func NewMsgTransfer(chatLogDatabase controller.ChatLogDatabase,
|
||||||
msgDatabase controller.CommonMsgDatabase,
|
msgDatabase controller.CommonMsgDatabase,
|
||||||
conversationRpcClient *rpcclient.ConversationRpcClient, groupRpcClient *rpcclient.GroupRpcClient) *MsgTransfer {
|
conversationRpcClient *rpcclient.ConversationRpcClient, groupRpcClient *rpcclient.GroupRpcClient) *MsgTransfer {
|
||||||
return &MsgTransfer{
|
return &MsgTransfer{persistentCH: NewPersistentConsumerHandler(chatLogDatabase), historyCH: NewOnlineHistoryRedisConsumerHandler(msgDatabase, conversationRpcClient, groupRpcClient),
|
||||||
persistentCH: NewPersistentConsumerHandler(chatLogDatabase),
|
historyMongoCH: NewOnlineHistoryMongoConsumerHandler(msgDatabase)}
|
||||||
historyCH: NewOnlineHistoryRedisConsumerHandler(msgDatabase, conversationRpcClient, groupRpcClient),
|
|
||||||
historyMongoCH: NewOnlineHistoryMongoConsumerHandler(msgDatabase),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MsgTransfer) initPrometheus() {
|
func (m *MsgTransfer) initPrometheus() {
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package push
|
package push
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -38,16 +52,9 @@ type Pusher struct {
|
|||||||
|
|
||||||
var errNoOfflinePusher = errors.New("no offlinePusher is configured")
|
var errNoOfflinePusher = errors.New("no offlinePusher is configured")
|
||||||
|
|
||||||
func NewPusher(
|
func NewPusher(discov discoveryregistry.SvcDiscoveryRegistry, offlinePusher offlinepush.OfflinePusher, database controller.PushDatabase,
|
||||||
discov discoveryregistry.SvcDiscoveryRegistry,
|
groupLocalCache *localcache.GroupLocalCache, conversationLocalCache *localcache.ConversationLocalCache,
|
||||||
offlinePusher offlinepush.OfflinePusher,
|
conversationRpcClient *rpcclient.ConversationRpcClient, groupRpcClient *rpcclient.GroupRpcClient, msgRpcClient *rpcclient.MessageRpcClient) *Pusher {
|
||||||
database controller.PushDatabase,
|
|
||||||
groupLocalCache *localcache.GroupLocalCache,
|
|
||||||
conversationLocalCache *localcache.ConversationLocalCache,
|
|
||||||
conversationRpcClient *rpcclient.ConversationRpcClient,
|
|
||||||
groupRpcClient *rpcclient.GroupRpcClient,
|
|
||||||
msgRpcClient *rpcclient.MessageRpcClient,
|
|
||||||
) *Pusher {
|
|
||||||
return &Pusher{
|
return &Pusher{
|
||||||
discov: discov,
|
discov: discov,
|
||||||
database: database,
|
database: database,
|
||||||
@ -94,18 +101,7 @@ func (p *Pusher) Push2User(ctx context.Context, userIDs []string, msg *sdkws.Msg
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
isOfflinePush := utils.GetSwitchFromOptions(msg.Options, constant.IsOfflinePush)
|
isOfflinePush := utils.GetSwitchFromOptions(msg.Options, constant.IsOfflinePush)
|
||||||
log.ZDebug(
|
log.ZDebug(ctx, "push_result", "ws push result", wsResults, "sendData", msg, "isOfflinePush", isOfflinePush, "push_to_userID", userIDs)
|
||||||
ctx,
|
|
||||||
"push_result",
|
|
||||||
"ws push result",
|
|
||||||
wsResults,
|
|
||||||
"sendData",
|
|
||||||
msg,
|
|
||||||
"isOfflinePush",
|
|
||||||
isOfflinePush,
|
|
||||||
"push_to_userID",
|
|
||||||
userIDs,
|
|
||||||
)
|
|
||||||
p.successCount++
|
p.successCount++
|
||||||
for _, userID := range userIDs {
|
for _, userID := range userIDs {
|
||||||
if isOfflinePush && userID != msg.SendID {
|
if isOfflinePush && userID != msg.SendID {
|
||||||
@ -156,15 +152,7 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
|
|||||||
}
|
}
|
||||||
defer func(groupID string, userIDs []string) {
|
defer func(groupID string, userIDs []string) {
|
||||||
if err := p.DeleteMemberAndSetConversationSeq(ctx, groupID, userIDs); err != nil {
|
if err := p.DeleteMemberAndSetConversationSeq(ctx, groupID, userIDs); err != nil {
|
||||||
log.ZError(
|
log.ZError(ctx, "MemberQuitNotification DeleteMemberAndSetConversationSeq", err, "groupID", groupID, "userIDs", userIDs)
|
||||||
ctx,
|
|
||||||
"MemberQuitNotification DeleteMemberAndSetConversationSeq",
|
|
||||||
err,
|
|
||||||
"groupID",
|
|
||||||
groupID,
|
|
||||||
"userIDs",
|
|
||||||
userIDs,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}(groupID, []string{tips.QuitUser.UserID})
|
}(groupID, []string{tips.QuitUser.UserID})
|
||||||
pushToUserIDs = append(pushToUserIDs, tips.QuitUser.UserID)
|
pushToUserIDs = append(pushToUserIDs, tips.QuitUser.UserID)
|
||||||
@ -173,21 +161,10 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
|
|||||||
if p.UnmarshalNotificationElem(msg.Content, &tips) != nil {
|
if p.UnmarshalNotificationElem(msg.Content, &tips) != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
kickedUsers := utils.Slice(
|
kickedUsers := utils.Slice(tips.KickedUserList, func(e *sdkws.GroupMemberFullInfo) string { return e.UserID })
|
||||||
tips.KickedUserList,
|
|
||||||
func(e *sdkws.GroupMemberFullInfo) string { return e.UserID },
|
|
||||||
)
|
|
||||||
defer func(groupID string, userIDs []string) {
|
defer func(groupID string, userIDs []string) {
|
||||||
if err := p.DeleteMemberAndSetConversationSeq(ctx, groupID, userIDs); err != nil {
|
if err := p.DeleteMemberAndSetConversationSeq(ctx, groupID, userIDs); err != nil {
|
||||||
log.ZError(
|
log.ZError(ctx, "MemberKickedNotification DeleteMemberAndSetConversationSeq", err, "groupID", groupID, "userIDs", userIDs)
|
||||||
ctx,
|
|
||||||
"MemberKickedNotification DeleteMemberAndSetConversationSeq",
|
|
||||||
err,
|
|
||||||
"groupID",
|
|
||||||
groupID,
|
|
||||||
"userIDs",
|
|
||||||
userIDs,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}(groupID, kickedUsers)
|
}(groupID, kickedUsers)
|
||||||
pushToUserIDs = append(pushToUserIDs, kickedUsers...)
|
pushToUserIDs = append(pushToUserIDs, kickedUsers...)
|
||||||
@ -197,16 +174,7 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
|
|||||||
if p.UnmarshalNotificationElem(msg.Content, &tips) != nil {
|
if p.UnmarshalNotificationElem(msg.Content, &tips) != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.ZInfo(
|
log.ZInfo(ctx, "GroupDismissedNotificationInfo****", "groupID", groupID, "num", len(pushToUserIDs), "list", pushToUserIDs)
|
||||||
ctx,
|
|
||||||
"GroupDismissedNotificationInfo****",
|
|
||||||
"groupID",
|
|
||||||
groupID,
|
|
||||||
"num",
|
|
||||||
len(pushToUserIDs),
|
|
||||||
"list",
|
|
||||||
pushToUserIDs,
|
|
||||||
)
|
|
||||||
if len(config.Config.Manager.UserID) > 0 {
|
if len(config.Config.Manager.UserID) > 0 {
|
||||||
ctx = mcontext.WithOpUserIDContext(ctx, config.Config.Manager.UserID[0])
|
ctx = mcontext.WithOpUserIDContext(ctx, config.Config.Manager.UserID[0])
|
||||||
}
|
}
|
||||||
@ -270,23 +238,9 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
|
|||||||
log.ZError(ctx, "offlinePushMsg failed", err, "groupID", groupID, "msg", msg)
|
log.ZError(ctx, "offlinePushMsg failed", err, "groupID", groupID, "msg", msg)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err := p.GetConnsAndOnlinePush(
|
_, err := p.GetConnsAndOnlinePush(ctx, msg, utils.IntersectString(needOfflinePushUserIDs, WebAndPcBackgroundUserIDs))
|
||||||
ctx,
|
|
||||||
msg,
|
|
||||||
utils.IntersectString(needOfflinePushUserIDs, WebAndPcBackgroundUserIDs),
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(
|
log.ZError(ctx, "offlinePushMsg failed", err, "groupID", groupID, "msg", msg, "userIDs", utils.IntersectString(needOfflinePushUserIDs, WebAndPcBackgroundUserIDs))
|
||||||
ctx,
|
|
||||||
"offlinePushMsg failed",
|
|
||||||
err,
|
|
||||||
"groupID",
|
|
||||||
groupID,
|
|
||||||
"msg",
|
|
||||||
msg,
|
|
||||||
"userIDs",
|
|
||||||
utils.IntersectString(needOfflinePushUserIDs, WebAndPcBackgroundUserIDs),
|
|
||||||
)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -294,11 +248,7 @@ func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pusher) GetConnsAndOnlinePush(
|
func (p *Pusher) GetConnsAndOnlinePush(ctx context.Context, msg *sdkws.MsgData, pushToUserIDs []string) (wsResults []*msggateway.SingleMsgToUserResults, err error) {
|
||||||
ctx context.Context,
|
|
||||||
msg *sdkws.MsgData,
|
|
||||||
pushToUserIDs []string,
|
|
||||||
) (wsResults []*msggateway.SingleMsgToUserResults, err error) {
|
|
||||||
conns, err := p.discov.GetConns(ctx, config.Config.RpcRegisterName.OpenImMessageGatewayName)
|
conns, err := p.discov.GetConns(ctx, config.Config.RpcRegisterName.OpenImMessageGatewayName)
|
||||||
log.ZDebug(ctx, "get gateway conn", "conn length", len(conns))
|
log.ZDebug(ctx, "get gateway conn", "conn length", len(conns))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -307,10 +257,7 @@ func (p *Pusher) GetConnsAndOnlinePush(
|
|||||||
//Online push message
|
//Online push message
|
||||||
for _, v := range conns {
|
for _, v := range conns {
|
||||||
msgClient := msggateway.NewMsgGatewayClient(v)
|
msgClient := msggateway.NewMsgGatewayClient(v)
|
||||||
reply, err := msgClient.SuperGroupOnlineBatchPushOneMsg(
|
reply, err := msgClient.SuperGroupOnlineBatchPushOneMsg(ctx, &msggateway.OnlineBatchPushOneMsgReq{MsgData: msg, PushToUserIDs: pushToUserIDs})
|
||||||
ctx,
|
|
||||||
&msggateway.OnlineBatchPushOneMsgReq{MsgData: msg, PushToUserIDs: pushToUserIDs},
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -323,12 +270,7 @@ func (p *Pusher) GetConnsAndOnlinePush(
|
|||||||
return wsResults, nil
|
return wsResults, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pusher) offlinePushMsg(
|
func (p *Pusher) offlinePushMsg(ctx context.Context, conversationID string, msg *sdkws.MsgData, offlinePushUserIDs []string) error {
|
||||||
ctx context.Context,
|
|
||||||
conversationID string,
|
|
||||||
msg *sdkws.MsgData,
|
|
||||||
offlinePushUserIDs []string,
|
|
||||||
) error {
|
|
||||||
title, content, opts, err := p.getOfflinePushInfos(conversationID, msg)
|
title, content, opts, err := p.getOfflinePushInfos(conversationID, msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -362,10 +304,7 @@ func (p *Pusher) GetOfflinePushOpts(msg *sdkws.MsgData) (opts *offlinepush.Opts,
|
|||||||
return opts, nil
|
return opts, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pusher) getOfflinePushInfos(
|
func (p *Pusher) getOfflinePushInfos(conversationID string, msg *sdkws.MsgData) (title, content string, opts *offlinepush.Opts, err error) {
|
||||||
conversationID string,
|
|
||||||
msg *sdkws.MsgData,
|
|
||||||
) (title, content string, opts *offlinepush.Opts, err error) {
|
|
||||||
if p.offlinePusher == nil {
|
if p.offlinePusher == nil {
|
||||||
err = errNoOfflinePusher
|
err = errNoOfflinePusher
|
||||||
return
|
return
|
||||||
|
@ -1,10 +1,22 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package conversation
|
package conversation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
||||||
@ -19,6 +31,7 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||||
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
type conversationServer struct {
|
type conversationServer struct {
|
||||||
@ -45,19 +58,12 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
|||||||
pbConversation.RegisterConversationServer(server, &conversationServer{
|
pbConversation.RegisterConversationServer(server, &conversationServer{
|
||||||
conversationNotificationSender: notification.NewConversationNotificationSender(&msgRpcClient),
|
conversationNotificationSender: notification.NewConversationNotificationSender(&msgRpcClient),
|
||||||
groupRpcClient: &groupRpcClient,
|
groupRpcClient: &groupRpcClient,
|
||||||
conversationDatabase: controller.NewConversationDatabase(
|
conversationDatabase: controller.NewConversationDatabase(conversationDB, cache.NewConversationRedis(rdb, cache.GetDefaultOpt(), conversationDB), tx.NewGorm(db)),
|
||||||
conversationDB,
|
|
||||||
cache.NewConversationRedis(rdb, cache.GetDefaultOpt(), conversationDB),
|
|
||||||
tx.NewGorm(db),
|
|
||||||
),
|
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationServer) GetConversation(
|
func (c *conversationServer) GetConversation(ctx context.Context, req *pbConversation.GetConversationReq) (*pbConversation.GetConversationResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbConversation.GetConversationReq,
|
|
||||||
) (*pbConversation.GetConversationResp, error) {
|
|
||||||
conversations, err := c.conversationDatabase.FindConversations(ctx, req.OwnerUserID, []string{req.ConversationID})
|
conversations, err := c.conversationDatabase.FindConversations(ctx, req.OwnerUserID, []string{req.ConversationID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -70,10 +76,7 @@ func (c *conversationServer) GetConversation(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationServer) GetAllConversations(
|
func (c *conversationServer) GetAllConversations(ctx context.Context, req *pbConversation.GetAllConversationsReq) (*pbConversation.GetAllConversationsResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbConversation.GetAllConversationsReq,
|
|
||||||
) (*pbConversation.GetAllConversationsResp, error) {
|
|
||||||
conversations, err := c.conversationDatabase.GetUserAllConversation(ctx, req.OwnerUserID)
|
conversations, err := c.conversationDatabase.GetUserAllConversation(ctx, req.OwnerUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -83,10 +86,7 @@ func (c *conversationServer) GetAllConversations(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationServer) GetConversations(
|
func (c *conversationServer) GetConversations(ctx context.Context, req *pbConversation.GetConversationsReq) (*pbConversation.GetConversationsResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbConversation.GetConversationsReq,
|
|
||||||
) (*pbConversation.GetConversationsResp, error) {
|
|
||||||
conversations, err := c.conversationDatabase.FindConversations(ctx, req.OwnerUserID, req.ConversationIDs)
|
conversations, err := c.conversationDatabase.FindConversations(ctx, req.OwnerUserID, req.ConversationIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -96,19 +96,12 @@ func (c *conversationServer) GetConversations(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationServer) SetConversation(
|
func (c *conversationServer) SetConversation(ctx context.Context, req *pbConversation.SetConversationReq) (*pbConversation.SetConversationResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbConversation.SetConversationReq,
|
|
||||||
) (*pbConversation.SetConversationResp, error) {
|
|
||||||
var conversation tableRelation.ConversationModel
|
var conversation tableRelation.ConversationModel
|
||||||
if err := utils.CopyStructFields(&conversation, req.Conversation); err != nil {
|
if err := utils.CopyStructFields(&conversation, req.Conversation); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
err := c.conversationDatabase.SetUserConversations(
|
err := c.conversationDatabase.SetUserConversations(ctx, req.Conversation.OwnerUserID, []*tableRelation.ConversationModel{&conversation})
|
||||||
ctx,
|
|
||||||
req.Conversation.OwnerUserID,
|
|
||||||
[]*tableRelation.ConversationModel{&conversation},
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -117,10 +110,7 @@ func (c *conversationServer) SetConversation(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationServer) SetConversations(
|
func (c *conversationServer) SetConversations(ctx context.Context, req *pbConversation.SetConversationsReq) (*pbConversation.SetConversationsResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbConversation.SetConversationsReq,
|
|
||||||
) (*pbConversation.SetConversationsResp, error) {
|
|
||||||
if req.Conversation == nil {
|
if req.Conversation == nil {
|
||||||
return nil, errs.ErrArgs.Wrap("conversation must not be nil")
|
return nil, errs.ErrArgs.Wrap("conversation must not be nil")
|
||||||
}
|
}
|
||||||
@ -178,12 +168,7 @@ func (c *conversationServer) SetConversations(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, userID := range req.UserIDs {
|
for _, userID := range req.UserIDs {
|
||||||
c.conversationNotificationSender.ConversationSetPrivateNotification(
|
c.conversationNotificationSender.ConversationSetPrivateNotification(ctx, userID, req.Conversation.UserID, req.Conversation.IsPrivateChat.Value)
|
||||||
ctx,
|
|
||||||
userID,
|
|
||||||
req.Conversation.UserID,
|
|
||||||
req.Conversation.IsPrivateChat.Value,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if req.Conversation.BurnDuration != nil {
|
if req.Conversation.BurnDuration != nil {
|
||||||
@ -200,10 +185,7 @@ func (c *conversationServer) SetConversations(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取超级大群开启免打扰的用户ID
|
// 获取超级大群开启免打扰的用户ID
|
||||||
func (c *conversationServer) GetRecvMsgNotNotifyUserIDs(
|
func (c *conversationServer) GetRecvMsgNotNotifyUserIDs(ctx context.Context, req *pbConversation.GetRecvMsgNotNotifyUserIDsReq) (*pbConversation.GetRecvMsgNotNotifyUserIDsResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbConversation.GetRecvMsgNotNotifyUserIDsReq,
|
|
||||||
) (*pbConversation.GetRecvMsgNotNotifyUserIDsResp, error) {
|
|
||||||
userIDs, err := c.conversationDatabase.FindRecvMsgNotNotifyUserIDs(ctx, req.GroupID)
|
userIDs, err := c.conversationDatabase.FindRecvMsgNotNotifyUserIDs(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -212,10 +194,7 @@ func (c *conversationServer) GetRecvMsgNotNotifyUserIDs(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create conversation without notification for msg redis transfer
|
// create conversation without notification for msg redis transfer
|
||||||
func (c *conversationServer) CreateSingleChatConversations(
|
func (c *conversationServer) CreateSingleChatConversations(ctx context.Context, req *pbConversation.CreateSingleChatConversationsReq) (*pbConversation.CreateSingleChatConversationsResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbConversation.CreateSingleChatConversationsReq,
|
|
||||||
) (*pbConversation.CreateSingleChatConversationsResp, error) {
|
|
||||||
var conversation tableRelation.ConversationModel
|
var conversation tableRelation.ConversationModel
|
||||||
conversation.ConversationID = utils.GetConversationIDBySessionType(constant.SingleChatType, req.RecvID, req.SendID)
|
conversation.ConversationID = utils.GetConversationIDBySessionType(constant.SingleChatType, req.RecvID, req.SendID)
|
||||||
conversation.ConversationType = constant.SingleChatType
|
conversation.ConversationType = constant.SingleChatType
|
||||||
@ -236,10 +215,7 @@ func (c *conversationServer) CreateSingleChatConversations(
|
|||||||
return &pbConversation.CreateSingleChatConversationsResp{}, nil
|
return &pbConversation.CreateSingleChatConversationsResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationServer) CreateGroupChatConversations(
|
func (c *conversationServer) CreateGroupChatConversations(ctx context.Context, req *pbConversation.CreateGroupChatConversationsReq) (*pbConversation.CreateGroupChatConversationsResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbConversation.CreateGroupChatConversationsReq,
|
|
||||||
) (*pbConversation.CreateGroupChatConversationsResp, error) {
|
|
||||||
err := c.conversationDatabase.CreateGroupChatConversation(ctx, req.GroupID, req.UserIDs)
|
err := c.conversationDatabase.CreateGroupChatConversation(ctx, req.GroupID, req.UserIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -247,10 +223,7 @@ func (c *conversationServer) CreateGroupChatConversations(
|
|||||||
return &pbConversation.CreateGroupChatConversationsResp{}, nil
|
return &pbConversation.CreateGroupChatConversationsResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationServer) SetConversationMaxSeq(
|
func (c *conversationServer) SetConversationMaxSeq(ctx context.Context, req *pbConversation.SetConversationMaxSeqReq) (*pbConversation.SetConversationMaxSeqResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbConversation.SetConversationMaxSeqReq,
|
|
||||||
) (*pbConversation.SetConversationMaxSeqResp, error) {
|
|
||||||
if err := c.conversationDatabase.UpdateUsersConversationFiled(ctx, req.OwnerUserID, req.ConversationID,
|
if err := c.conversationDatabase.UpdateUsersConversationFiled(ctx, req.OwnerUserID, req.ConversationID,
|
||||||
map[string]interface{}{"max_seq": req.MaxSeq}); err != nil {
|
map[string]interface{}{"max_seq": req.MaxSeq}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -258,10 +231,7 @@ func (c *conversationServer) SetConversationMaxSeq(
|
|||||||
return &pbConversation.SetConversationMaxSeqResp{}, nil
|
return &pbConversation.SetConversationMaxSeqResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationServer) GetConversationIDs(
|
func (c *conversationServer) GetConversationIDs(ctx context.Context, req *pbConversation.GetConversationIDsReq) (*pbConversation.GetConversationIDsResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbConversation.GetConversationIDsReq,
|
|
||||||
) (*pbConversation.GetConversationIDsResp, error) {
|
|
||||||
conversationIDs, err := c.conversationDatabase.GetConversationIDs(ctx, req.UserID)
|
conversationIDs, err := c.conversationDatabase.GetConversationIDs(ctx, req.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -269,10 +239,7 @@ func (c *conversationServer) GetConversationIDs(
|
|||||||
return &pbConversation.GetConversationIDsResp{ConversationIDs: conversationIDs}, nil
|
return &pbConversation.GetConversationIDsResp{ConversationIDs: conversationIDs}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationServer) GetUserConversationIDsHash(
|
func (c *conversationServer) GetUserConversationIDsHash(ctx context.Context, req *pbConversation.GetUserConversationIDsHashReq) (*pbConversation.GetUserConversationIDsHashResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbConversation.GetUserConversationIDsHashReq,
|
|
||||||
) (*pbConversation.GetUserConversationIDsHashResp, error) {
|
|
||||||
hash, err := c.conversationDatabase.GetUserConversationIDsHash(ctx, req.OwnerUserID)
|
hash, err := c.conversationDatabase.GetUserConversationIDsHash(ctx, req.OwnerUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -280,15 +247,10 @@ func (c *conversationServer) GetUserConversationIDsHash(
|
|||||||
return &pbConversation.GetUserConversationIDsHashResp{Hash: hash}, nil
|
return &pbConversation.GetUserConversationIDsHashResp{Hash: hash}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationServer) GetConversationsByConversationID(
|
func (c *conversationServer) GetConversationsByConversationID(ctx context.Context, req *pbConversation.GetConversationsByConversationIDReq) (*pbConversation.GetConversationsByConversationIDResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbConversation.GetConversationsByConversationIDReq,
|
|
||||||
) (*pbConversation.GetConversationsByConversationIDResp, error) {
|
|
||||||
conversations, err := c.conversationDatabase.GetConversationsByConversationID(ctx, req.ConversationIDs)
|
conversations, err := c.conversationDatabase.GetConversationsByConversationID(ctx, req.ConversationIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &pbConversation.GetConversationsByConversationIDResp{
|
return &pbConversation.GetConversationsByConversationIDResp{Conversations: convert.ConversationsDB2Pb(conversations)}, nil
|
||||||
Conversations: convert.ConversationsDB2Pb(conversations),
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,36 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
pbConversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
|
||||||
"math/big"
|
"math/big"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
pbConversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/wrapperspb"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mw/specialerror"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mw/specialerror"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
"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/db/cache"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
|
||||||
@ -34,6 +45,7 @@ import (
|
|||||||
pbGroup "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/group"
|
pbGroup "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/group"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||||
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
||||||
@ -59,18 +71,13 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
|||||||
pbGroup.RegisterGroupServer(server, &groupServer{
|
pbGroup.RegisterGroupServer(server, &groupServer{
|
||||||
GroupDatabase: database,
|
GroupDatabase: database,
|
||||||
User: userRpcClient,
|
User: userRpcClient,
|
||||||
Notification: notification.NewGroupNotificationSender(
|
Notification: notification.NewGroupNotificationSender(database, &msgRpcClient, &userRpcClient, func(ctx context.Context, userIDs []string) ([]notification.CommonUser, error) {
|
||||||
database,
|
users, err := userRpcClient.GetUsersInfo(ctx, userIDs)
|
||||||
&msgRpcClient,
|
if err != nil {
|
||||||
&userRpcClient,
|
return nil, err
|
||||||
func(ctx context.Context, userIDs []string) ([]notification.CommonUser, error) {
|
}
|
||||||
users, err := userRpcClient.GetUsersInfo(ctx, userIDs)
|
return utils.Slice(users, func(e *sdkws.UserInfo) notification.CommonUser { return e }), nil
|
||||||
if err != nil {
|
}),
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return utils.Slice(users, func(e *sdkws.UserInfo) notification.CommonUser { return e }), nil
|
|
||||||
},
|
|
||||||
),
|
|
||||||
conversationRpcClient: conversationRpcClient,
|
conversationRpcClient: conversationRpcClient,
|
||||||
msgRpcClient: msgRpcClient,
|
msgRpcClient: msgRpcClient,
|
||||||
})
|
})
|
||||||
@ -127,16 +134,7 @@ func (s *groupServer) GenGroupID(ctx context.Context, groupID *string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
id := utils.Md5(
|
id := utils.Md5(strings.Join([]string{mcontext.GetOperationID(ctx), strconv.FormatInt(time.Now().UnixNano(), 10), strconv.Itoa(rand.Int())}, ",;,"))
|
||||||
strings.Join(
|
|
||||||
[]string{
|
|
||||||
mcontext.GetOperationID(ctx),
|
|
||||||
strconv.FormatInt(time.Now().UnixNano(), 10),
|
|
||||||
strconv.Itoa(rand.Int()),
|
|
||||||
},
|
|
||||||
",;,",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
bi := big.NewInt(0)
|
bi := big.NewInt(0)
|
||||||
bi.SetString(id[0:8], 16)
|
bi.SetString(id[0:8], 16)
|
||||||
id = bi.String()
|
id = bi.String()
|
||||||
@ -250,10 +248,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetJoinedGroupList(
|
func (s *groupServer) GetJoinedGroupList(ctx context.Context, req *pbGroup.GetJoinedGroupListReq) (*pbGroup.GetJoinedGroupListResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.GetJoinedGroupListReq,
|
|
||||||
) (*pbGroup.GetJoinedGroupListResp, error) {
|
|
||||||
resp := &pbGroup.GetJoinedGroupListResp{}
|
resp := &pbGroup.GetJoinedGroupListResp{}
|
||||||
if err := tokenverify.CheckAccessV3(ctx, req.FromUserID); err != nil {
|
if err := tokenverify.CheckAccessV3(ctx, req.FromUserID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -263,8 +258,7 @@ func (s *groupServer) GetJoinedGroupList(
|
|||||||
pageNumber = req.Pagination.PageNumber
|
pageNumber = req.Pagination.PageNumber
|
||||||
showNumber = req.Pagination.ShowNumber
|
showNumber = req.Pagination.ShowNumber
|
||||||
}
|
}
|
||||||
// total, members, err := s.GroupDatabase.PageGroupMember(ctx, nil, []string{req.FromUserID}, nil, pageNumber,
|
//total, members, err := s.GroupDatabase.PageGroupMember(ctx, nil, []string{req.FromUserID}, nil, pageNumber, showNumber)
|
||||||
// showNumber)
|
|
||||||
total, members, err := s.GroupDatabase.PageGetJoinGroup(ctx, req.FromUserID, pageNumber, showNumber)
|
total, members, err := s.GroupDatabase.PageGetJoinGroup(ctx, req.FromUserID, pageNumber, showNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -303,10 +297,7 @@ func (s *groupServer) GetJoinedGroupList(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) InviteUserToGroup(
|
func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbGroup.InviteUserToGroupReq) (*pbGroup.InviteUserToGroupResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.InviteUserToGroupReq,
|
|
||||||
) (*pbGroup.InviteUserToGroupResp, error) {
|
|
||||||
resp := &pbGroup.InviteUserToGroupResp{}
|
resp := &pbGroup.InviteUserToGroupResp{}
|
||||||
if len(req.InvitedUserIDs) == 0 {
|
if len(req.InvitedUserIDs) == 0 {
|
||||||
return nil, errs.ErrArgs.Wrap("user empty")
|
return nil, errs.ErrArgs.Wrap("user empty")
|
||||||
@ -407,10 +398,7 @@ func (s *groupServer) InviteUserToGroup(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupAllMember(
|
func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGroupAllMemberReq) (*pbGroup.GetGroupAllMemberResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.GetGroupAllMemberReq,
|
|
||||||
) (*pbGroup.GetGroupAllMemberResp, error) {
|
|
||||||
resp := &pbGroup.GetGroupAllMemberResp{}
|
resp := &pbGroup.GetGroupAllMemberResp{}
|
||||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -438,10 +426,7 @@ func (s *groupServer) GetGroupAllMember(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupMemberList(
|
func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbGroup.GetGroupMemberListReq) (*pbGroup.GetGroupMemberListResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.GetGroupMemberListReq,
|
|
||||||
) (*pbGroup.GetGroupMemberListResp, error) {
|
|
||||||
resp := &pbGroup.GetGroupMemberListResp{}
|
resp := &pbGroup.GetGroupMemberListResp{}
|
||||||
total, members, err := s.PageGetGroupMember(ctx, req.GroupID, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
total, members, err := s.PageGetGroupMember(ctx, req.GroupID, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||||
log.ZDebug(ctx, "GetGroupMemberList", "total", total, "members", members, "length", len(members))
|
log.ZDebug(ctx, "GetGroupMemberList", "total", total, "members", members, "length", len(members))
|
||||||
@ -454,10 +439,7 @@ func (s *groupServer) GetGroupMemberList(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) KickGroupMember(
|
func (s *groupServer) KickGroupMember(ctx context.Context, req *pbGroup.KickGroupMemberReq) (*pbGroup.KickGroupMemberResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.KickGroupMemberReq,
|
|
||||||
) (*pbGroup.KickGroupMemberResp, error) {
|
|
||||||
resp := &pbGroup.KickGroupMemberResp{}
|
resp := &pbGroup.KickGroupMemberResp{}
|
||||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -565,10 +547,7 @@ func (s *groupServer) KickGroupMember(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupMembersInfo(
|
func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetGroupMembersInfoReq) (*pbGroup.GetGroupMembersInfoResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.GetGroupMembersInfoReq,
|
|
||||||
) (*pbGroup.GetGroupMembersInfoResp, error) {
|
|
||||||
resp := &pbGroup.GetGroupMembersInfoResp{}
|
resp := &pbGroup.GetGroupMembersInfoResp{}
|
||||||
if len(req.UserIDs) == 0 {
|
if len(req.UserIDs) == 0 {
|
||||||
return nil, errs.ErrArgs.Wrap("userIDs empty")
|
return nil, errs.ErrArgs.Wrap("userIDs empty")
|
||||||
@ -595,10 +574,7 @@ func (s *groupServer) GetGroupMembersInfo(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupApplicationList(
|
func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.GetGroupApplicationListReq) (*pbGroup.GetGroupApplicationListResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.GetGroupApplicationListReq,
|
|
||||||
) (*pbGroup.GetGroupApplicationListResp, error) {
|
|
||||||
pageNumber, showNumber := utils.GetPage(req.Pagination)
|
pageNumber, showNumber := utils.GetPage(req.Pagination)
|
||||||
|
|
||||||
groupIDs, err := s.GroupDatabase.FindUserManagedGroupID(ctx, req.FromUserID)
|
groupIDs, err := s.GroupDatabase.FindUserManagedGroupID(ctx, req.FromUserID)
|
||||||
@ -649,19 +625,12 @@ func (s *groupServer) GetGroupApplicationList(
|
|||||||
return e.GroupID
|
return e.GroupID
|
||||||
})
|
})
|
||||||
resp.GroupRequests = utils.Slice(groupRequests, func(e *relationTb.GroupRequestModel) *sdkws.GroupRequest {
|
resp.GroupRequests = utils.Slice(groupRequests, func(e *relationTb.GroupRequestModel) *sdkws.GroupRequest {
|
||||||
return convert.Db2PbGroupRequest(
|
return convert.Db2PbGroupRequest(e, userMap[e.UserID], convert.Db2PbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, groupMemberNumMap[e.GroupID]))
|
||||||
e,
|
|
||||||
userMap[e.UserID],
|
|
||||||
convert.Db2PbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, groupMemberNumMap[e.GroupID]),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupsInfo(
|
func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsInfoReq) (*pbGroup.GetGroupsInfoResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.GetGroupsInfoReq,
|
|
||||||
) (*pbGroup.GetGroupsInfoResp, error) {
|
|
||||||
resp := &pbGroup.GetGroupsInfoResp{}
|
resp := &pbGroup.GetGroupsInfoResp{}
|
||||||
if len(req.GroupIDs) == 0 {
|
if len(req.GroupIDs) == 0 {
|
||||||
return nil, errs.ErrArgs.Wrap("groupID is empty")
|
return nil, errs.ErrArgs.Wrap("groupID is empty")
|
||||||
@ -691,10 +660,7 @@ func (s *groupServer) GetGroupsInfo(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GroupApplicationResponse(
|
func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (*pbGroup.GroupApplicationResponseResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.GroupApplicationResponseReq,
|
|
||||||
) (*pbGroup.GroupApplicationResponseResp, error) {
|
|
||||||
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
|
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
|
||||||
if !utils.Contain(req.HandleResult, constant.GroupResponseAgree, constant.GroupResponseRefuse) {
|
if !utils.Contain(req.HandleResult, constant.GroupResponseAgree, constant.GroupResponseRefuse) {
|
||||||
return nil, errs.ErrArgs.Wrap("HandleResult unknown")
|
return nil, errs.ErrArgs.Wrap("HandleResult unknown")
|
||||||
@ -766,10 +732,7 @@ func (s *groupServer) GroupApplicationResponse(
|
|||||||
return &pbGroup.GroupApplicationResponseResp{}, nil
|
return &pbGroup.GroupApplicationResponseResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) JoinGroup(
|
func (s *groupServer) JoinGroup(ctx context.Context, req *pbGroup.JoinGroupReq) (resp *pbGroup.JoinGroupResp, err error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.JoinGroupReq,
|
|
||||||
) (resp *pbGroup.JoinGroupResp, err error) {
|
|
||||||
defer log.ZInfo(ctx, "JoinGroup.Return")
|
defer log.ZInfo(ctx, "JoinGroup.Return")
|
||||||
user, err := s.User.GetUserInfo(ctx, req.InviterUserID)
|
user, err := s.User.GetUserInfo(ctx, req.InviterUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -869,10 +832,7 @@ func (s *groupServer) deleteMemberAndSetConversationSeq(ctx context.Context, gro
|
|||||||
return s.conversationRpcClient.SetConversationMaxSeq(ctx, userIDs, conevrsationID, maxSeq)
|
return s.conversationRpcClient.SetConversationMaxSeq(ctx, userIDs, conevrsationID, maxSeq)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) SetGroupInfo(
|
func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInfoReq) (*pbGroup.SetGroupInfoResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.SetGroupInfoReq,
|
|
||||||
) (*pbGroup.SetGroupInfoResp, error) {
|
|
||||||
var opMember *relationTb.GroupMemberModel
|
var opMember *relationTb.GroupMemberModel
|
||||||
if !tokenverify.IsAppManagerUid(ctx) {
|
if !tokenverify.IsAppManagerUid(ctx) {
|
||||||
var err error
|
var err error
|
||||||
@ -924,17 +884,11 @@ func (s *groupServer) SetGroupInfo(
|
|||||||
go func() {
|
go func() {
|
||||||
nctx := mcontext.NewCtx("@@@" + mcontext.GetOperationID(ctx))
|
nctx := mcontext.NewCtx("@@@" + mcontext.GetOperationID(ctx))
|
||||||
conversation := &pbConversation.ConversationReq{
|
conversation := &pbConversation.ConversationReq{
|
||||||
ConversationID: utils.GetConversationIDBySessionType(
|
ConversationID: utils.GetConversationIDBySessionType(constant.SuperGroupChatType, req.GroupInfoForSet.GroupID),
|
||||||
constant.SuperGroupChatType,
|
|
||||||
req.GroupInfoForSet.GroupID,
|
|
||||||
),
|
|
||||||
ConversationType: constant.SuperGroupChatType,
|
ConversationType: constant.SuperGroupChatType,
|
||||||
GroupID: req.GroupInfoForSet.GroupID,
|
GroupID: req.GroupInfoForSet.GroupID,
|
||||||
}
|
}
|
||||||
resp, err := s.GetGroupMemberUserIDs(
|
resp, err := s.GetGroupMemberUserIDs(nctx, &pbGroup.GetGroupMemberUserIDsReq{GroupID: req.GroupInfoForSet.GroupID})
|
||||||
nctx,
|
|
||||||
&pbGroup.GetGroupMemberUserIDsReq{GroupID: req.GroupInfoForSet.GroupID},
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZWarn(ctx, "GetGroupMemberIDs", err)
|
log.ZWarn(ctx, "GetGroupMemberIDs", err)
|
||||||
return
|
return
|
||||||
@ -945,10 +899,7 @@ func (s *groupServer) SetGroupInfo(
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
num++
|
num++
|
||||||
s.Notification.GroupInfoSetAnnouncementNotification(
|
s.Notification.GroupInfoSetAnnouncementNotification(ctx, &sdkws.GroupInfoSetAnnouncementTips{Group: tips.Group, OpUser: tips.OpUser})
|
||||||
ctx,
|
|
||||||
&sdkws.GroupInfoSetAnnouncementTips{Group: tips.Group, OpUser: tips.OpUser},
|
|
||||||
)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
switch len(data) - num {
|
switch len(data) - num {
|
||||||
@ -965,10 +916,7 @@ func (s *groupServer) SetGroupInfo(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) TransferGroupOwner(
|
func (s *groupServer) TransferGroupOwner(ctx context.Context, req *pbGroup.TransferGroupOwnerReq) (*pbGroup.TransferGroupOwnerResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.TransferGroupOwnerReq,
|
|
||||||
) (*pbGroup.TransferGroupOwnerResp, error) {
|
|
||||||
resp := &pbGroup.TransferGroupOwnerResp{}
|
resp := &pbGroup.TransferGroupOwnerResp{}
|
||||||
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
group, err := s.GroupDatabase.TakeGroup(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1047,20 +995,9 @@ func (s *groupServer) GetGroups(ctx context.Context, req *pbGroup.GetGroupsReq)
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupMembersCMS(
|
func (s *groupServer) GetGroupMembersCMS(ctx context.Context, req *pbGroup.GetGroupMembersCMSReq) (*pbGroup.GetGroupMembersCMSResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.GetGroupMembersCMSReq,
|
|
||||||
) (*pbGroup.GetGroupMembersCMSResp, error) {
|
|
||||||
resp := &pbGroup.GetGroupMembersCMSResp{}
|
resp := &pbGroup.GetGroupMembersCMSResp{}
|
||||||
total, members, err := s.GroupDatabase.SearchGroupMember(
|
total, members, err := s.GroupDatabase.SearchGroupMember(ctx, req.UserName, []string{req.GroupID}, nil, nil, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||||
ctx,
|
|
||||||
req.UserName,
|
|
||||||
[]string{req.GroupID},
|
|
||||||
nil,
|
|
||||||
nil,
|
|
||||||
req.Pagination.PageNumber,
|
|
||||||
req.Pagination.ShowNumber,
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -1080,10 +1017,7 @@ func (s *groupServer) GetGroupMembersCMS(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetUserReqApplicationList(
|
func (s *groupServer) GetUserReqApplicationList(ctx context.Context, req *pbGroup.GetUserReqApplicationListReq) (*pbGroup.GetUserReqApplicationListResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.GetUserReqApplicationListReq,
|
|
||||||
) (*pbGroup.GetUserReqApplicationListResp, error) {
|
|
||||||
resp := &pbGroup.GetUserReqApplicationListResp{}
|
resp := &pbGroup.GetUserReqApplicationListResp{}
|
||||||
user, err := s.User.GetPublicUserInfo(ctx, req.UserID)
|
user, err := s.User.GetPublicUserInfo(ctx, req.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1130,19 +1064,12 @@ func (s *groupServer) GetUserReqApplicationList(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
resp.GroupRequests = utils.Slice(requests, func(e *relationTb.GroupRequestModel) *sdkws.GroupRequest {
|
resp.GroupRequests = utils.Slice(requests, func(e *relationTb.GroupRequestModel) *sdkws.GroupRequest {
|
||||||
return convert.Db2PbGroupRequest(
|
return convert.Db2PbGroupRequest(e, user, convert.Db2PbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, uint32(groupMemberNum[e.GroupID])))
|
||||||
e,
|
|
||||||
user,
|
|
||||||
convert.Db2PbGroupInfo(groupMap[e.GroupID], ownerMap[e.GroupID].UserID, uint32(groupMemberNum[e.GroupID])),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) DismissGroup(
|
func (s *groupServer) DismissGroup(ctx context.Context, req *pbGroup.DismissGroupReq) (*pbGroup.DismissGroupResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.DismissGroupReq,
|
|
||||||
) (*pbGroup.DismissGroupResp, error) {
|
|
||||||
defer log.ZInfo(ctx, "DismissGroup.return")
|
defer log.ZInfo(ctx, "DismissGroup.return")
|
||||||
resp := &pbGroup.DismissGroupResp{}
|
resp := &pbGroup.DismissGroupResp{}
|
||||||
owner, err := s.TakeGroupOwner(ctx, req.GroupID)
|
owner, err := s.TakeGroupOwner(ctx, req.GroupID)
|
||||||
@ -1191,10 +1118,7 @@ func (s *groupServer) DismissGroup(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) MuteGroupMember(
|
func (s *groupServer) MuteGroupMember(ctx context.Context, req *pbGroup.MuteGroupMemberReq) (*pbGroup.MuteGroupMemberResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.MuteGroupMemberReq,
|
|
||||||
) (*pbGroup.MuteGroupMemberResp, error) {
|
|
||||||
resp := &pbGroup.MuteGroupMemberResp{}
|
resp := &pbGroup.MuteGroupMemberResp{}
|
||||||
//if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil {
|
//if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil {
|
||||||
// return nil, err
|
// return nil, err
|
||||||
@ -1229,10 +1153,7 @@ func (s *groupServer) MuteGroupMember(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) CancelMuteGroupMember(
|
func (s *groupServer) CancelMuteGroupMember(ctx context.Context, req *pbGroup.CancelMuteGroupMemberReq) (*pbGroup.CancelMuteGroupMemberResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.CancelMuteGroupMemberReq,
|
|
||||||
) (*pbGroup.CancelMuteGroupMemberResp, error) {
|
|
||||||
resp := &pbGroup.CancelMuteGroupMemberResp{}
|
resp := &pbGroup.CancelMuteGroupMemberResp{}
|
||||||
//member, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.UserID)
|
//member, err := s.GroupDatabase.TakeGroupMember(ctx, req.GroupID, req.UserID)
|
||||||
//if err != nil {
|
//if err != nil {
|
||||||
@ -1244,8 +1165,7 @@ func (s *groupServer) CancelMuteGroupMember(
|
|||||||
// return nil, err
|
// return nil, err
|
||||||
// }
|
// }
|
||||||
// if opMember.RoleLevel <= member.RoleLevel {
|
// if opMember.RoleLevel <= member.RoleLevel {
|
||||||
// return nil, errs.ErrNoPermission.Wrap(fmt.Sprintf("self RoleLevel %d target %d", opMember.RoleLevel,
|
// return nil, errs.ErrNoPermission.Wrap(fmt.Sprintf("self RoleLevel %d target %d", opMember.RoleLevel, member.RoleLevel))
|
||||||
// member.RoleLevel))
|
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
//if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil {
|
//if err := tokenverify.CheckAccessV3(ctx, req.UserID); err != nil {
|
||||||
@ -1293,10 +1213,7 @@ func (s *groupServer) MuteGroup(ctx context.Context, req *pbGroup.MuteGroupReq)
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) CancelMuteGroup(
|
func (s *groupServer) CancelMuteGroup(ctx context.Context, req *pbGroup.CancelMuteGroupReq) (*pbGroup.CancelMuteGroupResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.CancelMuteGroupReq,
|
|
||||||
) (*pbGroup.CancelMuteGroupResp, error) {
|
|
||||||
resp := &pbGroup.CancelMuteGroupResp{}
|
resp := &pbGroup.CancelMuteGroupResp{}
|
||||||
if err := s.CheckGroupAdmin(ctx, req.GroupID); err != nil {
|
if err := s.CheckGroupAdmin(ctx, req.GroupID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -1308,10 +1225,7 @@ func (s *groupServer) CancelMuteGroup(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) SetGroupMemberInfo(
|
func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGroupMemberInfoReq) (*pbGroup.SetGroupMemberInfoResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.SetGroupMemberInfoReq,
|
|
||||||
) (*pbGroup.SetGroupMemberInfoResp, error) {
|
|
||||||
resp := &pbGroup.SetGroupMemberInfoResp{}
|
resp := &pbGroup.SetGroupMemberInfoResp{}
|
||||||
if len(req.Members) == 0 {
|
if len(req.Members) == 0 {
|
||||||
return nil, errs.ErrArgs.Wrap("members empty")
|
return nil, errs.ErrArgs.Wrap("members empty")
|
||||||
@ -1338,11 +1252,9 @@ func (s *groupServer) SetGroupMemberInfo(
|
|||||||
delete(duplicateMap, [...]string{member.GroupID, member.UserID})
|
delete(duplicateMap, [...]string{member.GroupID, member.UserID})
|
||||||
}
|
}
|
||||||
if len(duplicateMap) > 0 {
|
if len(duplicateMap) > 0 {
|
||||||
return nil, errs.ErrArgs.Wrap(
|
return nil, errs.ErrArgs.Wrap("user not found" + strings.Join(utils.Slice(utils.Keys(duplicateMap), func(e [2]string) string {
|
||||||
"user not found" + strings.Join(utils.Slice(utils.Keys(duplicateMap), func(e [2]string) string {
|
return fmt.Sprintf("[group: %s user: %s]", e[0], e[1])
|
||||||
return fmt.Sprintf("[group: %s user: %s]", e[0], e[1])
|
}), ","))
|
||||||
}), ","),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
memberMap := utils.SliceToMap(members, func(e *relationTb.GroupMemberModel) [2]string {
|
memberMap := utils.SliceToMap(members, func(e *relationTb.GroupMemberModel) [2]string {
|
||||||
return [...]string{e.GroupID, e.UserID}
|
return [...]string{e.GroupID, e.UserID}
|
||||||
@ -1372,9 +1284,7 @@ func (s *groupServer) SetGroupMemberInfo(
|
|||||||
}
|
}
|
||||||
dbMember, ok := memberMap[[...]string{member.GroupID, member.UserID}]
|
dbMember, ok := memberMap[[...]string{member.GroupID, member.UserID}]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errs.ErrRecordNotFound.Wrap(
|
return nil, errs.ErrRecordNotFound.Wrap(fmt.Sprintf("user %s not in group %s", member.UserID, member.GroupID))
|
||||||
fmt.Sprintf("user %s not in group %s", member.UserID, member.GroupID),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
//if opMember.RoleLevel == constant.GroupOwner {
|
//if opMember.RoleLevel == constant.GroupOwner {
|
||||||
// continue
|
// continue
|
||||||
@ -1436,25 +1346,14 @@ func (s *groupServer) SetGroupMemberInfo(
|
|||||||
if member.Nickname != nil || member.FaceURL != nil || member.Ex != nil {
|
if member.Nickname != nil || member.FaceURL != nil || member.Ex != nil {
|
||||||
log.ZDebug(ctx, "setGroupMemberInfo notification", "member", member.UserID)
|
log.ZDebug(ctx, "setGroupMemberInfo notification", "member", member.UserID)
|
||||||
if err := s.Notification.GroupMemberInfoSetNotification(ctx, member.GroupID, member.UserID); err != nil {
|
if err := s.Notification.GroupMemberInfoSetNotification(ctx, member.GroupID, member.UserID); err != nil {
|
||||||
log.ZError(
|
log.ZError(ctx, "setGroupMemberInfo notification failed", err, "member", member.UserID, "groupID", member.GroupID)
|
||||||
ctx,
|
|
||||||
"setGroupMemberInfo notification failed",
|
|
||||||
err,
|
|
||||||
"member",
|
|
||||||
member.UserID,
|
|
||||||
"groupID",
|
|
||||||
member.GroupID,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupAbstractInfo(
|
func (s *groupServer) GetGroupAbstractInfo(ctx context.Context, req *pbGroup.GetGroupAbstractInfoReq) (*pbGroup.GetGroupAbstractInfoResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.GetGroupAbstractInfoReq,
|
|
||||||
) (*pbGroup.GetGroupAbstractInfoResp, error) {
|
|
||||||
resp := &pbGroup.GetGroupAbstractInfoResp{}
|
resp := &pbGroup.GetGroupAbstractInfoResp{}
|
||||||
if len(req.GroupIDs) == 0 {
|
if len(req.GroupIDs) == 0 {
|
||||||
return nil, errs.ErrArgs.Wrap("groupIDs empty")
|
return nil, errs.ErrArgs.Wrap("groupIDs empty")
|
||||||
@ -1485,10 +1384,7 @@ func (s *groupServer) GetGroupAbstractInfo(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetUserInGroupMembers(
|
func (s *groupServer) GetUserInGroupMembers(ctx context.Context, req *pbGroup.GetUserInGroupMembersReq) (*pbGroup.GetUserInGroupMembersResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.GetUserInGroupMembersReq,
|
|
||||||
) (*pbGroup.GetUserInGroupMembersResp, error) {
|
|
||||||
resp := &pbGroup.GetUserInGroupMembersResp{}
|
resp := &pbGroup.GetUserInGroupMembersResp{}
|
||||||
if len(req.GroupIDs) == 0 {
|
if len(req.GroupIDs) == 0 {
|
||||||
return nil, errs.ErrArgs.Wrap("groupIDs empty")
|
return nil, errs.ErrArgs.Wrap("groupIDs empty")
|
||||||
@ -1512,10 +1408,7 @@ func (s *groupServer) GetUserInGroupMembers(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupMemberUserIDs(
|
func (s *groupServer) GetGroupMemberUserIDs(ctx context.Context, req *pbGroup.GetGroupMemberUserIDsReq) (resp *pbGroup.GetGroupMemberUserIDsResp, err error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.GetGroupMemberUserIDsReq,
|
|
||||||
) (resp *pbGroup.GetGroupMemberUserIDsResp, err error) {
|
|
||||||
resp = &pbGroup.GetGroupMemberUserIDsResp{}
|
resp = &pbGroup.GetGroupMemberUserIDsResp{}
|
||||||
resp.UserIDs, err = s.GroupDatabase.FindGroupMemberUserID(ctx, req.GroupID)
|
resp.UserIDs, err = s.GroupDatabase.FindGroupMemberUserID(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1524,10 +1417,7 @@ func (s *groupServer) GetGroupMemberUserIDs(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *groupServer) GetGroupMemberRoleLevel(
|
func (s *groupServer) GetGroupMemberRoleLevel(ctx context.Context, req *pbGroup.GetGroupMemberRoleLevelReq) (*pbGroup.GetGroupMemberRoleLevelResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.GetGroupMemberRoleLevelReq,
|
|
||||||
) (*pbGroup.GetGroupMemberRoleLevelResp, error) {
|
|
||||||
resp := &pbGroup.GetGroupMemberRoleLevelResp{}
|
resp := &pbGroup.GetGroupMemberRoleLevelResp{}
|
||||||
if len(req.RoleLevels) == 0 {
|
if len(req.RoleLevels) == 0 {
|
||||||
return nil, errs.ErrArgs.Wrap("RoleLevels empty")
|
return nil, errs.ErrArgs.Wrap("RoleLevels empty")
|
||||||
|
@ -1,17 +1,27 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/group"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/group"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *groupServer) GroupCreateCount(
|
func (s *groupServer) GroupCreateCount(ctx context.Context, req *group.GroupCreateCountReq) (*group.GroupCreateCountResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *group.GroupCreateCountReq,
|
|
||||||
) (*group.GroupCreateCountResp, error) {
|
|
||||||
if req.Start > req.End {
|
if req.Start > req.End {
|
||||||
return nil, errs.ErrArgs.Wrap("start > end")
|
return nil, errs.ErrArgs.Wrap("start > end")
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package msg
|
package msg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -67,6 +81,9 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
|||||||
groupRpcClient := rpcclient.NewGroupRpcClient(client)
|
groupRpcClient := rpcclient.NewGroupRpcClient(client)
|
||||||
friendRpcClient := rpcclient.NewFriendRpcClient(client)
|
friendRpcClient := rpcclient.NewFriendRpcClient(client)
|
||||||
mysql, err := relation.NewGormDB()
|
mysql, err := relation.NewGormDB()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
msgMysModel := relation.NewChatLogGorm(mysql)
|
msgMysModel := relation.NewChatLogGorm(mysql)
|
||||||
msgDatabase := controller.NewCommonMsgDatabase(msgDocModel, cacheModel, msgMysModel)
|
msgDatabase := controller.NewCommonMsgDatabase(msgDocModel, cacheModel, msgMysModel)
|
||||||
s := &msgServer{
|
s := &msgServer{
|
||||||
|
@ -1,25 +1,30 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package msg
|
package msg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/unrelation"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (m *msgServer) GetActiveUser(ctx context.Context, req *msg.GetActiveUserReq) (*msg.GetActiveUserResp, error) {
|
func (m *msgServer) GetActiveUser(ctx context.Context, req *msg.GetActiveUserReq) (*msg.GetActiveUserResp, error) {
|
||||||
msgCount, userCount, users, dateCount, err := m.MsgDatabase.RangeUserSendCount(
|
msgCount, userCount, users, dateCount, err := m.MsgDatabase.RangeUserSendCount(ctx, time.UnixMilli(req.Start), time.UnixMilli(req.End), req.Group, req.Ase, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||||
ctx,
|
|
||||||
time.UnixMilli(req.Start),
|
|
||||||
time.UnixMilli(req.End),
|
|
||||||
req.Group,
|
|
||||||
req.Ase,
|
|
||||||
req.Pagination.PageNumber,
|
|
||||||
req.Pagination.ShowNumber,
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -54,14 +59,7 @@ func (m *msgServer) GetActiveUser(ctx context.Context, req *msg.GetActiveUserReq
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *msgServer) GetActiveGroup(ctx context.Context, req *msg.GetActiveGroupReq) (*msg.GetActiveGroupResp, error) {
|
func (m *msgServer) GetActiveGroup(ctx context.Context, req *msg.GetActiveGroupReq) (*msg.GetActiveGroupResp, error) {
|
||||||
msgCount, groupCount, groups, dateCount, err := m.MsgDatabase.RangeGroupSendCount(
|
msgCount, groupCount, groups, dateCount, err := m.MsgDatabase.RangeGroupSendCount(ctx, time.UnixMilli(req.Start), time.UnixMilli(req.End), req.Ase, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||||
ctx,
|
|
||||||
time.UnixMilli(req.Start),
|
|
||||||
time.UnixMilli(req.End),
|
|
||||||
req.Ase,
|
|
||||||
req.Pagination.PageNumber,
|
|
||||||
req.Pagination.ShowNumber,
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,21 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package third
|
package third
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/cont"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/cont"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
||||||
@ -11,6 +23,7 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (t *thirdServer) PartLimit(ctx context.Context, req *third.PartLimitReq) (*third.PartLimitResp, error) {
|
func (t *thirdServer) PartLimit(ctx context.Context, req *third.PartLimitReq) (*third.PartLimitResp, error) {
|
||||||
@ -30,10 +43,7 @@ func (t *thirdServer) PartSize(ctx context.Context, req *third.PartSizeReq) (*th
|
|||||||
return &third.PartSizeResp{Size: size}, nil
|
return &third.PartSizeResp{Size: size}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *thirdServer) InitiateMultipartUpload(
|
func (t *thirdServer) InitiateMultipartUpload(ctx context.Context, req *third.InitiateMultipartUploadReq) (*third.InitiateMultipartUploadResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *third.InitiateMultipartUploadReq,
|
|
||||||
) (*third.InitiateMultipartUploadResp, error) {
|
|
||||||
defer log.ZDebug(ctx, "return")
|
defer log.ZDebug(ctx, "return")
|
||||||
if err := checkUploadName(ctx, req.Name); err != nil {
|
if err := checkUploadName(ctx, req.Name); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -112,10 +122,7 @@ func (t *thirdServer) AuthSign(ctx context.Context, req *third.AuthSignReq) (*th
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *thirdServer) CompleteMultipartUpload(
|
func (t *thirdServer) CompleteMultipartUpload(ctx context.Context, req *third.CompleteMultipartUploadReq) (*third.CompleteMultipartUploadResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *third.CompleteMultipartUploadReq,
|
|
||||||
) (*third.CompleteMultipartUploadResp, error) {
|
|
||||||
defer log.ZDebug(ctx, "return")
|
defer log.ZDebug(ctx, "return")
|
||||||
if err := checkUploadName(ctx, req.Name); err != nil {
|
if err := checkUploadName(ctx, req.Name); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1,17 +1,28 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package third
|
package third
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/cos"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/cos"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/minio"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/minio"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/oss"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/oss"
|
||||||
|
"net/url"
|
||||||
"google.golang.org/grpc"
|
"time"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
||||||
@ -21,6 +32,7 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||||
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
||||||
@ -79,10 +91,7 @@ type thirdServer struct {
|
|||||||
defaultExpire time.Duration
|
defaultExpire time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *thirdServer) FcmUpdateToken(
|
func (t *thirdServer) FcmUpdateToken(ctx context.Context, req *third.FcmUpdateTokenReq) (resp *third.FcmUpdateTokenResp, err error) {
|
||||||
ctx context.Context,
|
|
||||||
req *third.FcmUpdateTokenReq,
|
|
||||||
) (resp *third.FcmUpdateTokenResp, err error) {
|
|
||||||
err = t.thirdDatabase.FcmUpdateToken(ctx, req.Account, int(req.PlatformID), req.FcmToken, req.ExpireTime)
|
err = t.thirdDatabase.FcmUpdateToken(ctx, req.Account, int(req.PlatformID), req.FcmToken, req.ExpireTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -90,10 +99,7 @@ func (t *thirdServer) FcmUpdateToken(
|
|||||||
return &third.FcmUpdateTokenResp{}, nil
|
return &third.FcmUpdateTokenResp{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *thirdServer) SetAppBadge(
|
func (t *thirdServer) SetAppBadge(ctx context.Context, req *third.SetAppBadgeReq) (resp *third.SetAppBadgeResp, err error) {
|
||||||
ctx context.Context,
|
|
||||||
req *third.SetAppBadgeReq,
|
|
||||||
) (resp *third.SetAppBadgeResp, err error) {
|
|
||||||
err = t.thirdDatabase.SetAppBadge(ctx, req.UserID, int(req.AppUnreadCount))
|
err = t.thirdDatabase.SetAppBadge(ctx, req.UserID, int(req.AppUnreadCount))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1,16 +1,29 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package third
|
package third
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
"unicode/utf8"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/third"
|
||||||
|
"strings"
|
||||||
|
"unicode/utf8"
|
||||||
)
|
)
|
||||||
|
|
||||||
func toPbMapArray(m map[string][]string) []*third.KeyValues {
|
func toPbMapArray(m map[string][]string) []*third.KeyValues {
|
||||||
|
@ -1,13 +1,26 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
"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/constant"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/convert"
|
||||||
@ -24,9 +37,8 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||||
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
type userServer struct {
|
type userServer struct {
|
||||||
@ -61,22 +73,16 @@ func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
|||||||
friendRpcClient := rpcclient.NewFriendRpcClient(client)
|
friendRpcClient := rpcclient.NewFriendRpcClient(client)
|
||||||
msgRpcClient := rpcclient.NewMessageRpcClient(client)
|
msgRpcClient := rpcclient.NewMessageRpcClient(client)
|
||||||
u := &userServer{
|
u := &userServer{
|
||||||
UserDatabase: database,
|
UserDatabase: database,
|
||||||
RegisterCenter: client,
|
RegisterCenter: client,
|
||||||
friendRpcClient: &friendRpcClient,
|
friendRpcClient: &friendRpcClient,
|
||||||
notificationSender: notification.NewFriendNotificationSender(
|
notificationSender: notification.NewFriendNotificationSender(&msgRpcClient, notification.WithDBFunc(database.FindWithError)),
|
||||||
&msgRpcClient,
|
|
||||||
notification.WithDBFunc(database.FindWithError),
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
pbuser.RegisterUserServer(server, u)
|
pbuser.RegisterUserServer(server, u)
|
||||||
return u.UserDatabase.InitOnce(context.Background(), users)
|
return u.UserDatabase.InitOnce(context.Background(), users)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) GetDesignateUsers(
|
func (s *userServer) GetDesignateUsers(ctx context.Context, req *pbuser.GetDesignateUsersReq) (resp *pbuser.GetDesignateUsersResp, err error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbuser.GetDesignateUsersReq,
|
|
||||||
) (resp *pbuser.GetDesignateUsersResp, err error) {
|
|
||||||
resp = &pbuser.GetDesignateUsersResp{}
|
resp = &pbuser.GetDesignateUsersResp{}
|
||||||
users, err := s.FindWithError(ctx, req.UserIDs)
|
users, err := s.FindWithError(ctx, req.UserIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -89,10 +95,7 @@ func (s *userServer) GetDesignateUsers(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) UpdateUserInfo(
|
func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbuser.UpdateUserInfoReq) (resp *pbuser.UpdateUserInfoResp, err error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbuser.UpdateUserInfoReq,
|
|
||||||
) (resp *pbuser.UpdateUserInfoResp, err error) {
|
|
||||||
resp = &pbuser.UpdateUserInfoResp{}
|
resp = &pbuser.UpdateUserInfoResp{}
|
||||||
err = tokenverify.CheckAccessV3(ctx, req.UserInfo.UserID)
|
err = tokenverify.CheckAccessV3(ctx, req.UserInfo.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -117,10 +120,7 @@ func (s *userServer) UpdateUserInfo(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) SetGlobalRecvMessageOpt(
|
func (s *userServer) SetGlobalRecvMessageOpt(ctx context.Context, req *pbuser.SetGlobalRecvMessageOptReq) (resp *pbuser.SetGlobalRecvMessageOptResp, err error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbuser.SetGlobalRecvMessageOptReq,
|
|
||||||
) (resp *pbuser.SetGlobalRecvMessageOptResp, err error) {
|
|
||||||
resp = &pbuser.SetGlobalRecvMessageOptResp{}
|
resp = &pbuser.SetGlobalRecvMessageOptResp{}
|
||||||
if _, err := s.FindWithError(ctx, []string{req.UserID}); err != nil {
|
if _, err := s.FindWithError(ctx, []string{req.UserID}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -134,10 +134,7 @@ func (s *userServer) SetGlobalRecvMessageOpt(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) AccountCheck(
|
func (s *userServer) AccountCheck(ctx context.Context, req *pbuser.AccountCheckReq) (resp *pbuser.AccountCheckResp, err error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbuser.AccountCheckReq,
|
|
||||||
) (resp *pbuser.AccountCheckResp, err error) {
|
|
||||||
resp = &pbuser.AccountCheckResp{}
|
resp = &pbuser.AccountCheckResp{}
|
||||||
if utils.Duplicate(req.CheckUserIDs) {
|
if utils.Duplicate(req.CheckUserIDs) {
|
||||||
return nil, errs.ErrArgs.Wrap("userID repeated")
|
return nil, errs.ErrArgs.Wrap("userID repeated")
|
||||||
@ -166,10 +163,7 @@ func (s *userServer) AccountCheck(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) GetPaginationUsers(
|
func (s *userServer) GetPaginationUsers(ctx context.Context, req *pbuser.GetPaginationUsersReq) (resp *pbuser.GetPaginationUsersResp, err error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbuser.GetPaginationUsersReq,
|
|
||||||
) (resp *pbuser.GetPaginationUsersResp, err error) {
|
|
||||||
var pageNumber, showNumber int32
|
var pageNumber, showNumber int32
|
||||||
if req.Pagination != nil {
|
if req.Pagination != nil {
|
||||||
pageNumber = req.Pagination.PageNumber
|
pageNumber = req.Pagination.PageNumber
|
||||||
@ -182,10 +176,7 @@ func (s *userServer) GetPaginationUsers(
|
|||||||
return &pbuser.GetPaginationUsersResp{Total: int32(total), Users: convert.UsersDB2Pb(users)}, err
|
return &pbuser.GetPaginationUsersResp{Total: int32(total), Users: convert.UsersDB2Pb(users)}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) UserRegister(
|
func (s *userServer) UserRegister(ctx context.Context, req *pbuser.UserRegisterReq) (resp *pbuser.UserRegisterResp, err error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbuser.UserRegisterReq,
|
|
||||||
) (resp *pbuser.UserRegisterResp, err error) {
|
|
||||||
resp = &pbuser.UserRegisterResp{}
|
resp = &pbuser.UserRegisterResp{}
|
||||||
if len(req.Users) == 0 {
|
if len(req.Users) == 0 {
|
||||||
return nil, errs.ErrArgs.Wrap("users is empty")
|
return nil, errs.ErrArgs.Wrap("users is empty")
|
||||||
@ -233,10 +224,7 @@ func (s *userServer) UserRegister(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) GetGlobalRecvMessageOpt(
|
func (s *userServer) GetGlobalRecvMessageOpt(ctx context.Context, req *pbuser.GetGlobalRecvMessageOptReq) (resp *pbuser.GetGlobalRecvMessageOptResp, err error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbuser.GetGlobalRecvMessageOptReq,
|
|
||||||
) (resp *pbuser.GetGlobalRecvMessageOptResp, err error) {
|
|
||||||
user, err := s.FindWithError(ctx, []string{req.UserID})
|
user, err := s.FindWithError(ctx, []string{req.UserID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -244,10 +232,7 @@ func (s *userServer) GetGlobalRecvMessageOpt(
|
|||||||
return &pbuser.GetGlobalRecvMessageOptResp{GlobalRecvMsgOpt: user[0].GlobalRecvMsgOpt}, nil
|
return &pbuser.GetGlobalRecvMessageOptResp{GlobalRecvMsgOpt: user[0].GlobalRecvMsgOpt}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *userServer) GetAllUserID(
|
func (s *userServer) GetAllUserID(ctx context.Context, req *pbuser.GetAllUserIDReq) (resp *pbuser.GetAllUserIDResp, err error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbuser.GetAllUserIDReq,
|
|
||||||
) (resp *pbuser.GetAllUserIDResp, err error) {
|
|
||||||
userIDs, err := s.UserDatabase.GetAllUserID(ctx)
|
userIDs, err := s.UserDatabase.GetAllUserID(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package tools
|
package tools
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -19,60 +33,19 @@ func (c *MsgTool) ConversationsDestructMsgs() {
|
|||||||
}
|
}
|
||||||
log.ZDebug(context.Background(), "nums conversations need destruct", "nums", len(conversations))
|
log.ZDebug(context.Background(), "nums conversations need destruct", "nums", len(conversations))
|
||||||
for _, conversation := range conversations {
|
for _, conversation := range conversations {
|
||||||
log.ZDebug(
|
log.ZDebug(ctx, "UserMsgsDestruct", "conversationID", conversation.ConversationID, "ownerUserID", conversation.OwnerUserID, "msgDestructTime", conversation.MsgDestructTime, "lastMsgDestructTime", conversation.LatestMsgDestructTime)
|
||||||
ctx,
|
seqs, err := c.msgDatabase.UserMsgsDestruct(ctx, conversation.OwnerUserID, conversation.ConversationID, conversation.MsgDestructTime, conversation.LatestMsgDestructTime)
|
||||||
"UserMsgsDestruct",
|
|
||||||
"conversationID",
|
|
||||||
conversation.ConversationID,
|
|
||||||
"ownerUserID",
|
|
||||||
conversation.OwnerUserID,
|
|
||||||
"msgDestructTime",
|
|
||||||
conversation.MsgDestructTime,
|
|
||||||
"lastMsgDestructTime",
|
|
||||||
conversation.LatestMsgDestructTime,
|
|
||||||
)
|
|
||||||
seqs, err := c.msgDatabase.UserMsgsDestruct(
|
|
||||||
ctx,
|
|
||||||
conversation.OwnerUserID,
|
|
||||||
conversation.ConversationID,
|
|
||||||
conversation.MsgDestructTime,
|
|
||||||
conversation.LatestMsgDestructTime,
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(
|
log.ZError(ctx, "user msg destruct failed", err, "conversationID", conversation.ConversationID, "ownerUserID", conversation.OwnerUserID)
|
||||||
ctx,
|
|
||||||
"user msg destruct failed",
|
|
||||||
err,
|
|
||||||
"conversationID",
|
|
||||||
conversation.ConversationID,
|
|
||||||
"ownerUserID",
|
|
||||||
conversation.OwnerUserID,
|
|
||||||
)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := c.conversationDatabase.UpdateUsersConversationFiled(ctx, []string{conversation.OwnerUserID}, conversation.ConversationID, map[string]interface{}{"latest_msg_destruct_time": time.Now()}); err != nil {
|
if err := c.conversationDatabase.UpdateUsersConversationFiled(ctx, []string{conversation.OwnerUserID}, conversation.ConversationID, map[string]interface{}{"latest_msg_destruct_time": time.Now()}); err != nil {
|
||||||
log.ZError(
|
log.ZError(ctx, "updateUsersConversationFiled failed", err, "conversationID", conversation.ConversationID, "ownerUserID", conversation.OwnerUserID)
|
||||||
ctx,
|
|
||||||
"updateUsersConversationFiled failed",
|
|
||||||
err,
|
|
||||||
"conversationID",
|
|
||||||
conversation.ConversationID,
|
|
||||||
"ownerUserID",
|
|
||||||
conversation.OwnerUserID,
|
|
||||||
)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if len(seqs) > 0 {
|
if len(seqs) > 0 {
|
||||||
if err := c.msgNotificationSender.UserDeleteMsgsNotification(ctx, conversation.OwnerUserID, conversation.ConversationID, seqs); err != nil {
|
if err := c.msgNotificationSender.UserDeleteMsgsNotification(ctx, conversation.OwnerUserID, conversation.ConversationID, seqs); err != nil {
|
||||||
log.ZError(
|
log.ZError(ctx, "userDeleteMsgsNotification failed", err, "conversationID", conversation.ConversationID, "ownerUserID", conversation.OwnerUserID)
|
||||||
ctx,
|
|
||||||
"userDeleteMsgsNotification failed",
|
|
||||||
err,
|
|
||||||
"conversationID",
|
|
||||||
conversation.ConversationID,
|
|
||||||
"ownerUserID",
|
|
||||||
conversation.OwnerUserID,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,19 +34,10 @@ func StartCronTask() error {
|
|||||||
c := cron.New()
|
c := cron.New()
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
log.ZInfo(
|
log.ZInfo(context.Background(), "start chatRecordsClearTime cron task", "cron config", config.Config.ChatRecordsClearTime)
|
||||||
context.Background(),
|
|
||||||
"start chatRecordsClearTime cron task",
|
|
||||||
"cron config",
|
|
||||||
config.Config.ChatRecordsClearTime,
|
|
||||||
)
|
|
||||||
_, err = c.AddFunc(config.Config.ChatRecordsClearTime, msgTool.AllConversationClearMsgAndFixSeq)
|
_, err = c.AddFunc(config.Config.ChatRecordsClearTime, msgTool.AllConversationClearMsgAndFixSeq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(
|
fmt.Println("start allConversationClearMsgAndFixSeq cron failed", err.Error(), config.Config.ChatRecordsClearTime)
|
||||||
"start allConversationClearMsgAndFixSeq cron failed",
|
|
||||||
err.Error(),
|
|
||||||
config.Config.ChatRecordsClearTime,
|
|
||||||
)
|
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
log.ZInfo(context.Background(), "start msgDestruct cron task", "cron config", config.Config.MsgDestructTime)
|
log.ZInfo(context.Background(), "start msgDestruct cron task", "cron config", config.Config.MsgDestructTime)
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package tools
|
package tools
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -6,10 +20,6 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/redis/go-redis/v9"
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
"google.golang.org/grpc/credentials/insecure"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/controller"
|
||||||
@ -24,6 +34,9 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient/notification"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||||
|
"github.com/redis/go-redis/v9"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MsgTool struct {
|
type MsgTool struct {
|
||||||
@ -34,13 +47,8 @@ type MsgTool struct {
|
|||||||
msgNotificationSender *notification.MsgNotificationSender
|
msgNotificationSender *notification.MsgNotificationSender
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMsgTool(
|
func NewMsgTool(msgDatabase controller.CommonMsgDatabase, userDatabase controller.UserDatabase,
|
||||||
msgDatabase controller.CommonMsgDatabase,
|
groupDatabase controller.GroupDatabase, conversationDatabase controller.ConversationDatabase, msgNotificationSender *notification.MsgNotificationSender) *MsgTool {
|
||||||
userDatabase controller.UserDatabase,
|
|
||||||
groupDatabase controller.GroupDatabase,
|
|
||||||
conversationDatabase controller.ConversationDatabase,
|
|
||||||
msgNotificationSender *notification.MsgNotificationSender,
|
|
||||||
) *MsgTool {
|
|
||||||
return &MsgTool{
|
return &MsgTool{
|
||||||
msgDatabase: msgDatabase,
|
msgDatabase: msgDatabase,
|
||||||
userDatabase: userDatabase,
|
userDatabase: userDatabase,
|
||||||
@ -63,18 +71,9 @@ func InitMsgTool() (*MsgTool, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
discov, err := zookeeper.NewClient(
|
discov, err := zookeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
|
||||||
config.Config.Zookeeper.ZkAddr,
|
zookeeper.WithFreq(time.Hour), zookeeper.WithRoundRobin(), zookeeper.WithUserNameAndPassword(config.Config.Zookeeper.Username,
|
||||||
config.Config.Zookeeper.Schema,
|
config.Config.Zookeeper.Password), zookeeper.WithTimeout(10), zookeeper.WithLogger(log.NewZkLogger()))
|
||||||
zookeeper.WithFreq(
|
|
||||||
time.Hour,
|
|
||||||
),
|
|
||||||
zookeeper.WithRoundRobin(),
|
|
||||||
zookeeper.WithUserNameAndPassword(config.Config.Zookeeper.Username,
|
|
||||||
config.Config.Zookeeper.Password),
|
|
||||||
zookeeper.WithTimeout(10),
|
|
||||||
zookeeper.WithLogger(log.NewZkLogger()),
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -87,11 +86,7 @@ func InitMsgTool() (*MsgTool, error) {
|
|||||||
tx.NewGorm(db),
|
tx.NewGorm(db),
|
||||||
)
|
)
|
||||||
groupDatabase := controller.InitGroupDatabase(db, rdb, mongo.GetDatabase())
|
groupDatabase := controller.InitGroupDatabase(db, rdb, mongo.GetDatabase())
|
||||||
conversationDatabase := controller.NewConversationDatabase(
|
conversationDatabase := controller.NewConversationDatabase(relation.NewConversationGorm(db), cache.NewConversationRedis(rdb, cache.GetDefaultOpt(), relation.NewConversationGorm(db)), tx.NewGorm(db))
|
||||||
relation.NewConversationGorm(db),
|
|
||||||
cache.NewConversationRedis(rdb, cache.GetDefaultOpt(), relation.NewConversationGorm(db)),
|
|
||||||
tx.NewGorm(db),
|
|
||||||
)
|
|
||||||
msgRpcClient := rpcclient.NewMessageRpcClient(discov)
|
msgRpcClient := rpcclient.NewMessageRpcClient(discov)
|
||||||
msgNotificationSender := notification.NewMsgNotificationSender(rpcclient.WithRpcClient(&msgRpcClient))
|
msgNotificationSender := notification.NewMsgNotificationSender(rpcclient.WithRpcClient(&msgRpcClient))
|
||||||
msgTool := NewMsgTool(msgDatabase, userDatabase, groupDatabase, conversationDatabase, msgNotificationSender)
|
msgTool := NewMsgTool(msgDatabase, userDatabase, groupDatabase, conversationDatabase, msgNotificationSender)
|
||||||
@ -116,15 +111,7 @@ func (c *MsgTool) AllConversationClearMsgAndFixSeq() {
|
|||||||
func (c *MsgTool) ClearConversationsMsg(ctx context.Context, conversationIDs []string) {
|
func (c *MsgTool) ClearConversationsMsg(ctx context.Context, conversationIDs []string) {
|
||||||
for _, conversationID := range conversationIDs {
|
for _, conversationID := range conversationIDs {
|
||||||
if err := c.msgDatabase.DeleteConversationMsgsAndSetMinSeq(ctx, conversationID, int64(config.Config.RetainChatRecords*24*60*60)); err != nil {
|
if err := c.msgDatabase.DeleteConversationMsgsAndSetMinSeq(ctx, conversationID, int64(config.Config.RetainChatRecords*24*60*60)); err != nil {
|
||||||
log.ZError(
|
log.ZError(ctx, "DeleteUserSuperGroupMsgsAndSetMinSeq failed", err, "conversationID", conversationID, "DBRetainChatRecords", config.Config.RetainChatRecords)
|
||||||
ctx,
|
|
||||||
"DeleteUserSuperGroupMsgsAndSetMinSeq failed",
|
|
||||||
err,
|
|
||||||
"conversationID",
|
|
||||||
conversationID,
|
|
||||||
"DBRetainChatRecords",
|
|
||||||
config.Config.RetainChatRecords,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
if err := c.checkMaxSeq(ctx, conversationID); err != nil {
|
if err := c.checkMaxSeq(ctx, conversationID); err != nil {
|
||||||
log.ZError(ctx, "fixSeq failed", err, "conversationID", conversationID)
|
log.ZError(ctx, "fixSeq failed", err, "conversationID", conversationID)
|
||||||
@ -138,19 +125,7 @@ func (c *MsgTool) checkMaxSeqWithMongo(ctx context.Context, conversationID strin
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if math.Abs(float64(maxSeqMongo-maxSeqCache)) > 10 {
|
if math.Abs(float64(maxSeqMongo-maxSeqCache)) > 10 {
|
||||||
log.ZError(
|
log.ZError(ctx, "cache max seq and mongo max seq is diff > 10", nil, "maxSeqMongo", maxSeqMongo, "minSeqMongo", minSeqMongo, "maxSeqCache", maxSeqCache, "conversationID", conversationID)
|
||||||
ctx,
|
|
||||||
"cache max seq and mongo max seq is diff > 10",
|
|
||||||
nil,
|
|
||||||
"maxSeqMongo",
|
|
||||||
maxSeqMongo,
|
|
||||||
"minSeqMongo",
|
|
||||||
minSeqMongo,
|
|
||||||
"maxSeqCache",
|
|
||||||
maxSeqCache,
|
|
||||||
"conversationID",
|
|
||||||
conversationID,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package apiresp
|
package apiresp
|
||||||
|
|
||||||
type ApiFormat interface {
|
type ApiFormat interface {
|
||||||
|
@ -47,8 +47,7 @@ type ForceLogoutReq struct {
|
|||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ForceLogoutResp struct {
|
type ForceLogoutResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type ParseTokenReq struct {
|
type ParseTokenReq struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
|
@ -68,16 +68,14 @@ type SetConversationReq struct {
|
|||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetConversationResp struct {
|
type SetConversationResp struct{}
|
||||||
}
|
|
||||||
type ModifyConversationFieldReq struct {
|
type ModifyConversationFieldReq struct {
|
||||||
Conversation
|
Conversation
|
||||||
FieldType int32 `json:"fieldType" binding:"required"`
|
FieldType int32 `json:"fieldType" binding:"required"`
|
||||||
UserIDList []string `json:"userIDList" binding:"required"`
|
UserIDList []string `json:"userIDList" binding:"required"`
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
type ModifyConversationFieldResp struct {
|
type ModifyConversationFieldResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type BatchSetConversationsReq struct {
|
type BatchSetConversationsReq struct {
|
||||||
Conversations []Conversation `json:"conversations" binding:"required"`
|
Conversations []Conversation `json:"conversations" binding:"required"`
|
||||||
@ -130,5 +128,4 @@ type SetRecvMsgOptReq struct {
|
|||||||
NotificationType int32 `json:"notificationType"`
|
NotificationType int32 `json:"notificationType"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetRecvMsgOptResp struct {
|
type SetRecvMsgOptResp struct{}
|
||||||
}
|
|
||||||
|
@ -185,8 +185,7 @@ type AddBlacklistReq struct {
|
|||||||
ToUserID string `json:"toUserID" binding:"required"`
|
ToUserID string `json:"toUserID" binding:"required"`
|
||||||
FromUserID string `json:"fromUserID" binding:"required"`
|
FromUserID string `json:"fromUserID" binding:"required"`
|
||||||
}
|
}
|
||||||
type AddBlacklistResp struct {
|
type AddBlacklistResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type ImportFriendReq struct {
|
type ImportFriendReq struct {
|
||||||
FriendUserIDList []string `json:"friendUserIDList" binding:"required"`
|
FriendUserIDList []string `json:"friendUserIDList" binding:"required"`
|
||||||
@ -212,15 +211,13 @@ type AddFriendResponseReq struct {
|
|||||||
HandleResult int32 `json:"flag" binding:"required,oneof=-1 0 1"`
|
HandleResult int32 `json:"flag" binding:"required,oneof=-1 0 1"`
|
||||||
HandleMsg string `json:"handleMsg"`
|
HandleMsg string `json:"handleMsg"`
|
||||||
}
|
}
|
||||||
type AddFriendResponseResp struct {
|
type AddFriendResponseResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type DeleteFriendReq struct {
|
type DeleteFriendReq struct {
|
||||||
ToUserID string `json:"toUserID" binding:"required"`
|
ToUserID string `json:"toUserID" binding:"required"`
|
||||||
FromUserID string `json:"fromUserID" binding:"required"`
|
FromUserID string `json:"fromUserID" binding:"required"`
|
||||||
}
|
}
|
||||||
type DeleteFriendResp struct {
|
type DeleteFriendResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type GetBlackListReq struct {
|
type GetBlackListReq struct {
|
||||||
FromUserID string `json:"fromUserID" binding:"required"`
|
FromUserID string `json:"fromUserID" binding:"required"`
|
||||||
@ -234,15 +231,13 @@ type SetFriendRemarkReq struct {
|
|||||||
FromUserID string `json:"fromUserID" binding:"required"`
|
FromUserID string `json:"fromUserID" binding:"required"`
|
||||||
Remark string `json:"remark"`
|
Remark string `json:"remark"`
|
||||||
}
|
}
|
||||||
type SetFriendRemarkResp struct {
|
type SetFriendRemarkResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type RemoveBlacklistReq struct {
|
type RemoveBlacklistReq struct {
|
||||||
ToUserID string `json:"toUserID" binding:"required"`
|
ToUserID string `json:"toUserID" binding:"required"`
|
||||||
FromUserID string `json:"fromUserID" binding:"required"`
|
FromUserID string `json:"fromUserID" binding:"required"`
|
||||||
}
|
}
|
||||||
type RemoveBlacklistResp struct {
|
type RemoveBlacklistResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type IsFriendReq struct {
|
type IsFriendReq struct {
|
||||||
ToUserID string `json:"toUserID" binding:"required"`
|
ToUserID string `json:"toUserID" binding:"required"`
|
||||||
@ -266,7 +261,7 @@ type GetFriendListResp struct {
|
|||||||
AddSource int32 `json:"addSource"`
|
AddSource int32 `json:"addSource"`
|
||||||
OperatorUserID string `json:"operatorUserID"`
|
OperatorUserID string `json:"operatorUserID"`
|
||||||
Ex string `json:"ex"`
|
Ex string `json:"ex"`
|
||||||
//FriendUser *UserInfo // TODO
|
// FriendUser *UserInfo // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetFriendApplyListReq struct {
|
type GetFriendApplyListReq struct {
|
||||||
|
@ -25,8 +25,7 @@ type KickGroupMemberReq struct {
|
|||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
type KickGroupMemberResp struct {
|
type KickGroupMemberResp struct {
|
||||||
|
// UserIDResultList []*UserIDResult `json:"data"`
|
||||||
//UserIDResultList []*UserIDResult `json:"data"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetGroupMembersInfoReq struct {
|
type GetGroupMembersInfoReq struct {
|
||||||
@ -46,8 +45,7 @@ type InviteUserToGroupReq struct {
|
|||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
type InviteUserToGroupResp struct {
|
type InviteUserToGroupResp struct {
|
||||||
|
// UserIDResultList []*UserIDResult `json:"data"`
|
||||||
//UserIDResultList []*UserIDResult `json:"data"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetJoinedGroupListReq struct {
|
type GetJoinedGroupListReq struct {
|
||||||
@ -114,8 +112,9 @@ type CreateGroupResp struct {
|
|||||||
|
|
||||||
type GetGroupApplicationListReq struct {
|
type GetGroupApplicationListReq struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
FromUserID string `json:"fromUserID" binding:"required"` //作为管理员或群主收到的 进群申请
|
FromUserID string `json:"fromUserID" binding:"required"` // 作为管理员或群主收到的 进群申请
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetGroupApplicationListResp struct {
|
type GetGroupApplicationListResp struct {
|
||||||
GroupRequestList []*sdkws.GroupRequest `json:"-"`
|
GroupRequestList []*sdkws.GroupRequest `json:"-"`
|
||||||
Data []map[string]interface{} `json:"data" swaggerignore:"true"`
|
Data []map[string]interface{} `json:"data" swaggerignore:"true"`
|
||||||
@ -163,12 +162,11 @@ type GetGroupInfoResp struct {
|
|||||||
type ApplicationGroupResponseReq struct {
|
type ApplicationGroupResponseReq struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
GroupID string `json:"groupID" binding:"required"`
|
GroupID string `json:"groupID" binding:"required"`
|
||||||
FromUserID string `json:"fromUserID" binding:"required"` //application from FromUserID
|
FromUserID string `json:"fromUserID" binding:"required"` // application from FromUserID
|
||||||
HandledMsg string `json:"handledMsg"`
|
HandledMsg string `json:"handledMsg"`
|
||||||
HandleResult int32 `json:"handleResult" binding:"required,oneof=-1 1"`
|
HandleResult int32 `json:"handleResult" binding:"required,oneof=-1 1"`
|
||||||
}
|
}
|
||||||
type ApplicationGroupResponseResp struct {
|
type ApplicationGroupResponseResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type JoinGroupReq struct {
|
type JoinGroupReq struct {
|
||||||
GroupID string `json:"groupID" binding:"required"`
|
GroupID string `json:"groupID" binding:"required"`
|
||||||
@ -178,15 +176,13 @@ type JoinGroupReq struct {
|
|||||||
InviterUserID string `json:"inviterUserID"`
|
InviterUserID string `json:"inviterUserID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type JoinGroupResp struct {
|
type JoinGroupResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type QuitGroupReq struct {
|
type QuitGroupReq struct {
|
||||||
GroupID string `json:"groupID" binding:"required"`
|
GroupID string `json:"groupID" binding:"required"`
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
type QuitGroupResp struct {
|
type QuitGroupResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type SetGroupInfoReq struct {
|
type SetGroupInfoReq struct {
|
||||||
GroupID string `json:"groupID" binding:"required"`
|
GroupID string `json:"groupID" binding:"required"`
|
||||||
@ -201,8 +197,7 @@ type SetGroupInfoReq struct {
|
|||||||
ApplyMemberFriend *int32 `json:"applyMemberFriend"`
|
ApplyMemberFriend *int32 `json:"applyMemberFriend"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetGroupInfoResp struct {
|
type SetGroupInfoResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type TransferGroupOwnerReq struct {
|
type TransferGroupOwnerReq struct {
|
||||||
GroupID string `json:"groupID" binding:"required"`
|
GroupID string `json:"groupID" binding:"required"`
|
||||||
@ -210,15 +205,13 @@ type TransferGroupOwnerReq struct {
|
|||||||
NewOwnerUserID string `json:"newOwnerUserID" binding:"required"`
|
NewOwnerUserID string `json:"newOwnerUserID" binding:"required"`
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
type TransferGroupOwnerResp struct {
|
type TransferGroupOwnerResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type DismissGroupReq struct {
|
type DismissGroupReq struct {
|
||||||
GroupID string `json:"groupID" binding:"required"`
|
GroupID string `json:"groupID" binding:"required"`
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
type DismissGroupResp struct {
|
type DismissGroupResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type MuteGroupMemberReq struct {
|
type MuteGroupMemberReq struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
@ -226,30 +219,26 @@ type MuteGroupMemberReq struct {
|
|||||||
UserID string `json:"userID" binding:"required"`
|
UserID string `json:"userID" binding:"required"`
|
||||||
MutedSeconds uint32 `json:"mutedSeconds" binding:"required"`
|
MutedSeconds uint32 `json:"mutedSeconds" binding:"required"`
|
||||||
}
|
}
|
||||||
type MuteGroupMemberResp struct {
|
type MuteGroupMemberResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type CancelMuteGroupMemberReq struct {
|
type CancelMuteGroupMemberReq struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
GroupID string `json:"groupID" binding:"required"`
|
GroupID string `json:"groupID" binding:"required"`
|
||||||
UserID string `json:"userID" binding:"required"`
|
UserID string `json:"userID" binding:"required"`
|
||||||
}
|
}
|
||||||
type CancelMuteGroupMemberResp struct {
|
type CancelMuteGroupMemberResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type MuteGroupReq struct {
|
type MuteGroupReq struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
GroupID string `json:"groupID" binding:"required"`
|
GroupID string `json:"groupID" binding:"required"`
|
||||||
}
|
}
|
||||||
type MuteGroupResp struct {
|
type MuteGroupResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type CancelMuteGroupReq struct {
|
type CancelMuteGroupReq struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
GroupID string `json:"groupID" binding:"required"`
|
GroupID string `json:"groupID" binding:"required"`
|
||||||
}
|
}
|
||||||
type CancelMuteGroupResp struct {
|
type CancelMuteGroupResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type SetGroupMemberNicknameReq struct {
|
type SetGroupMemberNicknameReq struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
@ -258,8 +247,7 @@ type SetGroupMemberNicknameReq struct {
|
|||||||
Nickname string `json:"nickname"`
|
Nickname string `json:"nickname"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetGroupMemberNicknameResp struct {
|
type SetGroupMemberNicknameResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type SetGroupMemberInfoReq struct {
|
type SetGroupMemberInfoReq struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
@ -271,8 +259,7 @@ type SetGroupMemberInfoReq struct {
|
|||||||
Ex *string `json:"ex"`
|
Ex *string `json:"ex"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetGroupMemberInfoResp struct {
|
type SetGroupMemberInfoResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type GetGroupAbstractInfoReq struct {
|
type GetGroupAbstractInfoReq struct {
|
||||||
OperationID string `json:"operationID"`
|
OperationID string `json:"operationID"`
|
||||||
|
@ -36,15 +36,14 @@ type GetUsersOnlineStatusReq struct {
|
|||||||
UserIDList []string `json:"userIDList" binding:"required,lte=200"`
|
UserIDList []string `json:"userIDList" binding:"required,lte=200"`
|
||||||
}
|
}
|
||||||
type GetUsersOnlineStatusResp struct {
|
type GetUsersOnlineStatusResp struct {
|
||||||
|
// SuccessResult []*msggateway.GetUsersOnlineStatusResp_SuccessResult `json:"data"`
|
||||||
//SuccessResult []*msggateway.GetUsersOnlineStatusResp_SuccessResult `json:"data"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type AccountCheckReq struct {
|
type AccountCheckReq struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
CheckUserIDList []string `json:"checkUserIDList" binding:"required,lte=100"`
|
CheckUserIDList []string `json:"checkUserIDList" binding:"required,lte=100"`
|
||||||
}
|
}
|
||||||
type AccountCheckResp struct {
|
type AccountCheckResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type ManagementSendMsg struct {
|
type ManagementSendMsg struct {
|
||||||
SendID string `json:"sendID" binding:"required"`
|
SendID string `json:"sendID" binding:"required"`
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package apistruct
|
package apistruct
|
||||||
|
|
||||||
type DelMsgReq struct {
|
type DelMsgReq struct {
|
||||||
@ -6,16 +20,14 @@ type DelMsgReq struct {
|
|||||||
OperationID string `json:"operationID,omitempty" binding:"required"`
|
OperationID string `json:"operationID,omitempty" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DelMsgResp struct {
|
type DelMsgResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type CleanUpMsgReq struct {
|
type CleanUpMsgReq struct {
|
||||||
UserID string `json:"userID" binding:"required"`
|
UserID string `json:"userID" binding:"required"`
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CleanUpMsgResp struct {
|
type CleanUpMsgResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type DelSuperGroupMsgReq struct {
|
type DelSuperGroupMsgReq struct {
|
||||||
UserID string `json:"userID" binding:"required"`
|
UserID string `json:"userID" binding:"required"`
|
||||||
@ -25,8 +37,7 @@ type DelSuperGroupMsgReq struct {
|
|||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DelSuperGroupMsgResp struct {
|
type DelSuperGroupMsgResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type MsgDeleteNotificationElem struct {
|
type MsgDeleteNotificationElem struct {
|
||||||
GroupID string `json:"groupID"`
|
GroupID string `json:"groupID"`
|
||||||
@ -41,8 +52,7 @@ type SetMsgMinSeqReq struct {
|
|||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetMsgMinSeqResp struct {
|
type SetMsgMinSeqResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type PictureBaseInfo struct {
|
type PictureBaseInfo struct {
|
||||||
UUID string `mapstructure:"uuid"`
|
UUID string `mapstructure:"uuid"`
|
||||||
|
@ -58,8 +58,7 @@ type UploadUpdateAppReq struct {
|
|||||||
UpdateLog string `form:"updateLog" binding:"required"`
|
UpdateLog string `form:"updateLog" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UploadUpdateAppResp struct {
|
type UploadUpdateAppResp struct{}
|
||||||
}
|
|
||||||
|
|
||||||
type GetDownloadURLReq struct {
|
type GetDownloadURLReq struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
@ -111,21 +110,19 @@ type GetRTCInvitationInfoStartAppResp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FCM第三方上报Token
|
* FCM第三方上报Token.
|
||||||
*/
|
*/
|
||||||
type FcmUpdateTokenReq struct {
|
type FcmUpdateTokenReq struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
Platform int `json:"platform" binding:"required,min=1,max=2"` //only for ios + android
|
Platform int `json:"platform" binding:"required,min=1,max=2"` // only for ios + android
|
||||||
FcmToken string `json:"fcmToken" binding:"required"`
|
FcmToken string `json:"fcmToken" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FcmUpdateTokenResp struct {
|
type FcmUpdateTokenResp struct{}
|
||||||
}
|
|
||||||
type SetAppBadgeReq struct {
|
type SetAppBadgeReq struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
FromUserID string `json:"fromUserID" binding:"required"`
|
FromUserID string `json:"fromUserID" binding:"required"`
|
||||||
AppUnreadCount int32 `json:"appUnreadCount"`
|
AppUnreadCount int32 `json:"appUnreadCount"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SetAppBadgeResp struct {
|
type SetAppBadgeResp struct{}
|
||||||
}
|
|
||||||
|
@ -16,7 +16,7 @@ package callbackstruct
|
|||||||
|
|
||||||
type CallbackUserOnlineReq struct {
|
type CallbackUserOnlineReq struct {
|
||||||
UserStatusCallbackReq
|
UserStatusCallbackReq
|
||||||
//Token string `json:"token"`
|
// Token string `json:"token"`
|
||||||
Seq int64 `json:"seq"`
|
Seq int64 `json:"seq"`
|
||||||
IsAppBackground bool `json:"isAppBackground"`
|
IsAppBackground bool `json:"isAppBackground"`
|
||||||
ConnID string `json:"connID"`
|
ConnID string `json:"connID"`
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -17,7 +17,7 @@ package constant
|
|||||||
const (
|
const (
|
||||||
|
|
||||||
///ContentType
|
///ContentType
|
||||||
//UserRelated
|
//UserRelated.
|
||||||
ContentTypeBegin = 100
|
ContentTypeBegin = 100
|
||||||
Text = 101
|
Text = 101
|
||||||
Picture = 102
|
Picture = 102
|
||||||
@ -45,23 +45,23 @@ const (
|
|||||||
SignalMsg = 202
|
SignalMsg = 202
|
||||||
CustomNotification = 203
|
CustomNotification = 203
|
||||||
|
|
||||||
//SysRelated
|
//SysRelated.
|
||||||
NotificationBegin = 1000
|
NotificationBegin = 1000
|
||||||
|
|
||||||
FriendApplicationApprovedNotification = 1201 //add_friend_response
|
FriendApplicationApprovedNotification = 1201 // add_friend_response
|
||||||
FriendApplicationRejectedNotification = 1202 //add_friend_response
|
FriendApplicationRejectedNotification = 1202 // add_friend_response
|
||||||
FriendApplicationNotification = 1203 //add_friend
|
FriendApplicationNotification = 1203 // add_friend
|
||||||
FriendAddedNotification = 1204
|
FriendAddedNotification = 1204
|
||||||
FriendDeletedNotification = 1205 //delete_friend
|
FriendDeletedNotification = 1205 // delete_friend
|
||||||
FriendRemarkSetNotification = 1206 //set_friend_remark?
|
FriendRemarkSetNotification = 1206 // set_friend_remark?
|
||||||
BlackAddedNotification = 1207 //add_black
|
BlackAddedNotification = 1207 // add_black
|
||||||
BlackDeletedNotification = 1208 //remove_black
|
BlackDeletedNotification = 1208 // remove_black
|
||||||
FriendInfoUpdatedNotification = 1209
|
FriendInfoUpdatedNotification = 1209
|
||||||
|
|
||||||
ConversationChangeNotification = 1300 // change conversation opt
|
ConversationChangeNotification = 1300 // change conversation opt
|
||||||
|
|
||||||
UserNotificationBegin = 1301
|
UserNotificationBegin = 1301
|
||||||
UserInfoUpdatedNotification = 1303 //SetSelfInfoTip = 204
|
UserInfoUpdatedNotification = 1303 // SetSelfInfoTip = 204
|
||||||
UserNotificationEnd = 1399
|
UserNotificationEnd = 1399
|
||||||
OANotification = 1400
|
OANotification = 1400
|
||||||
|
|
||||||
@ -113,37 +113,37 @@ const (
|
|||||||
|
|
||||||
NotificationEnd = 5000
|
NotificationEnd = 5000
|
||||||
|
|
||||||
//status
|
//status.
|
||||||
MsgNormal = 1
|
MsgNormal = 1
|
||||||
MsgDeleted = 4
|
MsgDeleted = 4
|
||||||
|
|
||||||
//MsgFrom
|
//MsgFrom.
|
||||||
UserMsgType = 100
|
UserMsgType = 100
|
||||||
SysMsgType = 200
|
SysMsgType = 200
|
||||||
|
|
||||||
//SessionType
|
//SessionType.
|
||||||
SingleChatType = 1
|
SingleChatType = 1
|
||||||
GroupChatType = 2
|
GroupChatType = 2
|
||||||
SuperGroupChatType = 3
|
SuperGroupChatType = 3
|
||||||
NotificationChatType = 4
|
NotificationChatType = 4
|
||||||
//token
|
//token.
|
||||||
NormalToken = 0
|
NormalToken = 0
|
||||||
InValidToken = 1
|
InValidToken = 1
|
||||||
KickedToken = 2
|
KickedToken = 2
|
||||||
ExpiredToken = 3
|
ExpiredToken = 3
|
||||||
|
|
||||||
//MultiTerminalLogin
|
//MultiTerminalLogin.
|
||||||
DefalutNotKick = 0
|
DefalutNotKick = 0
|
||||||
//Full-end login, but the same end is mutually exclusive
|
//Full-end login, but the same end is mutually exclusive.
|
||||||
AllLoginButSameTermKick = 1
|
AllLoginButSameTermKick = 1
|
||||||
//Only one of the endpoints can log in
|
//Only one of the endpoints can log in.
|
||||||
SingleTerminalLogin = 2
|
SingleTerminalLogin = 2
|
||||||
//The web side can be online at the same time, and the other side can only log in at one end
|
//The web side can be online at the same time, and the other side can only log in at one end.
|
||||||
WebAndOther = 3
|
WebAndOther = 3
|
||||||
// The PC side is mutually exclusive, and the mobile side is mutually exclusive, but the web side can be online at
|
// The PC side is mutually exclusive, and the mobile side is mutually exclusive, but the web side can be online at
|
||||||
// the same time
|
// the same time.
|
||||||
PcMobileAndWeb = 4
|
PcMobileAndWeb = 4
|
||||||
//The PC terminal can be online at the same time,but other terminal only one of the endpoints can login
|
//The PC terminal can be online at the same time,but other terminal only one of the endpoints can login.
|
||||||
PCAndOther = 5
|
PCAndOther = 5
|
||||||
|
|
||||||
OnlineStatus = "online"
|
OnlineStatus = "online"
|
||||||
@ -151,12 +151,12 @@ const (
|
|||||||
Registered = "registered"
|
Registered = "registered"
|
||||||
UnRegistered = "unregistered"
|
UnRegistered = "unregistered"
|
||||||
|
|
||||||
//MsgReceiveOpt
|
//MsgReceiveOpt.
|
||||||
ReceiveMessage = 0
|
ReceiveMessage = 0
|
||||||
NotReceiveMessage = 1
|
NotReceiveMessage = 1
|
||||||
ReceiveNotNotifyMessage = 2
|
ReceiveNotNotifyMessage = 2
|
||||||
|
|
||||||
//OptionsKey
|
//OptionsKey.
|
||||||
IsHistory = "history"
|
IsHistory = "history"
|
||||||
IsPersistent = "persistent"
|
IsPersistent = "persistent"
|
||||||
IsOfflinePush = "offlinePush"
|
IsOfflinePush = "offlinePush"
|
||||||
@ -170,13 +170,13 @@ const (
|
|||||||
IsNotNotification = "isNotNotification"
|
IsNotNotification = "isNotNotification"
|
||||||
IsSendMsg = "isSendMsg"
|
IsSendMsg = "isSendMsg"
|
||||||
|
|
||||||
//GroupStatus
|
//GroupStatus.
|
||||||
GroupOk = 0
|
GroupOk = 0
|
||||||
GroupBanChat = 1
|
GroupBanChat = 1
|
||||||
GroupStatusDismissed = 2
|
GroupStatusDismissed = 2
|
||||||
GroupStatusMuted = 3
|
GroupStatusMuted = 3
|
||||||
|
|
||||||
//GroupType
|
//GroupType.
|
||||||
NormalGroup = 0
|
NormalGroup = 0
|
||||||
SuperGroup = 1
|
SuperGroup = 1
|
||||||
WorkingGroup = 2
|
WorkingGroup = 2
|
||||||
@ -184,19 +184,19 @@ const (
|
|||||||
GroupBaned = 3
|
GroupBaned = 3
|
||||||
GroupBanPrivateChat = 4
|
GroupBanPrivateChat = 4
|
||||||
|
|
||||||
//UserJoinGroupSource
|
//UserJoinGroupSource.
|
||||||
JoinByAdmin = 1
|
JoinByAdmin = 1
|
||||||
|
|
||||||
JoinByInvitation = 2
|
JoinByInvitation = 2
|
||||||
JoinBySearch = 3
|
JoinBySearch = 3
|
||||||
JoinByQRCode = 4
|
JoinByQRCode = 4
|
||||||
|
|
||||||
//Minio
|
//Minio.
|
||||||
MinioDurationTimes = 3600
|
MinioDurationTimes = 3600
|
||||||
//Aws
|
//Aws.
|
||||||
AwsDurationTimes = 3600
|
AwsDurationTimes = 3600
|
||||||
|
|
||||||
//callbackCommand
|
//callbackCommand.
|
||||||
CallbackBeforeSendSingleMsgCommand = "callbackBeforeSendSingleMsgCommand"
|
CallbackBeforeSendSingleMsgCommand = "callbackBeforeSendSingleMsgCommand"
|
||||||
CallbackAfterSendSingleMsgCommand = "callbackAfterSendSingleMsgCommand"
|
CallbackAfterSendSingleMsgCommand = "callbackAfterSendSingleMsgCommand"
|
||||||
CallbackBeforeSendGroupMsgCommand = "callbackBeforeSendGroupMsgCommand"
|
CallbackBeforeSendGroupMsgCommand = "callbackBeforeSendGroupMsgCommand"
|
||||||
@ -217,19 +217,19 @@ const (
|
|||||||
CallbackGetMessageListReactionExtensionsCommand = "callbackGetMessageListReactionExtensionsCommand"
|
CallbackGetMessageListReactionExtensionsCommand = "callbackGetMessageListReactionExtensionsCommand"
|
||||||
CallbackAddMessageListReactionExtensionsCommand = "callbackAddMessageListReactionExtensionsCommand"
|
CallbackAddMessageListReactionExtensionsCommand = "callbackAddMessageListReactionExtensionsCommand"
|
||||||
|
|
||||||
//callback actionCode
|
//callback actionCode.
|
||||||
ActionAllow = 0
|
ActionAllow = 0
|
||||||
ActionForbidden = 1
|
ActionForbidden = 1
|
||||||
//callback callbackHandleCode
|
//callback callbackHandleCode.
|
||||||
CallbackHandleSuccess = 0
|
CallbackHandleSuccess = 0
|
||||||
CallbackHandleFailed = 1
|
CallbackHandleFailed = 1
|
||||||
|
|
||||||
// minioUpload
|
// minioUpload.
|
||||||
OtherType = 1
|
OtherType = 1
|
||||||
VideoType = 2
|
VideoType = 2
|
||||||
ImageType = 3
|
ImageType = 3
|
||||||
|
|
||||||
// sendMsgStaus
|
// sendMsgStaus.
|
||||||
MsgStatusNotExist = 0
|
MsgStatusNotExist = 0
|
||||||
MsgIsSending = 1
|
MsgIsSending = 1
|
||||||
MsgSendSuccessed = 2
|
MsgSendSuccessed = 2
|
||||||
@ -299,25 +299,27 @@ const (
|
|||||||
Female = 2
|
Female = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
const OperationID = "operationID"
|
const (
|
||||||
const OpUserID = "opUserID"
|
OperationID = "operationID"
|
||||||
const ConnID = "connID"
|
OpUserID = "opUserID"
|
||||||
const OpUserPlatform = "platform"
|
ConnID = "connID"
|
||||||
const Token = "token"
|
OpUserPlatform = "platform"
|
||||||
const RpcCustomHeader = "customHeader" // rpc中间件自定义ctx参数
|
Token = "token"
|
||||||
const CheckKey = "CheckKey"
|
RpcCustomHeader = "customHeader" // rpc中间件自定义ctx参数
|
||||||
const TriggerID = "triggerID"
|
CheckKey = "CheckKey"
|
||||||
const RemoteAddr = "remoteAddr"
|
TriggerID = "triggerID"
|
||||||
|
RemoteAddr = "remoteAddr"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
BecomeFriendByImport = 1 //管理员导入
|
BecomeFriendByImport = 1 // 管理员导入
|
||||||
BecomeFriendByApply = 2 //申请添加
|
BecomeFriendByApply = 2 // 申请添加
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ApplyNeedVerificationInviteDirectly = 0 // 申请需要同意 邀请直接进
|
ApplyNeedVerificationInviteDirectly = 0 // 申请需要同意 邀请直接进
|
||||||
AllNeedVerification = 1 //所有人进群需要验证,除了群主管理员邀请进群
|
AllNeedVerification = 1 // 所有人进群需要验证,除了群主管理员邀请进群
|
||||||
Directly = 2 //直接进群
|
Directly = 2 // 直接进群
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -345,7 +347,7 @@ const LogFileName = "OpenIM.log"
|
|||||||
|
|
||||||
const LocalHost = "0.0.0.0"
|
const LocalHost = "0.0.0.0"
|
||||||
|
|
||||||
// flag parse
|
// flag parse.
|
||||||
const (
|
const (
|
||||||
FlagPort = "port"
|
FlagPort = "port"
|
||||||
FlagWsPort = "ws_port"
|
FlagWsPort = "ws_port"
|
||||||
|
@ -15,10 +15,9 @@
|
|||||||
package constant
|
package constant
|
||||||
|
|
||||||
// fixme 1<--->IOS 2<--->Android 3<--->Windows
|
// fixme 1<--->IOS 2<--->Android 3<--->Windows
|
||||||
//fixme 4<--->OSX 5<--->Web 6<--->MiniWeb 7<--->Linux
|
// fixme 4<--->OSX 5<--->Web 6<--->MiniWeb 7<--->Linux
|
||||||
|
|
||||||
const (
|
const (
|
||||||
//Platform ID
|
//Platform ID.
|
||||||
IOSPlatformID = 1
|
IOSPlatformID = 1
|
||||||
AndroidPlatformID = 2
|
AndroidPlatformID = 2
|
||||||
WindowsPlatformID = 3
|
WindowsPlatformID = 3
|
||||||
@ -30,7 +29,7 @@ const (
|
|||||||
IPadPlatformID = 9
|
IPadPlatformID = 9
|
||||||
AdminPlatformID = 10
|
AdminPlatformID = 10
|
||||||
|
|
||||||
//Platform string match to Platform ID
|
//Platform string match to Platform ID.
|
||||||
IOSPlatformStr = "IOS"
|
IOSPlatformStr = "IOS"
|
||||||
AndroidPlatformStr = "Android"
|
AndroidPlatformStr = "Android"
|
||||||
WindowsPlatformStr = "Windows"
|
WindowsPlatformStr = "Windows"
|
||||||
@ -42,7 +41,7 @@ const (
|
|||||||
IPadPlatformStr = "IPad"
|
IPadPlatformStr = "IPad"
|
||||||
AdminPlatformStr = "Admin"
|
AdminPlatformStr = "Admin"
|
||||||
|
|
||||||
//terminal types
|
//terminal types.
|
||||||
TerminalPC = "PC"
|
TerminalPC = "PC"
|
||||||
TerminalMobile = "Mobile"
|
TerminalMobile = "Mobile"
|
||||||
)
|
)
|
||||||
@ -59,6 +58,7 @@ var PlatformID2Name = map[int]string{
|
|||||||
IPadPlatformID: IPadPlatformStr,
|
IPadPlatformID: IPadPlatformStr,
|
||||||
AdminPlatformID: AdminPlatformStr,
|
AdminPlatformID: AdminPlatformStr,
|
||||||
}
|
}
|
||||||
|
|
||||||
var PlatformName2ID = map[string]int{
|
var PlatformName2ID = map[string]int{
|
||||||
IOSPlatformStr: IOSPlatformID,
|
IOSPlatformStr: IOSPlatformID,
|
||||||
AndroidPlatformStr: AndroidPlatformID,
|
AndroidPlatformStr: AndroidPlatformID,
|
||||||
@ -71,6 +71,7 @@ var PlatformName2ID = map[string]int{
|
|||||||
IPadPlatformStr: IPadPlatformID,
|
IPadPlatformStr: IPadPlatformID,
|
||||||
AdminPlatformStr: AdminPlatformID,
|
AdminPlatformStr: AdminPlatformID,
|
||||||
}
|
}
|
||||||
|
|
||||||
var PlatformName2class = map[string]string{
|
var PlatformName2class = map[string]string{
|
||||||
IOSPlatformStr: TerminalMobile,
|
IOSPlatformStr: TerminalMobile,
|
||||||
AndroidPlatformStr: TerminalMobile,
|
AndroidPlatformStr: TerminalMobile,
|
||||||
@ -80,6 +81,7 @@ var PlatformName2class = map[string]string{
|
|||||||
OSXPlatformStr: TerminalPC,
|
OSXPlatformStr: TerminalPC,
|
||||||
LinuxPlatformStr: TerminalPC,
|
LinuxPlatformStr: TerminalPC,
|
||||||
}
|
}
|
||||||
|
|
||||||
var PlatformID2class = map[int]string{
|
var PlatformID2class = map[int]string{
|
||||||
IOSPlatformID: TerminalMobile,
|
IOSPlatformID: TerminalMobile,
|
||||||
AndroidPlatformID: TerminalMobile,
|
AndroidPlatformID: TerminalMobile,
|
||||||
@ -93,12 +95,15 @@ var PlatformID2class = map[int]string{
|
|||||||
func PlatformIDToName(num int) string {
|
func PlatformIDToName(num int) string {
|
||||||
return PlatformID2Name[num]
|
return PlatformID2Name[num]
|
||||||
}
|
}
|
||||||
|
|
||||||
func PlatformNameToID(name string) int {
|
func PlatformNameToID(name string) int {
|
||||||
return PlatformName2ID[name]
|
return PlatformName2ID[name]
|
||||||
}
|
}
|
||||||
|
|
||||||
func PlatformNameToClass(name string) string {
|
func PlatformNameToClass(name string) string {
|
||||||
return PlatformName2class[name]
|
return PlatformName2class[name]
|
||||||
}
|
}
|
||||||
|
|
||||||
func PlatformIDToClass(num int) string {
|
func PlatformIDToClass(num int) string {
|
||||||
return PlatformID2class[num]
|
return PlatformID2class[num]
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -14,22 +28,13 @@ import (
|
|||||||
|
|
||||||
type ConversationDatabase interface {
|
type ConversationDatabase interface {
|
||||||
//UpdateUserConversationFiled 更新用户该会话的属性信息
|
//UpdateUserConversationFiled 更新用户该会话的属性信息
|
||||||
UpdateUsersConversationFiled(
|
UpdateUsersConversationFiled(ctx context.Context, userIDs []string, conversationID string, args map[string]interface{}) error
|
||||||
ctx context.Context,
|
|
||||||
userIDs []string,
|
|
||||||
conversationID string,
|
|
||||||
args map[string]interface{},
|
|
||||||
) error
|
|
||||||
//CreateConversation 创建一批新的会话
|
//CreateConversation 创建一批新的会话
|
||||||
CreateConversation(ctx context.Context, conversations []*relationTb.ConversationModel) error
|
CreateConversation(ctx context.Context, conversations []*relationTb.ConversationModel) error
|
||||||
//SyncPeerUserPrivateConversation 同步对端私聊会话内部保证事务操作
|
//SyncPeerUserPrivateConversation 同步对端私聊会话内部保证事务操作
|
||||||
SyncPeerUserPrivateConversationTx(ctx context.Context, conversation []*relationTb.ConversationModel) error
|
SyncPeerUserPrivateConversationTx(ctx context.Context, conversation []*relationTb.ConversationModel) error
|
||||||
//FindConversations 根据会话ID获取某个用户的多个会话
|
//FindConversations 根据会话ID获取某个用户的多个会话
|
||||||
FindConversations(
|
FindConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationTb.ConversationModel, error)
|
||||||
ctx context.Context,
|
|
||||||
ownerUserID string,
|
|
||||||
conversationIDs []string,
|
|
||||||
) ([]*relationTb.ConversationModel, error)
|
|
||||||
//FindRecvMsgNotNotifyUserIDs 获取超级大群开启免打扰的用户ID
|
//FindRecvMsgNotNotifyUserIDs 获取超级大群开启免打扰的用户ID
|
||||||
FindRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) ([]string, error)
|
FindRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) ([]string, error)
|
||||||
//GetUserAllConversation 获取一个用户在服务器上所有的会话
|
//GetUserAllConversation 获取一个用户在服务器上所有的会话
|
||||||
@ -37,29 +42,17 @@ type ConversationDatabase interface {
|
|||||||
//SetUserConversations 设置用户多个会话属性,如果会话不存在则创建,否则更新,内部保证原子性
|
//SetUserConversations 设置用户多个会话属性,如果会话不存在则创建,否则更新,内部保证原子性
|
||||||
SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error
|
SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error
|
||||||
//SetUsersConversationFiledTx 设置多个用户会话关于某个字段的更新操作,如果会话不存在则创建,否则更新,内部保证事务操作
|
//SetUsersConversationFiledTx 设置多个用户会话关于某个字段的更新操作,如果会话不存在则创建,否则更新,内部保证事务操作
|
||||||
SetUsersConversationFiledTx(
|
SetUsersConversationFiledTx(ctx context.Context, userIDs []string, conversation *relationTb.ConversationModel, filedMap map[string]interface{}) error
|
||||||
ctx context.Context,
|
|
||||||
userIDs []string,
|
|
||||||
conversation *relationTb.ConversationModel,
|
|
||||||
filedMap map[string]interface{},
|
|
||||||
) error
|
|
||||||
CreateGroupChatConversation(ctx context.Context, groupID string, userIDs []string) error
|
CreateGroupChatConversation(ctx context.Context, groupID string, userIDs []string) error
|
||||||
GetConversationIDs(ctx context.Context, userID string) ([]string, error)
|
GetConversationIDs(ctx context.Context, userID string) ([]string, error)
|
||||||
GetUserConversationIDsHash(ctx context.Context, ownerUserID string) (hash uint64, err error)
|
GetUserConversationIDsHash(ctx context.Context, ownerUserID string) (hash uint64, err error)
|
||||||
GetAllConversationIDs(ctx context.Context) ([]string, error)
|
GetAllConversationIDs(ctx context.Context) ([]string, error)
|
||||||
GetUserAllHasReadSeqs(ctx context.Context, ownerUserID string) (map[string]int64, error)
|
GetUserAllHasReadSeqs(ctx context.Context, ownerUserID string) (map[string]int64, error)
|
||||||
GetConversationsByConversationID(
|
GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*relationTb.ConversationModel, error)
|
||||||
ctx context.Context,
|
|
||||||
conversationIDs []string,
|
|
||||||
) ([]*relationTb.ConversationModel, error)
|
|
||||||
GetConversationIDsNeedDestruct(ctx context.Context) ([]*relationTb.ConversationModel, error)
|
GetConversationIDsNeedDestruct(ctx context.Context) ([]*relationTb.ConversationModel, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConversationDatabase(
|
func NewConversationDatabase(conversation relationTb.ConversationModelInterface, cache cache.ConversationCache, tx tx.Tx) ConversationDatabase {
|
||||||
conversation relationTb.ConversationModelInterface,
|
|
||||||
cache cache.ConversationCache,
|
|
||||||
tx tx.Tx,
|
|
||||||
) ConversationDatabase {
|
|
||||||
return &conversationDatabase{
|
return &conversationDatabase{
|
||||||
conversationDB: conversation,
|
conversationDB: conversation,
|
||||||
cache: cache,
|
cache: cache,
|
||||||
@ -73,12 +66,7 @@ type conversationDatabase struct {
|
|||||||
tx tx.Tx
|
tx tx.Tx
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationDatabase) SetUsersConversationFiledTx(
|
func (c *conversationDatabase) SetUsersConversationFiledTx(ctx context.Context, userIDs []string, conversation *relationTb.ConversationModel, filedMap map[string]interface{}) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
userIDs []string,
|
|
||||||
conversation *relationTb.ConversationModel,
|
|
||||||
filedMap map[string]interface{},
|
|
||||||
) (err error) {
|
|
||||||
cache := c.cache.NewCache()
|
cache := c.cache.NewCache()
|
||||||
if err := c.tx.Transaction(func(tx any) error {
|
if err := c.tx.Transaction(func(tx any) error {
|
||||||
conversationTx := c.conversationDB.NewTx(tx)
|
conversationTx := c.conversationDB.NewTx(tx)
|
||||||
@ -126,12 +114,7 @@ func (c *conversationDatabase) SetUsersConversationFiledTx(
|
|||||||
return cache.ExecDel(ctx)
|
return cache.ExecDel(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationDatabase) UpdateUsersConversationFiled(
|
func (c *conversationDatabase) UpdateUsersConversationFiled(ctx context.Context, userIDs []string, conversationID string, args map[string]interface{}) error {
|
||||||
ctx context.Context,
|
|
||||||
userIDs []string,
|
|
||||||
conversationID string,
|
|
||||||
args map[string]interface{},
|
|
||||||
) error {
|
|
||||||
_, err := c.conversationDB.UpdateByMap(ctx, userIDs, conversationID, args)
|
_, err := c.conversationDB.UpdateByMap(ctx, userIDs, conversationID, args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -139,10 +122,7 @@ func (c *conversationDatabase) UpdateUsersConversationFiled(
|
|||||||
return c.cache.DelUsersConversation(conversationID, userIDs...).ExecDel(ctx)
|
return c.cache.DelUsersConversation(conversationID, userIDs...).ExecDel(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationDatabase) CreateConversation(
|
func (c *conversationDatabase) CreateConversation(ctx context.Context, conversations []*relationTb.ConversationModel) error {
|
||||||
ctx context.Context,
|
|
||||||
conversations []*relationTb.ConversationModel,
|
|
||||||
) error {
|
|
||||||
if err := c.conversationDB.Create(ctx, conversations); err != nil {
|
if err := c.conversationDB.Create(ctx, conversations); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -155,10 +135,7 @@ func (c *conversationDatabase) CreateConversation(
|
|||||||
return cache.DelConversationIDs(userIDs...).DelUserConversationIDsHash(userIDs...).ExecDel(ctx)
|
return cache.DelConversationIDs(userIDs...).DelUserConversationIDsHash(userIDs...).ExecDel(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationDatabase) SyncPeerUserPrivateConversationTx(
|
func (c *conversationDatabase) SyncPeerUserPrivateConversationTx(ctx context.Context, conversations []*relationTb.ConversationModel) error {
|
||||||
ctx context.Context,
|
|
||||||
conversations []*relationTb.ConversationModel,
|
|
||||||
) error {
|
|
||||||
cache := c.cache.NewCache()
|
cache := c.cache.NewCache()
|
||||||
if err := c.tx.Transaction(func(tx any) error {
|
if err := c.tx.Transaction(func(tx any) error {
|
||||||
conversationTx := c.conversationDB.NewTx(tx)
|
conversationTx := c.conversationDB.NewTx(tx)
|
||||||
@ -196,34 +173,19 @@ func (c *conversationDatabase) SyncPeerUserPrivateConversationTx(
|
|||||||
return cache.ExecDel(ctx)
|
return cache.ExecDel(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationDatabase) FindConversations(
|
func (c *conversationDatabase) FindConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationTb.ConversationModel, error) {
|
||||||
ctx context.Context,
|
|
||||||
ownerUserID string,
|
|
||||||
conversationIDs []string,
|
|
||||||
) ([]*relationTb.ConversationModel, error) {
|
|
||||||
return c.cache.GetConversations(ctx, ownerUserID, conversationIDs)
|
return c.cache.GetConversations(ctx, ownerUserID, conversationIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationDatabase) GetConversation(
|
func (c *conversationDatabase) GetConversation(ctx context.Context, ownerUserID string, conversationID string) (*relationTb.ConversationModel, error) {
|
||||||
ctx context.Context,
|
|
||||||
ownerUserID string,
|
|
||||||
conversationID string,
|
|
||||||
) (*relationTb.ConversationModel, error) {
|
|
||||||
return c.cache.GetConversation(ctx, ownerUserID, conversationID)
|
return c.cache.GetConversation(ctx, ownerUserID, conversationID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationDatabase) GetUserAllConversation(
|
func (c *conversationDatabase) GetUserAllConversation(ctx context.Context, ownerUserID string) ([]*relationTb.ConversationModel, error) {
|
||||||
ctx context.Context,
|
|
||||||
ownerUserID string,
|
|
||||||
) ([]*relationTb.ConversationModel, error) {
|
|
||||||
return c.cache.GetUserAllConversations(ctx, ownerUserID)
|
return c.cache.GetUserAllConversations(ctx, ownerUserID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationDatabase) SetUserConversations(
|
func (c *conversationDatabase) SetUserConversations(ctx context.Context, ownerUserID string, conversations []*relationTb.ConversationModel) error {
|
||||||
ctx context.Context,
|
|
||||||
ownerUserID string,
|
|
||||||
conversations []*relationTb.ConversationModel,
|
|
||||||
) error {
|
|
||||||
cache := c.cache.NewCache()
|
cache := c.cache.NewCache()
|
||||||
if err := c.tx.Transaction(func(tx any) error {
|
if err := c.tx.Transaction(func(tx any) error {
|
||||||
var conversationIDs []string
|
var conversationIDs []string
|
||||||
@ -273,11 +235,7 @@ func (c *conversationDatabase) FindRecvMsgNotNotifyUserIDs(ctx context.Context,
|
|||||||
return c.cache.GetSuperGroupRecvMsgNotNotifyUserIDs(ctx, groupID)
|
return c.cache.GetSuperGroupRecvMsgNotNotifyUserIDs(ctx, groupID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationDatabase) CreateGroupChatConversation(
|
func (c *conversationDatabase) CreateGroupChatConversation(ctx context.Context, groupID string, userIDs []string) error {
|
||||||
ctx context.Context,
|
|
||||||
groupID string,
|
|
||||||
userIDs []string,
|
|
||||||
) error {
|
|
||||||
cache := c.cache.NewCache()
|
cache := c.cache.NewCache()
|
||||||
conversationID := utils.GetConversationIDBySessionType(constant.SuperGroupChatType, groupID)
|
conversationID := utils.GetConversationIDBySessionType(constant.SuperGroupChatType, groupID)
|
||||||
if err := c.tx.Transaction(func(tx any) error {
|
if err := c.tx.Transaction(func(tx any) error {
|
||||||
@ -317,10 +275,7 @@ func (c *conversationDatabase) GetConversationIDs(ctx context.Context, userID st
|
|||||||
return c.cache.GetUserConversationIDs(ctx, userID)
|
return c.cache.GetUserConversationIDs(ctx, userID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationDatabase) GetUserConversationIDsHash(
|
func (c *conversationDatabase) GetUserConversationIDsHash(ctx context.Context, ownerUserID string) (hash uint64, err error) {
|
||||||
ctx context.Context,
|
|
||||||
ownerUserID string,
|
|
||||||
) (hash uint64, err error) {
|
|
||||||
return c.cache.GetUserConversationIDsHash(ctx, ownerUserID)
|
return c.cache.GetUserConversationIDsHash(ctx, ownerUserID)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,22 +283,14 @@ func (c *conversationDatabase) GetAllConversationIDs(ctx context.Context) ([]str
|
|||||||
return c.conversationDB.GetAllConversationIDs(ctx)
|
return c.conversationDB.GetAllConversationIDs(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationDatabase) GetUserAllHasReadSeqs(
|
func (c *conversationDatabase) GetUserAllHasReadSeqs(ctx context.Context, ownerUserID string) (map[string]int64, error) {
|
||||||
ctx context.Context,
|
|
||||||
ownerUserID string,
|
|
||||||
) (map[string]int64, error) {
|
|
||||||
return c.cache.GetUserAllHasReadSeqs(ctx, ownerUserID)
|
return c.cache.GetUserAllHasReadSeqs(ctx, ownerUserID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationDatabase) GetConversationsByConversationID(
|
func (c *conversationDatabase) GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*relationTb.ConversationModel, error) {
|
||||||
ctx context.Context,
|
|
||||||
conversationIDs []string,
|
|
||||||
) ([]*relationTb.ConversationModel, error) {
|
|
||||||
return c.conversationDB.GetConversationsByConversationID(ctx, conversationIDs)
|
return c.conversationDB.GetConversationsByConversationID(ctx, conversationIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *conversationDatabase) GetConversationIDsNeedDestruct(
|
func (c *conversationDatabase) GetConversationIDsNeedDestruct(ctx context.Context) ([]*relationTb.ConversationModel, error) {
|
||||||
ctx context.Context,
|
|
||||||
) ([]*relationTb.ConversationModel, error) {
|
|
||||||
return c.conversationDB.GetConversationIDsNeedDestruct(ctx)
|
return c.conversationDB.GetConversationIDsNeedDestruct(ctx)
|
||||||
}
|
}
|
||||||
|
@ -573,10 +573,6 @@ func (g *groupDatabase) CountTotal(ctx context.Context, before *time.Time) (coun
|
|||||||
return g.groupDB.CountTotal(ctx, before)
|
return g.groupDB.CountTotal(ctx, before)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *groupDatabase) CountRangeEverydayTotal(
|
func (g *groupDatabase) CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error) {
|
||||||
ctx context.Context,
|
|
||||||
start time.Time,
|
|
||||||
end time.Time,
|
|
||||||
) (map[string]int64, error) {
|
|
||||||
return g.groupDB.CountRangeEverydayTotal(ctx, start, end)
|
return g.groupDB.CountRangeEverydayTotal(ctx, start, end)
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -21,11 +35,10 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
|
||||||
|
|
||||||
pbMsg "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
|
pbMsg "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||||
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -44,36 +57,16 @@ type CommonMsgDatabase interface {
|
|||||||
DeleteMessagesFromCache(ctx context.Context, conversationID string, seqs []int64) error
|
DeleteMessagesFromCache(ctx context.Context, conversationID string, seqs []int64) error
|
||||||
DelUserDeleteMsgsList(ctx context.Context, conversationID string, seqs []int64)
|
DelUserDeleteMsgsList(ctx context.Context, conversationID string, seqs []int64)
|
||||||
// incrSeq然后批量插入缓存
|
// incrSeq然后批量插入缓存
|
||||||
BatchInsertChat2Cache(
|
BatchInsertChat2Cache(ctx context.Context, conversationID string, msgs []*sdkws.MsgData) (seq int64, isNewConversation bool, err error)
|
||||||
ctx context.Context,
|
|
||||||
conversationID string,
|
|
||||||
msgs []*sdkws.MsgData,
|
|
||||||
) (seq int64, isNewConversation bool, err error)
|
|
||||||
|
|
||||||
// 通过seqList获取mongo中写扩散消息
|
// 通过seqList获取mongo中写扩散消息
|
||||||
GetMsgBySeqsRange(
|
GetMsgBySeqsRange(ctx context.Context, userID string, conversationID string, begin, end, num, userMaxSeq int64) (minSeq int64, maxSeq int64, seqMsg []*sdkws.MsgData, err error)
|
||||||
ctx context.Context,
|
|
||||||
userID string,
|
|
||||||
conversationID string,
|
|
||||||
begin, end, num, userMaxSeq int64,
|
|
||||||
) (minSeq int64, maxSeq int64, seqMsg []*sdkws.MsgData, err error)
|
|
||||||
// 通过seqList获取大群在 mongo里面的消息
|
// 通过seqList获取大群在 mongo里面的消息
|
||||||
GetMsgBySeqs(
|
GetMsgBySeqs(ctx context.Context, userID string, conversationID string, seqs []int64) (minSeq int64, maxSeq int64, seqMsg []*sdkws.MsgData, err error)
|
||||||
ctx context.Context,
|
|
||||||
userID string,
|
|
||||||
conversationID string,
|
|
||||||
seqs []int64,
|
|
||||||
) (minSeq int64, maxSeq int64, seqMsg []*sdkws.MsgData, err error)
|
|
||||||
// 删除会话消息重置最小seq, remainTime为消息保留的时间单位秒,超时消息删除, 传0删除所有消息(此方法不删除redis cache)
|
// 删除会话消息重置最小seq, remainTime为消息保留的时间单位秒,超时消息删除, 传0删除所有消息(此方法不删除redis cache)
|
||||||
DeleteConversationMsgsAndSetMinSeq(ctx context.Context, conversationID string, remainTime int64) error
|
DeleteConversationMsgsAndSetMinSeq(ctx context.Context, conversationID string, remainTime int64) error
|
||||||
// 用户标记删除过期消息返回标记删除的seq列表
|
// 用户标记删除过期消息返回标记删除的seq列表
|
||||||
UserMsgsDestruct(
|
UserMsgsDestruct(cte context.Context, userID string, conversationID string, destructTime int64, lastMsgDestructTime time.Time) (seqs []int64, err error)
|
||||||
cte context.Context,
|
|
||||||
userID string,
|
|
||||||
conversationID string,
|
|
||||||
destructTime int64,
|
|
||||||
lastMsgDestructTime time.Time,
|
|
||||||
) (seqs []int64, err error)
|
|
||||||
|
|
||||||
// 用户根据seq删除消息
|
// 用户根据seq删除消息
|
||||||
DeleteUserMsgsBySeqs(ctx context.Context, userID string, conversationID string, seqs []int64) error
|
DeleteUserMsgsBySeqs(ctx context.Context, userID string, conversationID string, seqs []int64) error
|
||||||
@ -99,10 +92,7 @@ type CommonMsgDatabase interface {
|
|||||||
UserSetHasReadSeqs(ctx context.Context, userID string, hasReadSeqs map[string]int64) error
|
UserSetHasReadSeqs(ctx context.Context, userID string, hasReadSeqs map[string]int64) error
|
||||||
|
|
||||||
GetMongoMaxAndMinSeq(ctx context.Context, conversationID string) (minSeqMongo, maxSeqMongo int64, err error)
|
GetMongoMaxAndMinSeq(ctx context.Context, conversationID string) (minSeqMongo, maxSeqMongo int64, err error)
|
||||||
GetConversationMinMaxSeqInMongoAndCache(
|
GetConversationMinMaxSeqInMongoAndCache(ctx context.Context, conversationID string) (minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache int64, err error)
|
||||||
ctx context.Context,
|
|
||||||
conversationID string,
|
|
||||||
) (minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache int64, err error)
|
|
||||||
SetSendMsgStatus(ctx context.Context, id string, status int32) error
|
SetSendMsgStatus(ctx context.Context, id string, status int32) error
|
||||||
GetSendMsgStatus(ctx context.Context, id string) (int32, error)
|
GetSendMsgStatus(ctx context.Context, id string) (int32, error)
|
||||||
SearchMessage(ctx context.Context, req *pbMsg.SearchMessageReq) (msgData []*sdkws.MsgData, err error)
|
SearchMessage(ctx context.Context, req *pbMsg.SearchMessageReq) (msgData []*sdkws.MsgData, err error)
|
||||||
@ -113,23 +103,8 @@ type CommonMsgDatabase interface {
|
|||||||
MsgToPushMQ(ctx context.Context, key, conversarionID string, msg2mq *sdkws.MsgData) (int32, int64, error)
|
MsgToPushMQ(ctx context.Context, key, conversarionID string, msg2mq *sdkws.MsgData) (int32, int64, error)
|
||||||
MsgToMongoMQ(ctx context.Context, key, conversarionID string, msgs []*sdkws.MsgData, lastSeq int64) error
|
MsgToMongoMQ(ctx context.Context, key, conversarionID string, msgs []*sdkws.MsgData, lastSeq int64) error
|
||||||
|
|
||||||
RangeUserSendCount(
|
RangeUserSendCount(ctx context.Context, start time.Time, end time.Time, group bool, ase bool, pageNumber int32, showNumber int32) (msgCount int64, userCount int64, users []*unRelationTb.UserCount, dateCount map[string]int64, err error)
|
||||||
ctx context.Context,
|
RangeGroupSendCount(ctx context.Context, start time.Time, end time.Time, ase bool, pageNumber int32, showNumber int32) (msgCount int64, userCount int64, groups []*unRelationTb.GroupCount, dateCount map[string]int64, err error)
|
||||||
start time.Time,
|
|
||||||
end time.Time,
|
|
||||||
group bool,
|
|
||||||
ase bool,
|
|
||||||
pageNumber int32,
|
|
||||||
showNumber int32,
|
|
||||||
) (msgCount int64, userCount int64, users []*unRelationTb.UserCount, dateCount map[string]int64, err error)
|
|
||||||
RangeGroupSendCount(
|
|
||||||
ctx context.Context,
|
|
||||||
start time.Time,
|
|
||||||
end time.Time,
|
|
||||||
ase bool,
|
|
||||||
pageNumber int32,
|
|
||||||
showNumber int32,
|
|
||||||
) (msgCount int64, userCount int64, groups []*unRelationTb.GroupCount, dateCount map[string]int64, err error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCommonMsgDatabase(msgDocModel unRelationTb.MsgDocModelInterface, cacheModel cache.MsgModel, msgMyqModel relation.ChatLogModelInterface) CommonMsgDatabase {
|
func NewCommonMsgDatabase(msgDocModel unRelationTb.MsgDocModelInterface, cacheModel cache.MsgModel, msgMyqModel relation.ChatLogModelInterface) CommonMsgDatabase {
|
||||||
@ -167,32 +142,16 @@ func (db *commonMsgDatabase) MsgToMQ(ctx context.Context, key string, msg2mq *sd
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) MsgToModifyMQ(
|
func (db *commonMsgDatabase) MsgToModifyMQ(ctx context.Context, key, conversationID string, messages []*sdkws.MsgData) error {
|
||||||
ctx context.Context,
|
|
||||||
key, conversationID string,
|
|
||||||
messages []*sdkws.MsgData,
|
|
||||||
) error {
|
|
||||||
if len(messages) > 0 {
|
if len(messages) > 0 {
|
||||||
_, _, err := db.producerToModify.SendMessage(
|
_, _, err := db.producerToModify.SendMessage(ctx, key, &pbMsg.MsgDataToModifyByMQ{ConversationID: conversationID, Messages: messages})
|
||||||
ctx,
|
|
||||||
key,
|
|
||||||
&pbMsg.MsgDataToModifyByMQ{ConversationID: conversationID, Messages: messages},
|
|
||||||
)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) MsgToPushMQ(
|
func (db *commonMsgDatabase) MsgToPushMQ(ctx context.Context, key, conversationID string, msg2mq *sdkws.MsgData) (int32, int64, error) {
|
||||||
ctx context.Context,
|
partition, offset, err := db.producerToPush.SendMessage(ctx, key, &pbMsg.PushMsgDataToMQ{MsgData: msg2mq, ConversationID: conversationID})
|
||||||
key, conversationID string,
|
|
||||||
msg2mq *sdkws.MsgData,
|
|
||||||
) (int32, int64, error) {
|
|
||||||
partition, offset, err := db.producerToPush.SendMessage(
|
|
||||||
ctx,
|
|
||||||
key,
|
|
||||||
&pbMsg.PushMsgDataToMQ{MsgData: msg2mq, ConversationID: conversationID},
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(ctx, "MsgToPushMQ", err, "key", key, "msg2mq", msg2mq)
|
log.ZError(ctx, "MsgToPushMQ", err, "key", key, "msg2mq", msg2mq)
|
||||||
return 0, 0, err
|
return 0, 0, err
|
||||||
@ -200,30 +159,15 @@ func (db *commonMsgDatabase) MsgToPushMQ(
|
|||||||
return partition, offset, nil
|
return partition, offset, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) MsgToMongoMQ(
|
func (db *commonMsgDatabase) MsgToMongoMQ(ctx context.Context, key, conversationID string, messages []*sdkws.MsgData, lastSeq int64) error {
|
||||||
ctx context.Context,
|
|
||||||
key, conversationID string,
|
|
||||||
messages []*sdkws.MsgData,
|
|
||||||
lastSeq int64,
|
|
||||||
) error {
|
|
||||||
if len(messages) > 0 {
|
if len(messages) > 0 {
|
||||||
_, _, err := db.producerToMongo.SendMessage(
|
_, _, err := db.producerToMongo.SendMessage(ctx, key, &pbMsg.MsgDataToMongoByMQ{LastSeq: lastSeq, ConversationID: conversationID, MsgData: messages})
|
||||||
ctx,
|
|
||||||
key,
|
|
||||||
&pbMsg.MsgDataToMongoByMQ{LastSeq: lastSeq, ConversationID: conversationID, MsgData: messages},
|
|
||||||
)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) BatchInsertBlock(
|
func (db *commonMsgDatabase) BatchInsertBlock(ctx context.Context, conversationID string, fields []any, key int8, firstSeq int64) error {
|
||||||
ctx context.Context,
|
|
||||||
conversationID string,
|
|
||||||
fields []any,
|
|
||||||
key int8,
|
|
||||||
firstSeq int64,
|
|
||||||
) error {
|
|
||||||
if len(fields) == 0 {
|
if len(fields) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -324,12 +268,7 @@ func (db *commonMsgDatabase) BatchInsertBlock(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) BatchInsertChat2DB(
|
func (db *commonMsgDatabase) BatchInsertChat2DB(ctx context.Context, conversationID string, msgList []*sdkws.MsgData, currentMaxSeq int64) error {
|
||||||
ctx context.Context,
|
|
||||||
conversationID string,
|
|
||||||
msgList []*sdkws.MsgData,
|
|
||||||
currentMaxSeq int64,
|
|
||||||
) error {
|
|
||||||
if len(msgList) == 0 {
|
if len(msgList) == 0 {
|
||||||
return errs.ErrArgs.Wrap("msgList is empty")
|
return errs.ErrArgs.Wrap("msgList is empty")
|
||||||
}
|
}
|
||||||
@ -375,21 +314,11 @@ func (db *commonMsgDatabase) BatchInsertChat2DB(
|
|||||||
return db.BatchInsertBlock(ctx, conversationID, msgs, updateKeyMsg, msgList[0].Seq)
|
return db.BatchInsertBlock(ctx, conversationID, msgs, updateKeyMsg, msgList[0].Seq)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) RevokeMsg(
|
func (db *commonMsgDatabase) RevokeMsg(ctx context.Context, conversationID string, seq int64, revoke *unRelationTb.RevokeModel) error {
|
||||||
ctx context.Context,
|
|
||||||
conversationID string,
|
|
||||||
seq int64,
|
|
||||||
revoke *unRelationTb.RevokeModel,
|
|
||||||
) error {
|
|
||||||
return db.BatchInsertBlock(ctx, conversationID, []any{revoke}, updateKeyRevoke, seq)
|
return db.BatchInsertBlock(ctx, conversationID, []any{revoke}, updateKeyRevoke, seq)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) MarkSingleChatMsgsAsRead(
|
func (db *commonMsgDatabase) MarkSingleChatMsgsAsRead(ctx context.Context, userID string, conversationID string, totalSeqs []int64) error {
|
||||||
ctx context.Context,
|
|
||||||
userID string,
|
|
||||||
conversationID string,
|
|
||||||
totalSeqs []int64,
|
|
||||||
) error {
|
|
||||||
for docID, seqs := range db.msg.GetDocIDSeqsMap(conversationID, totalSeqs) {
|
for docID, seqs := range db.msg.GetDocIDSeqsMap(conversationID, totalSeqs) {
|
||||||
var indexes []int64
|
var indexes []int64
|
||||||
for _, seq := range seqs {
|
for _, seq := range seqs {
|
||||||
@ -412,11 +341,7 @@ func (db *commonMsgDatabase) DelUserDeleteMsgsList(ctx context.Context, conversa
|
|||||||
db.cache.DelUserDeleteMsgsList(ctx, conversationID, seqs)
|
db.cache.DelUserDeleteMsgsList(ctx, conversationID, seqs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) BatchInsertChat2Cache(
|
func (db *commonMsgDatabase) BatchInsertChat2Cache(ctx context.Context, conversationID string, msgs []*sdkws.MsgData) (seq int64, isNew bool, err error) {
|
||||||
ctx context.Context,
|
|
||||||
conversationID string,
|
|
||||||
msgs []*sdkws.MsgData,
|
|
||||||
) (seq int64, isNew bool, err error) {
|
|
||||||
currentMaxSeq, err := db.cache.GetMaxSeq(ctx, conversationID)
|
currentMaxSeq, err := db.cache.GetMaxSeq(ctx, conversationID)
|
||||||
if err != nil && errs.Unwrap(err) != redis.Nil {
|
if err != nil && errs.Unwrap(err) != redis.Nil {
|
||||||
prome.Inc(prome.SeqGetFailedCounter)
|
prome.Inc(prome.SeqGetFailedCounter)
|
||||||
@ -463,11 +388,7 @@ func (db *commonMsgDatabase) BatchInsertChat2Cache(
|
|||||||
return lastMaxSeq, isNew, utils.Wrap(err, "")
|
return lastMaxSeq, isNew, utils.Wrap(err, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) getMsgBySeqs(
|
func (db *commonMsgDatabase) getMsgBySeqs(ctx context.Context, userID, conversationID string, seqs []int64) (totalMsgs []*sdkws.MsgData, err error) {
|
||||||
ctx context.Context,
|
|
||||||
userID, conversationID string,
|
|
||||||
seqs []int64,
|
|
||||||
) (totalMsgs []*sdkws.MsgData, err error) {
|
|
||||||
for docID, seqs := range db.msg.GetDocIDSeqsMap(conversationID, seqs) {
|
for docID, seqs := range db.msg.GetDocIDSeqsMap(conversationID, seqs) {
|
||||||
//log.ZDebug(ctx, "getMsgBySeqs", "docID", docID, "seqs", seqs)
|
//log.ZDebug(ctx, "getMsgBySeqs", "docID", docID, "seqs", seqs)
|
||||||
msgs, err := db.findMsgInfoBySeq(ctx, userID, docID, seqs)
|
msgs, err := db.findMsgInfoBySeq(ctx, userID, docID, seqs)
|
||||||
@ -481,11 +402,7 @@ func (db *commonMsgDatabase) getMsgBySeqs(
|
|||||||
return totalMsgs, nil
|
return totalMsgs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) findMsgInfoBySeq(
|
func (db *commonMsgDatabase) findMsgInfoBySeq(ctx context.Context, userID, docID string, seqs []int64) (totalMsgs []*unRelationTb.MsgInfoModel, err error) {
|
||||||
ctx context.Context,
|
|
||||||
userID, docID string,
|
|
||||||
seqs []int64,
|
|
||||||
) (totalMsgs []*unRelationTb.MsgInfoModel, err error) {
|
|
||||||
msgs, err := db.msgDocDatabase.GetMsgBySeqIndexIn1Doc(ctx, userID, docID, seqs)
|
msgs, err := db.msgDocDatabase.GetMsgBySeqIndexIn1Doc(ctx, userID, docID, seqs)
|
||||||
for _, msg := range msgs {
|
for _, msg := range msgs {
|
||||||
if msg.IsRead {
|
if msg.IsRead {
|
||||||
@ -495,25 +412,8 @@ func (db *commonMsgDatabase) findMsgInfoBySeq(
|
|||||||
return msgs, err
|
return msgs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) getMsgBySeqsRange(
|
func (db *commonMsgDatabase) getMsgBySeqsRange(ctx context.Context, userID string, conversationID string, allSeqs []int64, begin, end int64) (seqMsgs []*sdkws.MsgData, err error) {
|
||||||
ctx context.Context,
|
log.ZDebug(ctx, "getMsgBySeqsRange", "conversationID", conversationID, "allSeqs", allSeqs, "begin", begin, "end", end)
|
||||||
userID string,
|
|
||||||
conversationID string,
|
|
||||||
allSeqs []int64,
|
|
||||||
begin, end int64,
|
|
||||||
) (seqMsgs []*sdkws.MsgData, err error) {
|
|
||||||
log.ZDebug(
|
|
||||||
ctx,
|
|
||||||
"getMsgBySeqsRange",
|
|
||||||
"conversationID",
|
|
||||||
conversationID,
|
|
||||||
"allSeqs",
|
|
||||||
allSeqs,
|
|
||||||
"begin",
|
|
||||||
begin,
|
|
||||||
"end",
|
|
||||||
end,
|
|
||||||
)
|
|
||||||
for docID, seqs := range db.msg.GetDocIDSeqsMap(conversationID, allSeqs) {
|
for docID, seqs := range db.msg.GetDocIDSeqsMap(conversationID, allSeqs) {
|
||||||
log.ZDebug(ctx, "getMsgBySeqsRange", "docID", docID, "seqs", seqs)
|
log.ZDebug(ctx, "getMsgBySeqsRange", "docID", docID, "seqs", seqs)
|
||||||
msgs, err := db.findMsgInfoBySeq(ctx, userID, docID, seqs)
|
msgs, err := db.findMsgInfoBySeq(ctx, userID, docID, seqs)
|
||||||
@ -530,12 +430,7 @@ func (db *commonMsgDatabase) getMsgBySeqsRange(
|
|||||||
return seqMsgs, nil
|
return seqMsgs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) GetMsgBySeqsRange(
|
func (db *commonMsgDatabase) GetMsgBySeqsRange(ctx context.Context, userID string, conversationID string, begin, end, num, userMaxSeq int64) (int64, int64, []*sdkws.MsgData, error) {
|
||||||
ctx context.Context,
|
|
||||||
userID string,
|
|
||||||
conversationID string,
|
|
||||||
begin, end, num, userMaxSeq int64,
|
|
||||||
) (int64, int64, []*sdkws.MsgData, error) {
|
|
||||||
userMinSeq, err := db.cache.GetConversationUserMinSeq(ctx, conversationID, userID)
|
userMinSeq, err := db.cache.GetConversationUserMinSeq(ctx, conversationID, userID)
|
||||||
if err != nil && errs.Unwrap(err) != redis.Nil {
|
if err != nil && errs.Unwrap(err) != redis.Nil {
|
||||||
return 0, 0, nil, err
|
return 0, 0, nil, err
|
||||||
@ -555,18 +450,7 @@ func (db *commonMsgDatabase) GetMsgBySeqsRange(
|
|||||||
if err != nil && errs.Unwrap(err) != redis.Nil {
|
if err != nil && errs.Unwrap(err) != redis.Nil {
|
||||||
return 0, 0, nil, err
|
return 0, 0, nil, err
|
||||||
}
|
}
|
||||||
log.ZDebug(
|
log.ZDebug(ctx, "GetMsgBySeqsRange", "userMinSeq", userMinSeq, "conMinSeq", minSeq, "conMaxSeq", maxSeq, "userMaxSeq", userMaxSeq)
|
||||||
ctx,
|
|
||||||
"GetMsgBySeqsRange",
|
|
||||||
"userMinSeq",
|
|
||||||
userMinSeq,
|
|
||||||
"conMinSeq",
|
|
||||||
minSeq,
|
|
||||||
"conMaxSeq",
|
|
||||||
maxSeq,
|
|
||||||
"userMaxSeq",
|
|
||||||
userMaxSeq,
|
|
||||||
)
|
|
||||||
if userMaxSeq != 0 {
|
if userMaxSeq != 0 {
|
||||||
if userMaxSeq < maxSeq {
|
if userMaxSeq < maxSeq {
|
||||||
maxSeq = userMaxSeq
|
maxSeq = userMaxSeq
|
||||||
@ -616,18 +500,7 @@ func (db *commonMsgDatabase) GetMsgBySeqsRange(
|
|||||||
cacheDelNum += 1
|
cacheDelNum += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.ZDebug(
|
log.ZDebug(ctx, "get delSeqs from redis", "delSeqs", delSeqs, "userID", userID, "conversationID", conversationID, "cacheDelNum", cacheDelNum)
|
||||||
ctx,
|
|
||||||
"get delSeqs from redis",
|
|
||||||
"delSeqs",
|
|
||||||
delSeqs,
|
|
||||||
"userID",
|
|
||||||
userID,
|
|
||||||
"conversationID",
|
|
||||||
conversationID,
|
|
||||||
"cacheDelNum",
|
|
||||||
cacheDelNum,
|
|
||||||
)
|
|
||||||
var reGetSeqsCache []int64
|
var reGetSeqsCache []int64
|
||||||
for i := 1; i <= cacheDelNum; {
|
for i := 1; i <= cacheDelNum; {
|
||||||
newSeq := newBegin - int64(i)
|
newSeq := newBegin - int64(i)
|
||||||
@ -647,15 +520,7 @@ func (db *commonMsgDatabase) GetMsgBySeqsRange(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if err != redis.Nil {
|
if err != redis.Nil {
|
||||||
prome.Add(prome.MsgPullFromRedisFailedCounter, len(failedSeqs2))
|
prome.Add(prome.MsgPullFromRedisFailedCounter, len(failedSeqs2))
|
||||||
log.ZError(
|
log.ZError(ctx, "get message from redis exception", err, "conversationID", conversationID, "seqs", reGetSeqsCache)
|
||||||
ctx,
|
|
||||||
"get message from redis exception",
|
|
||||||
err,
|
|
||||||
"conversationID",
|
|
||||||
conversationID,
|
|
||||||
"seqs",
|
|
||||||
reGetSeqsCache,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
failedSeqs = append(failedSeqs, failedSeqs2...)
|
failedSeqs = append(failedSeqs, failedSeqs2...)
|
||||||
@ -681,12 +546,7 @@ func (db *commonMsgDatabase) GetMsgBySeqsRange(
|
|||||||
return minSeq, maxSeq, successMsgs, nil
|
return minSeq, maxSeq, successMsgs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) GetMsgBySeqs(
|
func (db *commonMsgDatabase) GetMsgBySeqs(ctx context.Context, userID string, conversationID string, seqs []int64) (int64, int64, []*sdkws.MsgData, error) {
|
||||||
ctx context.Context,
|
|
||||||
userID string,
|
|
||||||
conversationID string,
|
|
||||||
seqs []int64,
|
|
||||||
) (int64, int64, []*sdkws.MsgData, error) {
|
|
||||||
userMinSeq, err := db.cache.GetConversationUserMinSeq(ctx, conversationID, userID)
|
userMinSeq, err := db.cache.GetConversationUserMinSeq(ctx, conversationID, userID)
|
||||||
if err != nil && errs.Unwrap(err) != redis.Nil {
|
if err != nil && errs.Unwrap(err) != redis.Nil {
|
||||||
return 0, 0, nil, err
|
return 0, 0, nil, err
|
||||||
@ -712,33 +572,10 @@ func (db *commonMsgDatabase) GetMsgBySeqs(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if err != redis.Nil {
|
if err != redis.Nil {
|
||||||
prome.Add(prome.MsgPullFromRedisFailedCounter, len(failedSeqs))
|
prome.Add(prome.MsgPullFromRedisFailedCounter, len(failedSeqs))
|
||||||
log.ZError(
|
log.ZError(ctx, "get message from redis exception", err, "failedSeqs", failedSeqs, "conversationID", conversationID)
|
||||||
ctx,
|
|
||||||
"get message from redis exception",
|
|
||||||
err,
|
|
||||||
"failedSeqs",
|
|
||||||
failedSeqs,
|
|
||||||
"conversationID",
|
|
||||||
conversationID,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.ZInfo(
|
log.ZInfo(ctx, "db.cache.GetMessagesBySeq", "userID", userID, "conversationID", conversationID, "seqs", seqs, "successMsgs", len(successMsgs), "failedSeqs", failedSeqs, "conversationID", conversationID)
|
||||||
ctx,
|
|
||||||
"db.cache.GetMessagesBySeq",
|
|
||||||
"userID",
|
|
||||||
userID,
|
|
||||||
"conversationID",
|
|
||||||
conversationID,
|
|
||||||
"seqs",
|
|
||||||
seqs,
|
|
||||||
"successMsgs",
|
|
||||||
len(successMsgs),
|
|
||||||
"failedSeqs",
|
|
||||||
failedSeqs,
|
|
||||||
"conversationID",
|
|
||||||
conversationID,
|
|
||||||
)
|
|
||||||
prome.Add(prome.MsgPullFromRedisSuccessCounter, len(successMsgs))
|
prome.Add(prome.MsgPullFromRedisSuccessCounter, len(successMsgs))
|
||||||
if len(failedSeqs) > 0 {
|
if len(failedSeqs) > 0 {
|
||||||
mongoMsgs, err := db.getMsgBySeqs(ctx, userID, conversationID, failedSeqs)
|
mongoMsgs, err := db.getMsgBySeqs(ctx, userID, conversationID, failedSeqs)
|
||||||
@ -752,11 +589,7 @@ func (db *commonMsgDatabase) GetMsgBySeqs(
|
|||||||
return minSeq, maxSeq, successMsgs, nil
|
return minSeq, maxSeq, successMsgs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) DeleteConversationMsgsAndSetMinSeq(
|
func (db *commonMsgDatabase) DeleteConversationMsgsAndSetMinSeq(ctx context.Context, conversationID string, remainTime int64) error {
|
||||||
ctx context.Context,
|
|
||||||
conversationID string,
|
|
||||||
remainTime int64,
|
|
||||||
) error {
|
|
||||||
var delStruct delMsgRecursionStruct
|
var delStruct delMsgRecursionStruct
|
||||||
var skip int64
|
var skip int64
|
||||||
minSeq, err := db.deleteMsgRecursion(ctx, conversationID, skip, &delStruct, remainTime)
|
minSeq, err := db.deleteMsgRecursion(ctx, conversationID, skip, &delStruct, remainTime)
|
||||||
@ -776,13 +609,7 @@ func (db *commonMsgDatabase) DeleteConversationMsgsAndSetMinSeq(
|
|||||||
return db.cache.SetMinSeq(ctx, conversationID, minSeq)
|
return db.cache.SetMinSeq(ctx, conversationID, minSeq)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) UserMsgsDestruct(
|
func (db *commonMsgDatabase) UserMsgsDestruct(ctx context.Context, userID string, conversationID string, destructTime int64, lastMsgDestructTime time.Time) (seqs []int64, err error) {
|
||||||
ctx context.Context,
|
|
||||||
userID string,
|
|
||||||
conversationID string,
|
|
||||||
destructTime int64,
|
|
||||||
lastMsgDestructTime time.Time,
|
|
||||||
) (seqs []int64, err error) {
|
|
||||||
var index int64
|
var index int64
|
||||||
for {
|
for {
|
||||||
// from oldest 2 newest
|
// from oldest 2 newest
|
||||||
@ -790,16 +617,7 @@ func (db *commonMsgDatabase) UserMsgsDestruct(
|
|||||||
if err != nil || msgDocModel.DocID == "" {
|
if err != nil || msgDocModel.DocID == "" {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == unrelation.ErrMsgListNotExist {
|
if err == unrelation.ErrMsgListNotExist {
|
||||||
log.ZDebug(
|
log.ZDebug(ctx, "deleteMsgRecursion finished", "conversationID", conversationID, "userID", userID, "index", index)
|
||||||
ctx,
|
|
||||||
"deleteMsgRecursion finished",
|
|
||||||
"conversationID",
|
|
||||||
conversationID,
|
|
||||||
"userID",
|
|
||||||
userID,
|
|
||||||
"index",
|
|
||||||
index,
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
log.ZError(ctx, "deleteMsgRecursion GetUserMsgListByIndex failed", err, "conversationID", conversationID, "index", index)
|
log.ZError(ctx, "deleteMsgRecursion GetUserMsgListByIndex failed", err, "conversationID", conversationID, "index", index)
|
||||||
}
|
}
|
||||||
@ -848,26 +666,13 @@ func (d *delMsgRecursionStruct) getSetMinSeq() int64 {
|
|||||||
// seq 70
|
// seq 70
|
||||||
// set minSeq 21
|
// set minSeq 21
|
||||||
// recursion 删除list并且返回设置的最小seq
|
// recursion 删除list并且返回设置的最小seq
|
||||||
func (db *commonMsgDatabase) deleteMsgRecursion(
|
func (db *commonMsgDatabase) deleteMsgRecursion(ctx context.Context, conversationID string, index int64, delStruct *delMsgRecursionStruct, remainTime int64) (int64, error) {
|
||||||
ctx context.Context,
|
|
||||||
conversationID string,
|
|
||||||
index int64,
|
|
||||||
delStruct *delMsgRecursionStruct,
|
|
||||||
remainTime int64,
|
|
||||||
) (int64, error) {
|
|
||||||
// find from oldest list
|
// find from oldest list
|
||||||
msgDocModel, err := db.msgDocDatabase.GetMsgDocModelByIndex(ctx, conversationID, index, 1)
|
msgDocModel, err := db.msgDocDatabase.GetMsgDocModelByIndex(ctx, conversationID, index, 1)
|
||||||
if err != nil || msgDocModel.DocID == "" {
|
if err != nil || msgDocModel.DocID == "" {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == unrelation.ErrMsgListNotExist {
|
if err == unrelation.ErrMsgListNotExist {
|
||||||
log.ZDebug(
|
log.ZDebug(ctx, "deleteMsgRecursion ErrMsgListNotExist", "conversationID", conversationID, "index:", index)
|
||||||
ctx,
|
|
||||||
"deleteMsgRecursion ErrMsgListNotExist",
|
|
||||||
"conversationID",
|
|
||||||
conversationID,
|
|
||||||
"index:",
|
|
||||||
index,
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
log.ZError(ctx, "deleteMsgRecursion GetUserMsgListByIndex failed", err, "conversationID", conversationID, "index", index)
|
log.ZError(ctx, "deleteMsgRecursion GetUserMsgListByIndex failed", err, "conversationID", conversationID, "index", index)
|
||||||
}
|
}
|
||||||
@ -879,23 +684,11 @@ func (db *commonMsgDatabase) deleteMsgRecursion(
|
|||||||
}
|
}
|
||||||
return delStruct.getSetMinSeq() + 1, nil
|
return delStruct.getSetMinSeq() + 1, nil
|
||||||
}
|
}
|
||||||
log.ZDebug(
|
log.ZDebug(ctx, "doc info", "conversationID", conversationID, "index", index, "docID", msgDocModel.DocID, "len", len(msgDocModel.Msg))
|
||||||
ctx,
|
|
||||||
"doc info",
|
|
||||||
"conversationID",
|
|
||||||
conversationID,
|
|
||||||
"index",
|
|
||||||
index,
|
|
||||||
"docID",
|
|
||||||
msgDocModel.DocID,
|
|
||||||
"len",
|
|
||||||
len(msgDocModel.Msg),
|
|
||||||
)
|
|
||||||
if int64(len(msgDocModel.Msg)) > db.msg.GetSingleGocMsgNum() {
|
if int64(len(msgDocModel.Msg)) > db.msg.GetSingleGocMsgNum() {
|
||||||
log.ZWarn(ctx, "msgs too large", nil, "lenth", len(msgDocModel.Msg), "docID:", msgDocModel.DocID)
|
log.ZWarn(ctx, "msgs too large", nil, "lenth", len(msgDocModel.Msg), "docID:", msgDocModel.DocID)
|
||||||
}
|
}
|
||||||
if msgDocModel.IsFull() &&
|
if msgDocModel.IsFull() && msgDocModel.Msg[len(msgDocModel.Msg)-1].Msg.SendTime+(remainTime*1000) < utils.GetCurrentTimestampByMill() {
|
||||||
msgDocModel.Msg[len(msgDocModel.Msg)-1].Msg.SendTime+(remainTime*1000) < utils.GetCurrentTimestampByMill() {
|
|
||||||
log.ZDebug(ctx, "doc is full and all msg is expired", "docID", msgDocModel.DocID)
|
log.ZDebug(ctx, "doc is full and all msg is expired", "docID", msgDocModel.DocID)
|
||||||
delStruct.delDocIDs = append(delStruct.delDocIDs, msgDocModel.DocID)
|
delStruct.delDocIDs = append(delStruct.delDocIDs, msgDocModel.DocID)
|
||||||
delStruct.minSeq = msgDocModel.Msg[len(msgDocModel.Msg)-1].Msg.Seq
|
delStruct.minSeq = msgDocModel.Msg[len(msgDocModel.Msg)-1].Msg.Seq
|
||||||
@ -932,11 +725,7 @@ func (db *commonMsgDatabase) deleteMsgRecursion(
|
|||||||
return seq, err
|
return seq, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) DeleteMsgsPhysicalBySeqs(
|
func (db *commonMsgDatabase) DeleteMsgsPhysicalBySeqs(ctx context.Context, conversationID string, allSeqs []int64) error {
|
||||||
ctx context.Context,
|
|
||||||
conversationID string,
|
|
||||||
allSeqs []int64,
|
|
||||||
) error {
|
|
||||||
if err := db.cache.DeleteMessages(ctx, conversationID, allSeqs); err != nil {
|
if err := db.cache.DeleteMessages(ctx, conversationID, allSeqs); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -952,12 +741,7 @@ func (db *commonMsgDatabase) DeleteMsgsPhysicalBySeqs(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) DeleteUserMsgsBySeqs(
|
func (db *commonMsgDatabase) DeleteUserMsgsBySeqs(ctx context.Context, userID string, conversationID string, seqs []int64) error {
|
||||||
ctx context.Context,
|
|
||||||
userID string,
|
|
||||||
conversationID string,
|
|
||||||
seqs []int64,
|
|
||||||
) error {
|
|
||||||
cachedMsgs, _, err := db.cache.GetMessagesBySeq(ctx, conversationID, seqs)
|
cachedMsgs, _, err := db.cache.GetMessagesBySeq(ctx, conversationID, seqs)
|
||||||
if err != nil && errs.Unwrap(err) != redis.Nil {
|
if err != nil && errs.Unwrap(err) != redis.Nil {
|
||||||
log.ZWarn(ctx, "DeleteUserMsgsBySeqs", err, "conversationID", conversationID, "seqs", seqs)
|
log.ZWarn(ctx, "DeleteUserMsgsBySeqs", err, "conversationID", conversationID, "seqs", seqs)
|
||||||
@ -1026,70 +810,31 @@ func (db *commonMsgDatabase) GetMinSeqs(ctx context.Context, conversationIDs []s
|
|||||||
func (db *commonMsgDatabase) GetMinSeq(ctx context.Context, conversationID string) (int64, error) {
|
func (db *commonMsgDatabase) GetMinSeq(ctx context.Context, conversationID string) (int64, error) {
|
||||||
return db.cache.GetMinSeq(ctx, conversationID)
|
return db.cache.GetMinSeq(ctx, conversationID)
|
||||||
}
|
}
|
||||||
|
func (db *commonMsgDatabase) GetConversationUserMinSeq(ctx context.Context, conversationID string, userID string) (int64, error) {
|
||||||
func (db *commonMsgDatabase) GetConversationUserMinSeq(
|
|
||||||
ctx context.Context,
|
|
||||||
conversationID string,
|
|
||||||
userID string,
|
|
||||||
) (int64, error) {
|
|
||||||
return db.cache.GetConversationUserMinSeq(ctx, conversationID, userID)
|
return db.cache.GetConversationUserMinSeq(ctx, conversationID, userID)
|
||||||
}
|
}
|
||||||
|
func (db *commonMsgDatabase) GetConversationUserMinSeqs(ctx context.Context, conversationID string, userIDs []string) (map[string]int64, error) {
|
||||||
func (db *commonMsgDatabase) GetConversationUserMinSeqs(
|
|
||||||
ctx context.Context,
|
|
||||||
conversationID string,
|
|
||||||
userIDs []string,
|
|
||||||
) (map[string]int64, error) {
|
|
||||||
return db.cache.GetConversationUserMinSeqs(ctx, conversationID, userIDs)
|
return db.cache.GetConversationUserMinSeqs(ctx, conversationID, userIDs)
|
||||||
}
|
}
|
||||||
|
func (db *commonMsgDatabase) SetConversationUserMinSeq(ctx context.Context, conversationID string, userID string, minSeq int64) error {
|
||||||
func (db *commonMsgDatabase) SetConversationUserMinSeq(
|
|
||||||
ctx context.Context,
|
|
||||||
conversationID string,
|
|
||||||
userID string,
|
|
||||||
minSeq int64,
|
|
||||||
) error {
|
|
||||||
return db.cache.SetConversationUserMinSeq(ctx, conversationID, userID, minSeq)
|
return db.cache.SetConversationUserMinSeq(ctx, conversationID, userID, minSeq)
|
||||||
}
|
}
|
||||||
|
func (db *commonMsgDatabase) SetConversationUserMinSeqs(ctx context.Context, conversationID string, seqs map[string]int64) (err error) {
|
||||||
func (db *commonMsgDatabase) SetConversationUserMinSeqs(
|
|
||||||
ctx context.Context,
|
|
||||||
conversationID string,
|
|
||||||
seqs map[string]int64,
|
|
||||||
) (err error) {
|
|
||||||
return db.cache.SetConversationUserMinSeqs(ctx, conversationID, seqs)
|
return db.cache.SetConversationUserMinSeqs(ctx, conversationID, seqs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) SetUserConversationsMinSeqs(
|
func (db *commonMsgDatabase) SetUserConversationsMinSeqs(ctx context.Context, userID string, seqs map[string]int64) error {
|
||||||
ctx context.Context,
|
|
||||||
userID string,
|
|
||||||
seqs map[string]int64,
|
|
||||||
) error {
|
|
||||||
return db.cache.SetUserConversationsMinSeqs(ctx, userID, seqs)
|
return db.cache.SetUserConversationsMinSeqs(ctx, userID, seqs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) UserSetHasReadSeqs(
|
func (db *commonMsgDatabase) UserSetHasReadSeqs(ctx context.Context, userID string, hasReadSeqs map[string]int64) error {
|
||||||
ctx context.Context,
|
|
||||||
userID string,
|
|
||||||
hasReadSeqs map[string]int64,
|
|
||||||
) error {
|
|
||||||
return db.cache.UserSetHasReadSeqs(ctx, userID, hasReadSeqs)
|
return db.cache.UserSetHasReadSeqs(ctx, userID, hasReadSeqs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) SetHasReadSeq(
|
func (db *commonMsgDatabase) SetHasReadSeq(ctx context.Context, userID string, conversationID string, hasReadSeq int64) error {
|
||||||
ctx context.Context,
|
|
||||||
userID string,
|
|
||||||
conversationID string,
|
|
||||||
hasReadSeq int64,
|
|
||||||
) error {
|
|
||||||
return db.cache.SetHasReadSeq(ctx, userID, conversationID, hasReadSeq)
|
return db.cache.SetHasReadSeq(ctx, userID, conversationID, hasReadSeq)
|
||||||
}
|
}
|
||||||
|
func (db *commonMsgDatabase) GetHasReadSeqs(ctx context.Context, userID string, conversationIDs []string) (map[string]int64, error) {
|
||||||
func (db *commonMsgDatabase) GetHasReadSeqs(
|
|
||||||
ctx context.Context,
|
|
||||||
userID string,
|
|
||||||
conversationIDs []string,
|
|
||||||
) (map[string]int64, error) {
|
|
||||||
return db.cache.GetHasReadSeqs(ctx, userID, conversationIDs)
|
return db.cache.GetHasReadSeqs(ctx, userID, conversationIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1105,10 +850,7 @@ func (db *commonMsgDatabase) GetSendMsgStatus(ctx context.Context, id string) (i
|
|||||||
return db.cache.GetSendMsgStatus(ctx, id)
|
return db.cache.GetSendMsgStatus(ctx, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) GetConversationMinMaxSeqInMongoAndCache(
|
func (db *commonMsgDatabase) GetConversationMinMaxSeqInMongoAndCache(ctx context.Context, conversationID string) (minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache int64, err error) {
|
||||||
ctx context.Context,
|
|
||||||
conversationID string,
|
|
||||||
) (minSeqMongo, maxSeqMongo, minSeqCache, maxSeqCache int64, err error) {
|
|
||||||
minSeqMongo, maxSeqMongo, err = db.GetMinMaxSeqMongo(ctx, conversationID)
|
minSeqMongo, maxSeqMongo, err = db.GetMinMaxSeqMongo(ctx, conversationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -1124,17 +866,11 @@ func (db *commonMsgDatabase) GetConversationMinMaxSeqInMongoAndCache(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) GetMongoMaxAndMinSeq(
|
func (db *commonMsgDatabase) GetMongoMaxAndMinSeq(ctx context.Context, conversationID string) (minSeqMongo, maxSeqMongo int64, err error) {
|
||||||
ctx context.Context,
|
|
||||||
conversationID string,
|
|
||||||
) (minSeqMongo, maxSeqMongo int64, err error) {
|
|
||||||
return db.GetMinMaxSeqMongo(ctx, conversationID)
|
return db.GetMinMaxSeqMongo(ctx, conversationID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) GetMinMaxSeqMongo(
|
func (db *commonMsgDatabase) GetMinMaxSeqMongo(ctx context.Context, conversationID string) (minSeqMongo, maxSeqMongo int64, err error) {
|
||||||
ctx context.Context,
|
|
||||||
conversationID string,
|
|
||||||
) (minSeqMongo, maxSeqMongo int64, err error) {
|
|
||||||
oldestMsgMongo, err := db.msgDocDatabase.GetOldestMsg(ctx, conversationID)
|
oldestMsgMongo, err := db.msgDocDatabase.GetOldestMsg(ctx, conversationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -1148,26 +884,11 @@ func (db *commonMsgDatabase) GetMinMaxSeqMongo(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) RangeUserSendCount(
|
func (db *commonMsgDatabase) RangeUserSendCount(ctx context.Context, start time.Time, end time.Time, group bool, ase bool, pageNumber int32, showNumber int32) (msgCount int64, userCount int64, users []*unRelationTb.UserCount, dateCount map[string]int64, err error) {
|
||||||
ctx context.Context,
|
|
||||||
start time.Time,
|
|
||||||
end time.Time,
|
|
||||||
group bool,
|
|
||||||
ase bool,
|
|
||||||
pageNumber int32,
|
|
||||||
showNumber int32,
|
|
||||||
) (msgCount int64, userCount int64, users []*unRelationTb.UserCount, dateCount map[string]int64, err error) {
|
|
||||||
return db.msgDocDatabase.RangeUserSendCount(ctx, start, end, group, ase, pageNumber, showNumber)
|
return db.msgDocDatabase.RangeUserSendCount(ctx, start, end, group, ase, pageNumber, showNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *commonMsgDatabase) RangeGroupSendCount(
|
func (db *commonMsgDatabase) RangeGroupSendCount(ctx context.Context, start time.Time, end time.Time, ase bool, pageNumber int32, showNumber int32) (msgCount int64, userCount int64, groups []*unRelationTb.GroupCount, dateCount map[string]int64, err error) {
|
||||||
ctx context.Context,
|
|
||||||
start time.Time,
|
|
||||||
end time.Time,
|
|
||||||
ase bool,
|
|
||||||
pageNumber int32,
|
|
||||||
showNumber int32,
|
|
||||||
) (msgCount int64, userCount int64, groups []*unRelationTb.GroupCount, dateCount map[string]int64, err error) {
|
|
||||||
return db.msgDocDatabase.RangeGroupSendCount(ctx, start, end, ase, pageNumber, showNumber)
|
return db.msgDocDatabase.RangeGroupSendCount(ctx, start, end, ase, pageNumber, showNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,26 +1,33 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"path/filepath"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/cont"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3/cont"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
|
||||||
|
"path/filepath"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type S3Database interface {
|
type S3Database interface {
|
||||||
PartLimit() *s3.PartLimit
|
PartLimit() *s3.PartLimit
|
||||||
PartSize(ctx context.Context, size int64) (int64, error)
|
PartSize(ctx context.Context, size int64) (int64, error)
|
||||||
AuthSign(ctx context.Context, uploadID string, partNumbers []int) (*s3.AuthSignResult, error)
|
AuthSign(ctx context.Context, uploadID string, partNumbers []int) (*s3.AuthSignResult, error)
|
||||||
InitiateMultipartUpload(
|
InitiateMultipartUpload(ctx context.Context, hash string, size int64, expire time.Duration, maxParts int) (*cont.InitiateUploadResult, error)
|
||||||
ctx context.Context,
|
|
||||||
hash string,
|
|
||||||
size int64,
|
|
||||||
expire time.Duration,
|
|
||||||
maxParts int,
|
|
||||||
) (*cont.InitiateUploadResult, error)
|
|
||||||
CompleteMultipartUpload(ctx context.Context, uploadID string, parts []string) (*cont.UploadResult, error)
|
CompleteMultipartUpload(ctx context.Context, uploadID string, parts []string) (*cont.UploadResult, error)
|
||||||
AccessURL(ctx context.Context, name string, expire time.Duration) (time.Time, string, error)
|
AccessURL(ctx context.Context, name string, expire time.Duration) (time.Time, string, error)
|
||||||
SetObject(ctx context.Context, info *relation.ObjectModel) error
|
SetObject(ctx context.Context, info *relation.ObjectModel) error
|
||||||
@ -50,21 +57,11 @@ func (s *s3Database) AuthSign(ctx context.Context, uploadID string, partNumbers
|
|||||||
return s.s3.AuthSign(ctx, uploadID, partNumbers)
|
return s.s3.AuthSign(ctx, uploadID, partNumbers)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *s3Database) InitiateMultipartUpload(
|
func (s *s3Database) InitiateMultipartUpload(ctx context.Context, hash string, size int64, expire time.Duration, maxParts int) (*cont.InitiateUploadResult, error) {
|
||||||
ctx context.Context,
|
|
||||||
hash string,
|
|
||||||
size int64,
|
|
||||||
expire time.Duration,
|
|
||||||
maxParts int,
|
|
||||||
) (*cont.InitiateUploadResult, error) {
|
|
||||||
return s.s3.InitiateUpload(ctx, hash, size, expire, maxParts)
|
return s.s3.InitiateUpload(ctx, hash, size, expire, maxParts)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *s3Database) CompleteMultipartUpload(
|
func (s *s3Database) CompleteMultipartUpload(ctx context.Context, uploadID string, parts []string) (*cont.UploadResult, error) {
|
||||||
ctx context.Context,
|
|
||||||
uploadID string,
|
|
||||||
parts []string,
|
|
||||||
) (*cont.UploadResult, error) {
|
|
||||||
return s.s3.CompleteUpload(ctx, uploadID, parts)
|
return s.s3.CompleteUpload(ctx, uploadID, parts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package relation
|
package relation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package relation
|
package relation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -36,13 +50,7 @@ func (g *GroupGorm) UpdateMap(ctx context.Context, groupID string, args map[stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupGorm) UpdateStatus(ctx context.Context, groupID string, status int32) (err error) {
|
func (g *GroupGorm) UpdateStatus(ctx context.Context, groupID string, status int32) (err error) {
|
||||||
return utils.Wrap(
|
return utils.Wrap(g.DB.Where("group_id = ?", groupID).Model(&relation.GroupModel{}).Updates(map[string]any{"status": status}).Error, "")
|
||||||
g.DB.Where("group_id = ?", groupID).
|
|
||||||
Model(&relation.GroupModel{}).
|
|
||||||
Updates(map[string]any{"status": status}).
|
|
||||||
Error,
|
|
||||||
"",
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupGorm) Find(ctx context.Context, groupIDs []string) (groups []*relation.GroupModel, err error) {
|
func (g *GroupGorm) Find(ctx context.Context, groupIDs []string) (groups []*relation.GroupModel, err error) {
|
||||||
@ -54,21 +62,13 @@ func (g *GroupGorm) Take(ctx context.Context, groupID string) (group *relation.G
|
|||||||
return group, utils.Wrap(g.DB.Where("group_id = ?", groupID).Take(group).Error, "")
|
return group, utils.Wrap(g.DB.Where("group_id = ?", groupID).Take(group).Error, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupGorm) Search(
|
func (g *GroupGorm) Search(ctx context.Context, keyword string, pageNumber, showNumber int32) (total uint32, groups []*relation.GroupModel, err error) {
|
||||||
ctx context.Context,
|
|
||||||
keyword string,
|
|
||||||
pageNumber, showNumber int32,
|
|
||||||
) (total uint32, groups []*relation.GroupModel, err error) {
|
|
||||||
db := g.DB
|
db := g.DB
|
||||||
db = db.WithContext(ctx).Where("status!=?", constant.GroupStatusDismissed)
|
db = db.WithContext(ctx).Where("status!=?", constant.GroupStatusDismissed)
|
||||||
return ormutil.GormSearch[relation.GroupModel](db, []string{"name"}, keyword, pageNumber, showNumber)
|
return ormutil.GormSearch[relation.GroupModel](db, []string{"name"}, keyword, pageNumber, showNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupGorm) GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error) {
|
func (g *GroupGorm) GetGroupIDsByGroupType(ctx context.Context, groupType int) (groupIDs []string, err error) {
|
||||||
return groupIDs, utils.Wrap(
|
return groupIDs, utils.Wrap(g.DB.Model(&relation.GroupModel{}).Where("group_type = ? ", groupType).Pluck("group_id", &groupIDs).Error, "")
|
||||||
g.DB.Model(&relation.GroupModel{}).Where("group_type = ? ", groupType).Pluck("group_id", &groupIDs).Error,
|
|
||||||
"",
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupGorm) CountTotal(ctx context.Context, before *time.Time) (count int64, err error) {
|
func (g *GroupGorm) CountTotal(ctx context.Context, before *time.Time) (count int64, err error) {
|
||||||
@ -82,22 +82,12 @@ func (g *GroupGorm) CountTotal(ctx context.Context, before *time.Time) (count in
|
|||||||
return count, nil
|
return count, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupGorm) CountRangeEverydayTotal(
|
func (g *GroupGorm) CountRangeEverydayTotal(ctx context.Context, start time.Time, end time.Time) (map[string]int64, error) {
|
||||||
ctx context.Context,
|
|
||||||
start time.Time,
|
|
||||||
end time.Time,
|
|
||||||
) (map[string]int64, error) {
|
|
||||||
var res []struct {
|
var res []struct {
|
||||||
Date time.Time `gorm:"column:date"`
|
Date time.Time `gorm:"column:date"`
|
||||||
Count int64 `gorm:"column:count"`
|
Count int64 `gorm:"column:count"`
|
||||||
}
|
}
|
||||||
err := g.db(ctx).
|
err := g.db(ctx).Model(&relation.GroupModel{}).Select("DATE(create_time) AS date, count(1) AS count").Where("create_time >= ? and create_time < ?", start, end).Group("date").Find(&res).Error
|
||||||
Model(&relation.GroupModel{}).
|
|
||||||
Select("DATE(create_time) AS date, count(1) AS count").
|
|
||||||
Where("create_time >= ? and create_time < ?", start, end).
|
|
||||||
Group("date").
|
|
||||||
Find(&res).
|
|
||||||
Error
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errs.Wrap(err)
|
return nil, errs.Wrap(err)
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package relation
|
package relation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package cont
|
package cont
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package cont
|
package cont
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -6,15 +20,13 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/google/uuid"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"path"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func New(impl s3.Interface) *Controller {
|
func New(impl s3.Interface) *Controller {
|
||||||
@ -58,13 +70,7 @@ func (c *Controller) GetHashObject(ctx context.Context, hash string) (*s3.Object
|
|||||||
return c.impl.StatObject(ctx, c.HashPath(hash))
|
return c.impl.StatObject(ctx, c.HashPath(hash))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Controller) InitiateUpload(
|
func (c *Controller) InitiateUpload(ctx context.Context, hash string, size int64, expire time.Duration, maxParts int) (*InitiateUploadResult, error) {
|
||||||
ctx context.Context,
|
|
||||||
hash string,
|
|
||||||
size int64,
|
|
||||||
expire time.Duration,
|
|
||||||
maxParts int,
|
|
||||||
) (*InitiateUploadResult, error) {
|
|
||||||
defer log.ZDebug(ctx, "return")
|
defer log.ZDebug(ctx, "return")
|
||||||
if size < 0 {
|
if size < 0 {
|
||||||
return nil, errors.New("invalid size")
|
return nil, errors.New("invalid size")
|
||||||
@ -247,11 +253,6 @@ func (c *Controller) IsNotFound(err error) bool {
|
|||||||
return c.impl.IsNotFound(err)
|
return c.impl.IsNotFound(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Controller) AccessURL(
|
func (c *Controller) AccessURL(ctx context.Context, name string, expire time.Duration, opt *s3.AccessURLOption) (string, error) {
|
||||||
ctx context.Context,
|
|
||||||
name string,
|
|
||||||
expire time.Duration,
|
|
||||||
opt *s3.AccessURLOption,
|
|
||||||
) (string, error) {
|
|
||||||
return c.impl.AccessURL(ctx, name, expire, opt)
|
return c.impl.AccessURL(ctx, name, expire, opt)
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,21 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package cont
|
package cont
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package cont
|
package cont
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package cont
|
package cont
|
||||||
|
|
||||||
import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
|
import "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
|
||||||
|
@ -1,19 +1,31 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package cos
|
package cos
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
|
||||||
|
"github.com/tencentyun/cos-go-sdk-v5"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/tencentyun/cos-go-sdk-v5"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -72,12 +84,7 @@ func (c *Cos) InitiateMultipartUpload(ctx context.Context, name string) (*s3.Ini
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cos) CompleteMultipartUpload(
|
func (c *Cos) CompleteMultipartUpload(ctx context.Context, uploadID string, name string, parts []s3.Part) (*s3.CompleteMultipartUploadResult, error) {
|
||||||
ctx context.Context,
|
|
||||||
uploadID string,
|
|
||||||
name string,
|
|
||||||
parts []s3.Part,
|
|
||||||
) (*s3.CompleteMultipartUploadResult, error) {
|
|
||||||
opts := &cos.CompleteMultipartUploadOptions{
|
opts := &cos.CompleteMultipartUploadOptions{
|
||||||
Parts: make([]cos.Object, len(parts)),
|
Parts: make([]cos.Object, len(parts)),
|
||||||
}
|
}
|
||||||
@ -116,13 +123,7 @@ func (c *Cos) PartSize(ctx context.Context, size int64) (int64, error) {
|
|||||||
return partSize, nil
|
return partSize, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cos) AuthSign(
|
func (c *Cos) AuthSign(ctx context.Context, uploadID string, name string, expire time.Duration, partNumbers []int) (*s3.AuthSignResult, error) {
|
||||||
ctx context.Context,
|
|
||||||
uploadID string,
|
|
||||||
name string,
|
|
||||||
expire time.Duration,
|
|
||||||
partNumbers []int,
|
|
||||||
) (*s3.AuthSignResult, error) {
|
|
||||||
result := s3.AuthSignResult{
|
result := s3.AuthSignResult{
|
||||||
URL: c.client.BaseURL.BucketURL.String() + "/" + cos.EncodeURIComponent(name),
|
URL: c.client.BaseURL.BucketURL.String() + "/" + cos.EncodeURIComponent(name),
|
||||||
Query: url.Values{"uploadId": {uploadID}},
|
Query: url.Values{"uploadId": {uploadID}},
|
||||||
@ -133,13 +134,7 @@ func (c *Cos) AuthSign(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
cos.AddAuthorizationHeader(
|
cos.AddAuthorizationHeader(c.credential.SecretID, c.credential.SecretKey, c.credential.SessionToken, req, cos.NewAuthTime(expire))
|
||||||
c.credential.SecretID,
|
|
||||||
c.credential.SecretKey,
|
|
||||||
c.credential.SessionToken,
|
|
||||||
req,
|
|
||||||
cos.NewAuthTime(expire),
|
|
||||||
)
|
|
||||||
result.Header = req.Header
|
result.Header = req.Header
|
||||||
for i, partNumber := range partNumbers {
|
for i, partNumber := range partNumbers {
|
||||||
result.Parts[i] = s3.SignPart{
|
result.Parts[i] = s3.SignPart{
|
||||||
@ -151,15 +146,7 @@ func (c *Cos) AuthSign(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cos) PresignedPutObject(ctx context.Context, name string, expire time.Duration) (string, error) {
|
func (c *Cos) PresignedPutObject(ctx context.Context, name string, expire time.Duration) (string, error) {
|
||||||
rawURL, err := c.client.Object.GetPresignedURL(
|
rawURL, err := c.client.Object.GetPresignedURL(ctx, http.MethodPut, name, c.credential.SecretID, c.credential.SecretKey, expire, nil)
|
||||||
ctx,
|
|
||||||
http.MethodPut,
|
|
||||||
name,
|
|
||||||
c.credential.SecretID,
|
|
||||||
c.credential.SecretKey,
|
|
||||||
expire,
|
|
||||||
nil,
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@ -231,13 +218,7 @@ func (c *Cos) AbortMultipartUpload(ctx context.Context, uploadID string, name st
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cos) ListUploadedParts(
|
func (c *Cos) ListUploadedParts(ctx context.Context, uploadID string, name string, partNumberMarker int, maxParts int) (*s3.ListUploadedPartsResult, error) {
|
||||||
ctx context.Context,
|
|
||||||
uploadID string,
|
|
||||||
name string,
|
|
||||||
partNumberMarker int,
|
|
||||||
maxParts int,
|
|
||||||
) (*s3.ListUploadedPartsResult, error) {
|
|
||||||
result, _, err := c.client.Object.ListParts(ctx, name, uploadID, &cos.ObjectListPartsOptions{
|
result, _, err := c.client.Object.ListParts(ctx, name, uploadID, &cos.ObjectListPartsOptions{
|
||||||
MaxParts: strconv.Itoa(maxParts),
|
MaxParts: strconv.Itoa(maxParts),
|
||||||
PartNumberMarker: strconv.Itoa(partNumberMarker),
|
PartNumberMarker: strconv.Itoa(partNumberMarker),
|
||||||
@ -264,12 +245,7 @@ func (c *Cos) ListUploadedParts(
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cos) AccessURL(
|
func (c *Cos) AccessURL(ctx context.Context, name string, expire time.Duration, opt *s3.AccessURLOption) (string, error) {
|
||||||
ctx context.Context,
|
|
||||||
name string,
|
|
||||||
expire time.Duration,
|
|
||||||
opt *s3.AccessURLOption,
|
|
||||||
) (string, error) {
|
|
||||||
//reqParams := make(url.Values)
|
//reqParams := make(url.Values)
|
||||||
//if opt != nil {
|
//if opt != nil {
|
||||||
// if opt.ContentType != "" {
|
// if opt.ContentType != "" {
|
||||||
@ -284,15 +260,7 @@ func (c *Cos) AccessURL(
|
|||||||
} else if expire < time.Second {
|
} else if expire < time.Second {
|
||||||
expire = time.Second
|
expire = time.Second
|
||||||
}
|
}
|
||||||
rawURL, err := c.client.Object.GetPresignedURL(
|
rawURL, err := c.client.Object.GetPresignedURL(ctx, http.MethodGet, name, c.credential.SecretID, c.credential.SecretKey, expire, nil)
|
||||||
ctx,
|
|
||||||
http.MethodGet,
|
|
||||||
name,
|
|
||||||
c.credential.SecretID,
|
|
||||||
c.credential.SecretKey,
|
|
||||||
expire,
|
|
||||||
nil,
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,33 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package minio
|
package minio
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
|
||||||
|
"github.com/minio/minio-go/v7"
|
||||||
|
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||||
|
"github.com/minio/minio-go/v7/pkg/signer"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/minio/minio-go/v7"
|
|
||||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
|
||||||
"github.com/minio/minio-go/v7/pkg/signer"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -42,6 +54,15 @@ func NewMinio() (s3.Interface, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
exists, err := client.BucketExists(context.Background(), conf.Bucket)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if !exists {
|
||||||
|
if err := client.MakeBucket(context.Background(), conf.Bucket, minio.MakeBucketOptions{}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
return &Minio{
|
return &Minio{
|
||||||
bucket: conf.Bucket,
|
bucket: conf.Bucket,
|
||||||
bucketURL: conf.Endpoint + "/" + conf.Bucket + "/",
|
bucketURL: conf.Endpoint + "/" + conf.Bucket + "/",
|
||||||
@ -81,12 +102,7 @@ func (m *Minio) InitiateMultipartUpload(ctx context.Context, name string) (*s3.I
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Minio) CompleteMultipartUpload(
|
func (m *Minio) CompleteMultipartUpload(ctx context.Context, uploadID string, name string, parts []s3.Part) (*s3.CompleteMultipartUploadResult, error) {
|
||||||
ctx context.Context,
|
|
||||||
uploadID string,
|
|
||||||
name string,
|
|
||||||
parts []s3.Part,
|
|
||||||
) (*s3.CompleteMultipartUploadResult, error) {
|
|
||||||
minioParts := make([]minio.CompletePart, len(parts))
|
minioParts := make([]minio.CompletePart, len(parts))
|
||||||
for i, part := range parts {
|
for i, part := range parts {
|
||||||
minioParts[i] = minio.CompletePart{
|
minioParts[i] = minio.CompletePart{
|
||||||
@ -123,13 +139,7 @@ func (m *Minio) PartSize(ctx context.Context, size int64) (int64, error) {
|
|||||||
return partSize, nil
|
return partSize, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Minio) AuthSign(
|
func (m *Minio) AuthSign(ctx context.Context, uploadID string, name string, expire time.Duration, partNumbers []int) (*s3.AuthSignResult, error) {
|
||||||
ctx context.Context,
|
|
||||||
uploadID string,
|
|
||||||
name string,
|
|
||||||
expire time.Duration,
|
|
||||||
partNumbers []int,
|
|
||||||
) (*s3.AuthSignResult, error) {
|
|
||||||
creds, err := m.opts.Creds.Get()
|
creds, err := m.opts.Creds.Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -146,14 +156,7 @@ func (m *Minio) AuthSign(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
request.Header.Set("X-Amz-Content-Sha256", unsignedPayload)
|
request.Header.Set("X-Amz-Content-Sha256", unsignedPayload)
|
||||||
request = signer.SignV4Trailer(
|
request = signer.SignV4Trailer(*request, creds.AccessKeyID, creds.SecretAccessKey, creds.SessionToken, "us-east-1", nil)
|
||||||
*request,
|
|
||||||
creds.AccessKeyID,
|
|
||||||
creds.SecretAccessKey,
|
|
||||||
creds.SessionToken,
|
|
||||||
"us-east-1",
|
|
||||||
nil,
|
|
||||||
)
|
|
||||||
result.Parts[i] = s3.SignPart{
|
result.Parts[i] = s3.SignPart{
|
||||||
PartNumber: partNumber,
|
PartNumber: partNumber,
|
||||||
URL: request.URL.String(),
|
URL: request.URL.String(),
|
||||||
@ -224,13 +227,7 @@ func (m *Minio) AbortMultipartUpload(ctx context.Context, uploadID string, name
|
|||||||
return m.core.AbortMultipartUpload(ctx, m.bucket, name, uploadID)
|
return m.core.AbortMultipartUpload(ctx, m.bucket, name, uploadID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Minio) ListUploadedParts(
|
func (m *Minio) ListUploadedParts(ctx context.Context, uploadID string, name string, partNumberMarker int, maxParts int) (*s3.ListUploadedPartsResult, error) {
|
||||||
ctx context.Context,
|
|
||||||
uploadID string,
|
|
||||||
name string,
|
|
||||||
partNumberMarker int,
|
|
||||||
maxParts int,
|
|
||||||
) (*s3.ListUploadedPartsResult, error) {
|
|
||||||
result, err := m.core.ListObjectParts(ctx, m.bucket, name, uploadID, partNumberMarker, maxParts)
|
result, err := m.core.ListObjectParts(ctx, m.bucket, name, uploadID, partNumberMarker, maxParts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -253,12 +250,7 @@ func (m *Minio) ListUploadedParts(
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Minio) AccessURL(
|
func (m *Minio) AccessURL(ctx context.Context, name string, expire time.Duration, opt *s3.AccessURLOption) (string, error) {
|
||||||
ctx context.Context,
|
|
||||||
name string,
|
|
||||||
expire time.Duration,
|
|
||||||
opt *s3.AccessURLOption,
|
|
||||||
) (string, error) {
|
|
||||||
//reqParams := make(url.Values)
|
//reqParams := make(url.Values)
|
||||||
//if opt != nil {
|
//if opt != nil {
|
||||||
// if opt.ContentType != "" {
|
// if opt.ContentType != "" {
|
||||||
|
@ -1,19 +1,31 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package oss
|
package oss
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
|
||||||
|
"github.com/aliyun/aliyun-oss-go-sdk/oss"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/aliyun/aliyun-oss-go-sdk/oss"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/s3"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -75,12 +87,7 @@ func (o *OSS) InitiateMultipartUpload(ctx context.Context, name string) (*s3.Ini
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OSS) CompleteMultipartUpload(
|
func (o *OSS) CompleteMultipartUpload(ctx context.Context, uploadID string, name string, parts []s3.Part) (*s3.CompleteMultipartUploadResult, error) {
|
||||||
ctx context.Context,
|
|
||||||
uploadID string,
|
|
||||||
name string,
|
|
||||||
parts []s3.Part,
|
|
||||||
) (*s3.CompleteMultipartUploadResult, error) {
|
|
||||||
ossParts := make([]oss.UploadPart, len(parts))
|
ossParts := make([]oss.UploadPart, len(parts))
|
||||||
for i, part := range parts {
|
for i, part := range parts {
|
||||||
ossParts[i] = oss.UploadPart{
|
ossParts[i] = oss.UploadPart{
|
||||||
@ -121,13 +128,7 @@ func (o *OSS) PartSize(ctx context.Context, size int64) (int64, error) {
|
|||||||
return partSize, nil
|
return partSize, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OSS) AuthSign(
|
func (o *OSS) AuthSign(ctx context.Context, uploadID string, name string, expire time.Duration, partNumbers []int) (*s3.AuthSignResult, error) {
|
||||||
ctx context.Context,
|
|
||||||
uploadID string,
|
|
||||||
name string,
|
|
||||||
expire time.Duration,
|
|
||||||
partNumbers []int,
|
|
||||||
) (*s3.AuthSignResult, error) {
|
|
||||||
result := s3.AuthSignResult{
|
result := s3.AuthSignResult{
|
||||||
URL: o.bucketURL + name,
|
URL: o.bucketURL + name,
|
||||||
Query: url.Values{"uploadId": {uploadID}},
|
Query: url.Values{"uploadId": {uploadID}},
|
||||||
@ -145,15 +146,7 @@ func (o *OSS) AuthSign(
|
|||||||
}
|
}
|
||||||
request.Header.Set(oss.HTTPHeaderHost, request.Host)
|
request.Header.Set(oss.HTTPHeaderHost, request.Host)
|
||||||
request.Header.Set(oss.HTTPHeaderDate, time.Now().UTC().Format(http.TimeFormat))
|
request.Header.Set(oss.HTTPHeaderDate, time.Now().UTC().Format(http.TimeFormat))
|
||||||
authorization := fmt.Sprintf(
|
authorization := fmt.Sprintf(`OSS %s:%s`, o.credentials.GetAccessKeyID(), o.getSignedStr(request, fmt.Sprintf(`/%s/%s?partNumber=%d&uploadId=%s`, o.bucket.BucketName, name, partNumber, uploadID), o.credentials.GetAccessKeySecret()))
|
||||||
`OSS %s:%s`,
|
|
||||||
o.credentials.GetAccessKeyID(),
|
|
||||||
o.getSignedStr(
|
|
||||||
request,
|
|
||||||
fmt.Sprintf(`/%s/%s?partNumber=%d&uploadId=%s`, o.bucket.BucketName, name, partNumber, uploadID),
|
|
||||||
o.credentials.GetAccessKeySecret(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
request.Header.Set(oss.HTTPHeaderAuthorization, authorization)
|
request.Header.Set(oss.HTTPHeaderAuthorization, authorization)
|
||||||
result.Parts[i] = s3.SignPart{
|
result.Parts[i] = s3.SignPart{
|
||||||
PartNumber: partNumber,
|
PartNumber: partNumber,
|
||||||
@ -234,13 +227,7 @@ func (o *OSS) AbortMultipartUpload(ctx context.Context, uploadID string, name st
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OSS) ListUploadedParts(
|
func (o *OSS) ListUploadedParts(ctx context.Context, uploadID string, name string, partNumberMarker int, maxParts int) (*s3.ListUploadedPartsResult, error) {
|
||||||
ctx context.Context,
|
|
||||||
uploadID string,
|
|
||||||
name string,
|
|
||||||
partNumberMarker int,
|
|
||||||
maxParts int,
|
|
||||||
) (*s3.ListUploadedPartsResult, error) {
|
|
||||||
result, err := o.bucket.ListUploadedParts(oss.InitiateMultipartUploadResult{
|
result, err := o.bucket.ListUploadedParts(oss.InitiateMultipartUploadResult{
|
||||||
UploadID: uploadID,
|
UploadID: uploadID,
|
||||||
Key: name,
|
Key: name,
|
||||||
@ -267,12 +254,7 @@ func (o *OSS) ListUploadedParts(
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OSS) AccessURL(
|
func (o *OSS) AccessURL(ctx context.Context, name string, expire time.Duration, opt *s3.AccessURLOption) (string, error) {
|
||||||
ctx context.Context,
|
|
||||||
name string,
|
|
||||||
expire time.Duration,
|
|
||||||
opt *s3.AccessURLOption,
|
|
||||||
) (string, error) {
|
|
||||||
//var opts []oss.Option
|
//var opts []oss.Option
|
||||||
//if opt != nil {
|
//if opt != nil {
|
||||||
// if opt.ContentType != "" {
|
// if opt.ContentType != "" {
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package oss
|
package oss
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -5,13 +19,12 @@ import (
|
|||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"github.com/aliyun/aliyun-oss-go-sdk/oss"
|
||||||
"hash"
|
"hash"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/aliyun/aliyun-oss-go-sdk/oss"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (o *OSS) getAdditionalHeaderKeys(req *http.Request) ([]string, map[string]string) {
|
func (o *OSS) getAdditionalHeaderKeys(req *http.Request) ([]string, map[string]string) {
|
||||||
@ -72,10 +85,7 @@ func (o *OSS) getSignedStr(req *http.Request, canonicalizedResource string, keyS
|
|||||||
|
|
||||||
// v2 signature
|
// v2 signature
|
||||||
if o.bucket.Client.Config.AuthVersion == oss.AuthV2 {
|
if o.bucket.Client.Config.AuthVersion == oss.AuthV2 {
|
||||||
signStr = req.Method + "\n" + contentMd5 + "\n" + contentType + "\n" + date + "\n" + canonicalizedOSSHeaders + strings.Join(
|
signStr = req.Method + "\n" + contentMd5 + "\n" + contentType + "\n" + date + "\n" + canonicalizedOSSHeaders + strings.Join(additionalList, ";") + "\n" + canonicalizedResource
|
||||||
additionalList,
|
|
||||||
";",
|
|
||||||
) + "\n" + canonicalizedResource
|
|
||||||
h = hmac.New(func() hash.Hash { return sha256.New() }, []byte(keySecret))
|
h = hmac.New(func() hash.Hash { return sha256.New() }, []byte(keySecret))
|
||||||
}
|
}
|
||||||
_, _ = io.WriteString(h, signStr)
|
_, _ = io.WriteString(h, signStr)
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package oss
|
package oss
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package s3
|
package s3
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -112,21 +126,10 @@ type Interface interface {
|
|||||||
PartLimit() *PartLimit
|
PartLimit() *PartLimit
|
||||||
|
|
||||||
InitiateMultipartUpload(ctx context.Context, name string) (*InitiateMultipartUploadResult, error)
|
InitiateMultipartUpload(ctx context.Context, name string) (*InitiateMultipartUploadResult, error)
|
||||||
CompleteMultipartUpload(
|
CompleteMultipartUpload(ctx context.Context, uploadID string, name string, parts []Part) (*CompleteMultipartUploadResult, error)
|
||||||
ctx context.Context,
|
|
||||||
uploadID string,
|
|
||||||
name string,
|
|
||||||
parts []Part,
|
|
||||||
) (*CompleteMultipartUploadResult, error)
|
|
||||||
|
|
||||||
PartSize(ctx context.Context, size int64) (int64, error)
|
PartSize(ctx context.Context, size int64) (int64, error)
|
||||||
AuthSign(
|
AuthSign(ctx context.Context, uploadID string, name string, expire time.Duration, partNumbers []int) (*AuthSignResult, error)
|
||||||
ctx context.Context,
|
|
||||||
uploadID string,
|
|
||||||
name string,
|
|
||||||
expire time.Duration,
|
|
||||||
partNumbers []int,
|
|
||||||
) (*AuthSignResult, error)
|
|
||||||
|
|
||||||
PresignedPutObject(ctx context.Context, name string, expire time.Duration) (string, error)
|
PresignedPutObject(ctx context.Context, name string, expire time.Duration) (string, error)
|
||||||
|
|
||||||
@ -139,13 +142,7 @@ type Interface interface {
|
|||||||
IsNotFound(err error) bool
|
IsNotFound(err error) bool
|
||||||
|
|
||||||
AbortMultipartUpload(ctx context.Context, uploadID string, name string) error
|
AbortMultipartUpload(ctx context.Context, uploadID string, name string) error
|
||||||
ListUploadedParts(
|
ListUploadedParts(ctx context.Context, uploadID string, name string, partNumberMarker int, maxParts int) (*ListUploadedPartsResult, error)
|
||||||
ctx context.Context,
|
|
||||||
uploadID string,
|
|
||||||
name string,
|
|
||||||
partNumberMarker int,
|
|
||||||
maxParts int,
|
|
||||||
) (*ListUploadedPartsResult, error)
|
|
||||||
|
|
||||||
AccessURL(ctx context.Context, name string, expire time.Duration, opt *AccessURLOption) (string, error)
|
AccessURL(ctx context.Context, name string, expire time.Duration, opt *AccessURLOption) (string, error)
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package relation
|
package relation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -10,20 +24,20 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ConversationModel struct {
|
type ConversationModel struct {
|
||||||
OwnerUserID string `gorm:"column:owner_user_id;primary_key;type:char(128)" json:"OwnerUserID"`
|
OwnerUserID string `gorm:"column:owner_user_id;primary_key;type:char(128)" json:"OwnerUserID"`
|
||||||
ConversationID string `gorm:"column:conversation_id;primary_key;type:char(128)" json:"conversationID"`
|
ConversationID string `gorm:"column:conversation_id;primary_key;type:char(128)" json:"conversationID"`
|
||||||
ConversationType int32 `gorm:"column:conversation_type" json:"conversationType"`
|
ConversationType int32 `gorm:"column:conversation_type" json:"conversationType"`
|
||||||
UserID string `gorm:"column:user_id;type:char(64)" json:"userID"`
|
UserID string `gorm:"column:user_id;type:char(64)" json:"userID"`
|
||||||
GroupID string `gorm:"column:group_id;type:char(128)" json:"groupID"`
|
GroupID string `gorm:"column:group_id;type:char(128)" json:"groupID"`
|
||||||
RecvMsgOpt int32 `gorm:"column:recv_msg_opt" json:"recvMsgOpt"`
|
RecvMsgOpt int32 `gorm:"column:recv_msg_opt" json:"recvMsgOpt"`
|
||||||
IsPinned bool `gorm:"column:is_pinned" json:"isPinned"`
|
IsPinned bool `gorm:"column:is_pinned" json:"isPinned"`
|
||||||
IsPrivateChat bool `gorm:"column:is_private_chat" json:"isPrivateChat"`
|
IsPrivateChat bool `gorm:"column:is_private_chat" json:"isPrivateChat"`
|
||||||
BurnDuration int32 `gorm:"column:burn_duration;default:30" json:"burnDuration"`
|
BurnDuration int32 `gorm:"column:burn_duration;default:30" json:"burnDuration"`
|
||||||
GroupAtType int32 `gorm:"column:group_at_type" json:"groupAtType"`
|
GroupAtType int32 `gorm:"column:group_at_type" json:"groupAtType"`
|
||||||
AttachedInfo string `gorm:"column:attached_info;type:varchar(1024)" json:"attachedInfo"`
|
AttachedInfo string `gorm:"column:attached_info;type:varchar(1024)" json:"attachedInfo"`
|
||||||
Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
|
Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
|
||||||
MaxSeq int64 `gorm:"column:max_seq" json:"maxSeq"`
|
MaxSeq int64 `gorm:"column:max_seq" json:"maxSeq"`
|
||||||
MinSeq int64 `gorm:"column:min_seq" json:"minSeq"`
|
MinSeq int64 `gorm:"column:min_seq" json:"minSeq"`
|
||||||
CreateTime time.Time `gorm:"column:create_time;index:create_time;autoCreateTime"`
|
CreateTime time.Time `gorm:"column:create_time;index:create_time;autoCreateTime"`
|
||||||
IsMsgDestruct bool `gorm:"column:is_msg_destruct;default:false"`
|
IsMsgDestruct bool `gorm:"column:is_msg_destruct;default:false"`
|
||||||
MsgDestructTime int64 `gorm:"column:msg_destruct_time;default:604800"`
|
MsgDestructTime int64 `gorm:"column:msg_destruct_time;default:604800"`
|
||||||
@ -37,26 +51,13 @@ func (ConversationModel) TableName() string {
|
|||||||
type ConversationModelInterface interface {
|
type ConversationModelInterface interface {
|
||||||
Create(ctx context.Context, conversations []*ConversationModel) (err error)
|
Create(ctx context.Context, conversations []*ConversationModel) (err error)
|
||||||
Delete(ctx context.Context, groupIDs []string) (err error)
|
Delete(ctx context.Context, groupIDs []string) (err error)
|
||||||
UpdateByMap(
|
UpdateByMap(ctx context.Context, userIDs []string, conversationID string, args map[string]interface{}) (rows int64, err error)
|
||||||
ctx context.Context,
|
|
||||||
userIDs []string,
|
|
||||||
conversationID string,
|
|
||||||
args map[string]interface{},
|
|
||||||
) (rows int64, err error)
|
|
||||||
Update(ctx context.Context, conversation *ConversationModel) (err error)
|
Update(ctx context.Context, conversation *ConversationModel) (err error)
|
||||||
Find(
|
Find(ctx context.Context, ownerUserID string, conversationIDs []string) (conversations []*ConversationModel, err error)
|
||||||
ctx context.Context,
|
|
||||||
ownerUserID string,
|
|
||||||
conversationIDs []string,
|
|
||||||
) (conversations []*ConversationModel, err error)
|
|
||||||
FindUserID(ctx context.Context, userIDs []string, conversationIDs []string) ([]string, error)
|
FindUserID(ctx context.Context, userIDs []string, conversationIDs []string) ([]string, error)
|
||||||
FindUserIDAllConversationID(ctx context.Context, userID string) ([]string, error)
|
FindUserIDAllConversationID(ctx context.Context, userID string) ([]string, error)
|
||||||
Take(ctx context.Context, userID, conversationID string) (conversation *ConversationModel, err error)
|
Take(ctx context.Context, userID, conversationID string) (conversation *ConversationModel, err error)
|
||||||
FindConversationID(
|
FindConversationID(ctx context.Context, userID string, conversationIDs []string) (existConversationID []string, err error)
|
||||||
ctx context.Context,
|
|
||||||
userID string,
|
|
||||||
conversationIDs []string,
|
|
||||||
) (existConversationID []string, err error)
|
|
||||||
FindUserIDAllConversations(ctx context.Context, userID string) (conversations []*ConversationModel, err error)
|
FindUserIDAllConversations(ctx context.Context, userID string) (conversations []*ConversationModel, err error)
|
||||||
FindRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) ([]string, error)
|
FindRecvMsgNotNotifyUserIDs(ctx context.Context, groupID string) ([]string, error)
|
||||||
GetUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string) (opt int, err error)
|
GetUserRecvMsgOpt(ctx context.Context, ownerUserID, conversationID string) (opt int, err error)
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package relation
|
package relation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -42,9 +42,9 @@ type Mongo struct {
|
|||||||
// NewMongo Initialize MongoDB connection
|
// NewMongo Initialize MongoDB connection
|
||||||
func NewMongo() (*Mongo, error) {
|
func NewMongo() (*Mongo, error) {
|
||||||
specialerror.AddReplace(mongo.ErrNoDocuments, errs.ErrRecordNotFound)
|
specialerror.AddReplace(mongo.ErrNoDocuments, errs.ErrRecordNotFound)
|
||||||
url := "mongodb://sample.host:27017/?maxPoolSize=20&w=majority"
|
uri := "mongodb://sample.host:27017/?maxPoolSize=20&w=majority"
|
||||||
if config.Config.Mongo.Uri != "" {
|
if config.Config.Mongo.Uri != "" {
|
||||||
url = config.Config.Mongo.Uri
|
uri = config.Config.Mongo.Uri
|
||||||
} else {
|
} else {
|
||||||
mongodbHosts := ""
|
mongodbHosts := ""
|
||||||
for i, v := range config.Config.Mongo.Address {
|
for i, v := range config.Config.Mongo.Address {
|
||||||
@ -55,22 +55,22 @@ func NewMongo() (*Mongo, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if config.Config.Mongo.Password != "" && config.Config.Mongo.Username != "" {
|
if config.Config.Mongo.Password != "" && config.Config.Mongo.Username != "" {
|
||||||
url = fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d&authSource=admin",
|
uri = fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d&authSource=admin",
|
||||||
config.Config.Mongo.Username, config.Config.Mongo.Password, mongodbHosts,
|
config.Config.Mongo.Username, config.Config.Mongo.Password, mongodbHosts,
|
||||||
config.Config.Mongo.Database, config.Config.Mongo.MaxPoolSize)
|
config.Config.Mongo.Database, config.Config.Mongo.MaxPoolSize)
|
||||||
} else {
|
} else {
|
||||||
url = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d&authSource=admin",
|
uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d&authSource=admin",
|
||||||
mongodbHosts, config.Config.Mongo.Database,
|
mongodbHosts, config.Config.Mongo.Database,
|
||||||
config.Config.Mongo.MaxPoolSize)
|
config.Config.Mongo.MaxPoolSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println("mongo:", url)
|
fmt.Println("mongo:", uri)
|
||||||
var mongoClient *mongo.Client
|
var mongoClient *mongo.Client
|
||||||
var err error = nil
|
var err error = nil
|
||||||
for i := 0; i <= maxRetry; i++ {
|
for i := 0; i <= maxRetry; i++ {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
mongoClient, err = mongo.Connect(ctx, options.Client().ApplyURI(url))
|
mongoClient, err = mongo.Connect(ctx, options.Client().ApplyURI(uri))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return &Mongo{db: mongoClient}, nil
|
return &Mongo{db: mongoClient}, nil
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package log
|
package log
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -17,11 +31,7 @@ type SqlLogger struct {
|
|||||||
SlowThreshold time.Duration
|
SlowThreshold time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSqlLogger(
|
func NewSqlLogger(logLevel gormLogger.LogLevel, ignoreRecordNotFoundError bool, slowThreshold time.Duration) *SqlLogger {
|
||||||
logLevel gormLogger.LogLevel,
|
|
||||||
ignoreRecordNotFoundError bool,
|
|
||||||
slowThreshold time.Duration,
|
|
||||||
) *SqlLogger {
|
|
||||||
return &SqlLogger{
|
return &SqlLogger{
|
||||||
LogLevel: logLevel,
|
LogLevel: logLevel,
|
||||||
IgnoreRecordNotFoundError: ignoreRecordNotFoundError,
|
IgnoreRecordNotFoundError: ignoreRecordNotFoundError,
|
||||||
@ -56,17 +66,7 @@ func (l *SqlLogger) Trace(ctx context.Context, begin time.Time, fc func() (sql s
|
|||||||
case err != nil && l.LogLevel >= gormLogger.Error && (!errors.Is(err, gorm.ErrRecordNotFound) || !l.IgnoreRecordNotFoundError):
|
case err != nil && l.LogLevel >= gormLogger.Error && (!errors.Is(err, gorm.ErrRecordNotFound) || !l.IgnoreRecordNotFoundError):
|
||||||
sql, rows := fc()
|
sql, rows := fc()
|
||||||
if rows == -1 {
|
if rows == -1 {
|
||||||
ZError(
|
ZError(ctx, "sql exec detail", err, "gorm", gormUtils.FileWithLineNum(), "elapsed time", fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6), "sql", sql)
|
||||||
ctx,
|
|
||||||
"sql exec detail",
|
|
||||||
err,
|
|
||||||
"gorm",
|
|
||||||
gormUtils.FileWithLineNum(),
|
|
||||||
"elapsed time",
|
|
||||||
fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6),
|
|
||||||
"sql",
|
|
||||||
sql,
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
ZError(ctx, "sql exec detail", err, "gorm", gormUtils.FileWithLineNum(), "elapsed time", fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6), "rows", rows, "sql", sql)
|
ZError(ctx, "sql exec detail", err, "gorm", gormUtils.FileWithLineNum(), "elapsed time", fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6), "rows", rows, "sql", sql)
|
||||||
}
|
}
|
||||||
@ -74,35 +74,14 @@ func (l *SqlLogger) Trace(ctx context.Context, begin time.Time, fc func() (sql s
|
|||||||
sql, rows := fc()
|
sql, rows := fc()
|
||||||
slowLog := fmt.Sprintf("SLOW SQL >= %v", l.SlowThreshold)
|
slowLog := fmt.Sprintf("SLOW SQL >= %v", l.SlowThreshold)
|
||||||
if rows == -1 {
|
if rows == -1 {
|
||||||
ZWarn(
|
ZWarn(ctx, "sql exec detail", nil, "gorm", gormUtils.FileWithLineNum(), "slow sql", slowLog, "elapsed time", fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6), "sql", sql)
|
||||||
ctx,
|
|
||||||
"sql exec detail",
|
|
||||||
nil,
|
|
||||||
"gorm",
|
|
||||||
gormUtils.FileWithLineNum(),
|
|
||||||
"slow sql",
|
|
||||||
slowLog,
|
|
||||||
"elapsed time",
|
|
||||||
fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6),
|
|
||||||
"sql",
|
|
||||||
sql,
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
ZWarn(ctx, "sql exec detail", nil, "gorm", gormUtils.FileWithLineNum(), "slow sql", slowLog, "elapsed time", fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6), "rows", rows, "sql", sql)
|
ZWarn(ctx, "sql exec detail", nil, "gorm", gormUtils.FileWithLineNum(), "slow sql", slowLog, "elapsed time", fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6), "rows", rows, "sql", sql)
|
||||||
}
|
}
|
||||||
case l.LogLevel == gormLogger.Info:
|
case l.LogLevel == gormLogger.Info:
|
||||||
sql, rows := fc()
|
sql, rows := fc()
|
||||||
if rows == -1 {
|
if rows == -1 {
|
||||||
ZDebug(
|
ZDebug(ctx, "sql exec detail", "gorm", gormUtils.FileWithLineNum(), "elapsed time", fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6), "sql", sql)
|
||||||
ctx,
|
|
||||||
"sql exec detail",
|
|
||||||
"gorm",
|
|
||||||
gormUtils.FileWithLineNum(),
|
|
||||||
"elapsed time",
|
|
||||||
fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6),
|
|
||||||
"sql",
|
|
||||||
sql,
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
ZDebug(ctx, "sql exec detail", "gorm", gormUtils.FileWithLineNum(), "elapsed time", fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6), "rows", rows, "sql", sql)
|
ZDebug(ctx, "sql exec detail", "gorm", gormUtils.FileWithLineNum(), "elapsed time", fmt.Sprintf("%f(ms)", float64(elapsed.Nanoseconds())/1e6), "rows", rows, "sql", sql)
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,15 @@ var mapper = []string{constant.OperationID, constant.OpUserID, constant.OpUserPl
|
|||||||
func WithOpUserIDContext(ctx context.Context, opUserID string) context.Context {
|
func WithOpUserIDContext(ctx context.Context, opUserID string) context.Context {
|
||||||
return context.WithValue(ctx, constant.OpUserID, opUserID)
|
return context.WithValue(ctx, constant.OpUserID, opUserID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithOpUserPlatformContext(ctx context.Context, platform string) context.Context {
|
func WithOpUserPlatformContext(ctx context.Context, platform string) context.Context {
|
||||||
return context.WithValue(ctx, constant.OpUserPlatform, platform)
|
return context.WithValue(ctx, constant.OpUserPlatform, platform)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithTriggerIDContext(ctx context.Context, triggerID string) context.Context {
|
func WithTriggerIDContext(ctx context.Context, triggerID string) context.Context {
|
||||||
return context.WithValue(ctx, constant.TriggerID, triggerID)
|
return context.WithValue(ctx, constant.TriggerID, triggerID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCtx(operationID string) context.Context {
|
func NewCtx(operationID string) context.Context {
|
||||||
c := context.Background()
|
c := context.Background()
|
||||||
ctx := context.WithValue(c, constant.OperationID, operationID)
|
ctx := context.WithValue(c, constant.OperationID, operationID)
|
||||||
@ -59,6 +62,7 @@ func GetOperationID(ctx context.Context) string {
|
|||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetOpUserID(ctx context.Context) string {
|
func GetOpUserID(ctx context.Context) string {
|
||||||
if ctx.Value(constant.OpUserID) != "" {
|
if ctx.Value(constant.OpUserID) != "" {
|
||||||
s, ok := ctx.Value(constant.OpUserID).(string)
|
s, ok := ctx.Value(constant.OpUserID).(string)
|
||||||
@ -68,6 +72,7 @@ func GetOpUserID(ctx context.Context) string {
|
|||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetConnID(ctx context.Context) string {
|
func GetConnID(ctx context.Context) string {
|
||||||
if ctx.Value(constant.ConnID) != "" {
|
if ctx.Value(constant.ConnID) != "" {
|
||||||
s, ok := ctx.Value(constant.ConnID).(string)
|
s, ok := ctx.Value(constant.ConnID).(string)
|
||||||
@ -87,6 +92,7 @@ func GetTriggerID(ctx context.Context) string {
|
|||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetOpUserPlatform(ctx context.Context) string {
|
func GetOpUserPlatform(ctx context.Context) string {
|
||||||
if ctx.Value(constant.OpUserPlatform) != "" {
|
if ctx.Value(constant.OpUserPlatform) != "" {
|
||||||
s, ok := ctx.Value(constant.OpUserPlatform).(string)
|
s, ok := ctx.Value(constant.OpUserPlatform).(string)
|
||||||
@ -96,6 +102,7 @@ func GetOpUserPlatform(ctx context.Context) string {
|
|||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetRemoteAddr(ctx context.Context) string {
|
func GetRemoteAddr(ctx context.Context) string {
|
||||||
if ctx.Value(constant.RemoteAddr) != "" {
|
if ctx.Value(constant.RemoteAddr) != "" {
|
||||||
s, ok := ctx.Value(constant.RemoteAddr).(string)
|
s, ok := ctx.Value(constant.RemoteAddr).(string)
|
||||||
@ -142,8 +149,6 @@ func WithMustInfoCtx(values []string) context.Context {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
for i, v := range values {
|
for i, v := range values {
|
||||||
ctx = context.WithValue(ctx, mapper[i], v)
|
ctx = context.WithValue(ctx, mapper[i], v)
|
||||||
|
|
||||||
}
|
}
|
||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package zookeeper
|
package zookeeper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -6,10 +20,9 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/go-zookeeper/zk"
|
"github.com/go-zookeeper/zk"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
@ -70,11 +83,7 @@ func (s *ZkClient) GetConnsRemote(serviceName string) (conns []resolver.Address,
|
|||||||
return conns, nil
|
return conns, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ZkClient) GetConns(
|
func (s *ZkClient) GetConns(ctx context.Context, serviceName string, opts ...grpc.DialOption) ([]grpc.ClientConnInterface, error) {
|
||||||
ctx context.Context,
|
|
||||||
serviceName string,
|
|
||||||
opts ...grpc.DialOption,
|
|
||||||
) ([]grpc.ClientConnInterface, error) {
|
|
||||||
s.logger.Printf("get conns from client, serviceName: %s", serviceName)
|
s.logger.Printf("get conns from client, serviceName: %s", serviceName)
|
||||||
opts = append(s.options, opts...)
|
opts = append(s.options, opts...)
|
||||||
s.lock.Lock()
|
s.lock.Lock()
|
||||||
@ -88,26 +97,12 @@ func (s *ZkClient) GetConns(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(addrs) == 0 {
|
if len(addrs) == 0 {
|
||||||
return nil, fmt.Errorf(
|
return nil, fmt.Errorf("no conn for service %s, grpc server may not exist, local conn is %v, please check zookeeper server %v, path: %s", serviceName, s.localConns, s.zkServers, s.zkRoot)
|
||||||
"no conn for service %s, grpc server may not exist, local conn is %v, please check zookeeper server %v, path: %s",
|
|
||||||
serviceName,
|
|
||||||
s.localConns,
|
|
||||||
s.zkServers,
|
|
||||||
s.zkRoot,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
cc, err := grpc.DialContext(ctx, addr.Addr, append(s.options, opts...)...)
|
cc, err := grpc.DialContext(ctx, addr.Addr, append(s.options, opts...)...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(
|
log.ZError(context.Background(), "dialContext failed", err, "addr", addr.Addr, "opts", append(s.options, opts...))
|
||||||
context.Background(),
|
|
||||||
"dialContext failed",
|
|
||||||
err,
|
|
||||||
"addr",
|
|
||||||
addr.Addr,
|
|
||||||
"opts",
|
|
||||||
append(s.options, opts...),
|
|
||||||
)
|
|
||||||
return nil, errs.Wrap(err)
|
return nil, errs.Wrap(err)
|
||||||
}
|
}
|
||||||
conns = append(conns, cc)
|
conns = append(conns, cc)
|
||||||
@ -117,15 +112,8 @@ func (s *ZkClient) GetConns(
|
|||||||
return conns, nil
|
return conns, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ZkClient) GetConn(
|
func (s *ZkClient) GetConn(ctx context.Context, serviceName string, opts ...grpc.DialOption) (grpc.ClientConnInterface, error) {
|
||||||
ctx context.Context,
|
newOpts := append(s.options, grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, s.balancerName)))
|
||||||
serviceName string,
|
|
||||||
opts ...grpc.DialOption,
|
|
||||||
) (grpc.ClientConnInterface, error) {
|
|
||||||
newOpts := append(
|
|
||||||
s.options,
|
|
||||||
grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, s.balancerName)),
|
|
||||||
)
|
|
||||||
s.logger.Printf("get conn from client, serviceName: %s", serviceName)
|
s.logger.Printf("get conn from client, serviceName: %s", serviceName)
|
||||||
return grpc.DialContext(ctx, fmt.Sprintf("%s:///%s", s.scheme, serviceName), append(newOpts, opts...)...)
|
return grpc.DialContext(ctx, fmt.Sprintf("%s:///%s", s.scheme, serviceName), append(newOpts, opts...)...)
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package errs
|
package errs
|
||||||
|
|
||||||
// UnknownCode 没有解析到code或解析的code=0
|
// UnknownCode 没有解析到code或解析的code=0.
|
||||||
const UnknownCode = 1000
|
const UnknownCode = 1000
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -34,47 +34,47 @@ const (
|
|||||||
InvitationError = 10014
|
InvitationError = 10014
|
||||||
)
|
)
|
||||||
|
|
||||||
// 通用错误码
|
// 通用错误码.
|
||||||
const (
|
const (
|
||||||
NoError = 0 //无错误
|
NoError = 0 // 无错误
|
||||||
DatabaseError = 90002 //redis/mysql等db错误
|
DatabaseError = 90002 // redis/mysql等db错误
|
||||||
NetworkError = 90004 //网络错误
|
NetworkError = 90004 // 网络错误
|
||||||
DataError = 90007 //数据错误
|
DataError = 90007 // 数据错误
|
||||||
|
|
||||||
CallbackError = 80000
|
CallbackError = 80000
|
||||||
|
|
||||||
//通用错误码
|
//通用错误码.
|
||||||
ServerInternalError = 500 //服务器内部错误
|
ServerInternalError = 500 //服务器内部错误
|
||||||
ArgsError = 1001 //输入参数错误
|
ArgsError = 1001 //输入参数错误
|
||||||
NoPermissionError = 1002 //权限不足
|
NoPermissionError = 1002 //权限不足
|
||||||
DuplicateKeyError = 1003
|
DuplicateKeyError = 1003
|
||||||
RecordNotFoundError = 1004 //记录不存在
|
RecordNotFoundError = 1004 // 记录不存在
|
||||||
|
|
||||||
// 账号错误码
|
// 账号错误码.
|
||||||
UserIDNotFoundError = 1101 //UserID不存在 或未注册
|
UserIDNotFoundError = 1101 // UserID不存在 或未注册
|
||||||
RegisteredAlreadyError = 1102 //用户已经注册过了
|
RegisteredAlreadyError = 1102 // 用户已经注册过了
|
||||||
|
|
||||||
// 群组错误码
|
// 群组错误码.
|
||||||
GroupIDNotFoundError = 1201 //GroupID不存在
|
GroupIDNotFoundError = 1201 // GroupID不存在
|
||||||
GroupIDExisted = 1202 //GroupID已存在
|
GroupIDExisted = 1202 // GroupID已存在
|
||||||
NotInGroupYetError = 1203 //不在群组中
|
NotInGroupYetError = 1203 // 不在群组中
|
||||||
DismissedAlreadyError = 1204 //群组已经解散
|
DismissedAlreadyError = 1204 // 群组已经解散
|
||||||
GroupTypeNotSupport = 1205
|
GroupTypeNotSupport = 1205
|
||||||
GroupRequestHandled = 1206
|
GroupRequestHandled = 1206
|
||||||
|
|
||||||
// 关系链错误码
|
// 关系链错误码.
|
||||||
CanNotAddYourselfError = 1301 //不能添加自己为好友
|
CanNotAddYourselfError = 1301 // 不能添加自己为好友
|
||||||
BlockedByPeer = 1302 //被对方拉黑
|
BlockedByPeer = 1302 // 被对方拉黑
|
||||||
NotPeersFriend = 1303 //不是对方的好友
|
NotPeersFriend = 1303 // 不是对方的好友
|
||||||
RelationshipAlreadyError = 1304 //已经是好友关系
|
RelationshipAlreadyError = 1304 // 已经是好友关系
|
||||||
|
|
||||||
// 消息错误码
|
// 消息错误码.
|
||||||
MessageHasReadDisable = 1401
|
MessageHasReadDisable = 1401
|
||||||
MutedInGroup = 1402 //群成员被禁言
|
MutedInGroup = 1402 // 群成员被禁言
|
||||||
MutedGroup = 1403 //群被禁言
|
MutedGroup = 1403 // 群被禁言
|
||||||
MsgAlreadyRevoke = 1404 //消息已撤回
|
MsgAlreadyRevoke = 1404 // 消息已撤回
|
||||||
|
|
||||||
// token错误码
|
// token错误码.
|
||||||
TokenExpiredError = 1501
|
TokenExpiredError = 1501
|
||||||
TokenInvalidError = 1502
|
TokenInvalidError = 1502
|
||||||
TokenMalformedError = 1503
|
TokenMalformedError = 1503
|
||||||
@ -83,10 +83,10 @@ const (
|
|||||||
TokenKickedError = 1506
|
TokenKickedError = 1506
|
||||||
TokenNotExistError = 1507
|
TokenNotExistError = 1507
|
||||||
|
|
||||||
// 长连接网关错误码
|
// 长连接网关错误码.
|
||||||
ConnOverMaxNumLimit = 1601
|
ConnOverMaxNumLimit = 1601
|
||||||
ConnArgsErr = 1602
|
ConnArgsErr = 1602
|
||||||
|
|
||||||
// S3错误码
|
// S3错误码.
|
||||||
FileUploadedExpiredError = 1701 // 上传过期
|
FileUploadedExpiredError = 1701 // 上传过期
|
||||||
)
|
)
|
||||||
|
@ -38,11 +38,11 @@ var (
|
|||||||
ErrData = NewCodeError(DataError, "DataError")
|
ErrData = NewCodeError(DataError, "DataError")
|
||||||
ErrTokenExpired = NewCodeError(TokenExpiredError, "TokenExpiredError")
|
ErrTokenExpired = NewCodeError(TokenExpiredError, "TokenExpiredError")
|
||||||
ErrTokenInvalid = NewCodeError(TokenInvalidError, "TokenInvalidError") //
|
ErrTokenInvalid = NewCodeError(TokenInvalidError, "TokenInvalidError") //
|
||||||
ErrTokenMalformed = NewCodeError(TokenMalformedError, "TokenMalformedError") //格式错误
|
ErrTokenMalformed = NewCodeError(TokenMalformedError, "TokenMalformedError") // 格式错误
|
||||||
ErrTokenNotValidYet = NewCodeError(TokenNotValidYetError, "TokenNotValidYetError") //还未生效
|
ErrTokenNotValidYet = NewCodeError(TokenNotValidYetError, "TokenNotValidYetError") // 还未生效
|
||||||
ErrTokenUnknown = NewCodeError(TokenUnknownError, "TokenUnknownError") //未知错误
|
ErrTokenUnknown = NewCodeError(TokenUnknownError, "TokenUnknownError") // 未知错误
|
||||||
ErrTokenKicked = NewCodeError(TokenKickedError, "TokenKickedError")
|
ErrTokenKicked = NewCodeError(TokenKickedError, "TokenKickedError")
|
||||||
ErrTokenNotExist = NewCodeError(TokenNotExistError, "TokenNotExistError") //在redis中不存在
|
ErrTokenNotExist = NewCodeError(TokenNotExistError, "TokenNotExistError") // 在redis中不存在
|
||||||
ErrDuplicateKey = NewCodeError(DuplicateKeyError, "DuplicateKeyError")
|
ErrDuplicateKey = NewCodeError(DuplicateKeyError, "DuplicateKeyError")
|
||||||
|
|
||||||
ErrMessageHasReadDisable = NewCodeError(MessageHasReadDisable, "MessageHasReadDisable")
|
ErrMessageHasReadDisable = NewCodeError(MessageHasReadDisable, "MessageHasReadDisable")
|
||||||
|
@ -1,15 +1,28 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package rpcclient
|
package rpcclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
|
||||||
pbConversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
|
pbConversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
|
||||||
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Conversation struct {
|
type Conversation struct {
|
||||||
@ -33,10 +46,7 @@ func NewConversationRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) Con
|
|||||||
return ConversationRpcClient(*NewConversation(discov))
|
return ConversationRpcClient(*NewConversation(discov))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationRpcClient) GetSingleConversationRecvMsgOpt(
|
func (c *ConversationRpcClient) GetSingleConversationRecvMsgOpt(ctx context.Context, userID, conversationID string) (int32, error) {
|
||||||
ctx context.Context,
|
|
||||||
userID, conversationID string,
|
|
||||||
) (int32, error) {
|
|
||||||
var req pbConversation.GetConversationReq
|
var req pbConversation.GetConversationReq
|
||||||
req.OwnerUserID = userID
|
req.OwnerUserID = userID
|
||||||
req.ConversationID = conversationID
|
req.ConversationID = conversationID
|
||||||
@ -48,51 +58,21 @@ func (c *ConversationRpcClient) GetSingleConversationRecvMsgOpt(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationRpcClient) SingleChatFirstCreateConversation(ctx context.Context, recvID, sendID string) error {
|
func (c *ConversationRpcClient) SingleChatFirstCreateConversation(ctx context.Context, recvID, sendID string) error {
|
||||||
_, err := c.Client.CreateSingleChatConversations(
|
_, err := c.Client.CreateSingleChatConversations(ctx, &pbConversation.CreateSingleChatConversationsReq{RecvID: recvID, SendID: sendID})
|
||||||
ctx,
|
|
||||||
&pbConversation.CreateSingleChatConversationsReq{RecvID: recvID, SendID: sendID},
|
|
||||||
)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationRpcClient) GroupChatFirstCreateConversation(
|
func (c *ConversationRpcClient) GroupChatFirstCreateConversation(ctx context.Context, groupID string, userIDs []string) error {
|
||||||
ctx context.Context,
|
_, err := c.Client.CreateGroupChatConversations(ctx, &pbConversation.CreateGroupChatConversationsReq{UserIDs: userIDs, GroupID: groupID})
|
||||||
groupID string,
|
|
||||||
userIDs []string,
|
|
||||||
) error {
|
|
||||||
_, err := c.Client.CreateGroupChatConversations(
|
|
||||||
ctx,
|
|
||||||
&pbConversation.CreateGroupChatConversationsReq{UserIDs: userIDs, GroupID: groupID},
|
|
||||||
)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationRpcClient) SetConversationMaxSeq(
|
func (c *ConversationRpcClient) SetConversationMaxSeq(ctx context.Context, ownerUserIDs []string, conversationID string, maxSeq int64) error {
|
||||||
ctx context.Context,
|
_, err := c.Client.SetConversationMaxSeq(ctx, &pbConversation.SetConversationMaxSeqReq{OwnerUserID: ownerUserIDs, ConversationID: conversationID, MaxSeq: maxSeq})
|
||||||
ownerUserIDs []string,
|
|
||||||
conversationID string,
|
|
||||||
maxSeq int64,
|
|
||||||
) error {
|
|
||||||
_, err := c.Client.SetConversationMaxSeq(
|
|
||||||
ctx,
|
|
||||||
&pbConversation.SetConversationMaxSeqReq{
|
|
||||||
OwnerUserID: ownerUserIDs,
|
|
||||||
ConversationID: conversationID,
|
|
||||||
MaxSeq: maxSeq,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
func (c *ConversationRpcClient) SetConversations(ctx context.Context, userIDs []string, conversation *pbConversation.ConversationReq) error {
|
||||||
func (c *ConversationRpcClient) SetConversations(
|
_, err := c.Client.SetConversations(ctx, &pbConversation.SetConversationsReq{UserIDs: userIDs, Conversation: conversation})
|
||||||
ctx context.Context,
|
|
||||||
userIDs []string,
|
|
||||||
conversation *pbConversation.ConversationReq,
|
|
||||||
) error {
|
|
||||||
_, err := c.Client.SetConversations(
|
|
||||||
ctx,
|
|
||||||
&pbConversation.SetConversationsReq{UserIDs: userIDs, Conversation: conversation},
|
|
||||||
)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,28 +84,16 @@ func (c *ConversationRpcClient) GetConversationIDs(ctx context.Context, ownerUse
|
|||||||
return resp.ConversationIDs, nil
|
return resp.ConversationIDs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationRpcClient) GetConversation(
|
func (c *ConversationRpcClient) GetConversation(ctx context.Context, ownerUserID, conversationID string) (*pbConversation.Conversation, error) {
|
||||||
ctx context.Context,
|
resp, err := c.Client.GetConversation(ctx, &pbConversation.GetConversationReq{OwnerUserID: ownerUserID, ConversationID: conversationID})
|
||||||
ownerUserID, conversationID string,
|
|
||||||
) (*pbConversation.Conversation, error) {
|
|
||||||
resp, err := c.Client.GetConversation(
|
|
||||||
ctx,
|
|
||||||
&pbConversation.GetConversationReq{OwnerUserID: ownerUserID, ConversationID: conversationID},
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return resp.Conversation, nil
|
return resp.Conversation, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationRpcClient) GetConversationsByConversationID(
|
func (c *ConversationRpcClient) GetConversationsByConversationID(ctx context.Context, conversationIDs []string) ([]*pbConversation.Conversation, error) {
|
||||||
ctx context.Context,
|
resp, err := c.Client.GetConversationsByConversationID(ctx, &pbConversation.GetConversationsByConversationIDReq{ConversationIDs: conversationIDs})
|
||||||
conversationIDs []string,
|
|
||||||
) ([]*pbConversation.Conversation, error) {
|
|
||||||
resp, err := c.Client.GetConversationsByConversationID(
|
|
||||||
ctx,
|
|
||||||
&pbConversation.GetConversationsByConversationIDReq{ConversationIDs: conversationIDs},
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -135,15 +103,8 @@ func (c *ConversationRpcClient) GetConversationsByConversationID(
|
|||||||
return resp.Conversations, nil
|
return resp.Conversations, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConversationRpcClient) GetConversations(
|
func (c *ConversationRpcClient) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*pbConversation.Conversation, error) {
|
||||||
ctx context.Context,
|
resp, err := c.Client.GetConversations(ctx, &pbConversation.GetConversationsReq{OwnerUserID: ownerUserID, ConversationIDs: conversationIDs})
|
||||||
ownerUserID string,
|
|
||||||
conversationIDs []string,
|
|
||||||
) ([]*pbConversation.Conversation, error) {
|
|
||||||
resp, err := c.Client.GetConversations(
|
|
||||||
ctx,
|
|
||||||
&pbConversation.GetConversationsReq{OwnerUserID: ownerUserID, ConversationIDs: conversationIDs},
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package rpcclient
|
package rpcclient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -5,9 +19,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/user"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/user"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
"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/constant"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
||||||
@ -15,6 +26,8 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
// "google.golang.org/protobuf/proto"
|
// "google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -108,9 +121,10 @@ func newSessionTypeConf() map[int32]int32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Message struct {
|
type Message struct {
|
||||||
conn grpc.ClientConnInterface
|
conn grpc.ClientConnInterface
|
||||||
Client msg.MsgClient
|
Client msg.MsgClient
|
||||||
discov discoveryregistry.SvcDiscoveryRegistry
|
discov discoveryregistry.SvcDiscoveryRegistry
|
||||||
|
userClient user.UserClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMessage(discov discoveryregistry.SvcDiscoveryRegistry) *Message {
|
func NewMessage(discov discoveryregistry.SvcDiscoveryRegistry) *Message {
|
||||||
@ -119,7 +133,20 @@ func NewMessage(discov discoveryregistry.SvcDiscoveryRegistry) *Message {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
client := msg.NewMsgClient(conn)
|
client := msg.NewMsgClient(conn)
|
||||||
return &Message{discov: discov, conn: conn, Client: client}
|
conn, err = discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImUserName)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
userClient := user.NewUserClient(conn)
|
||||||
|
return &Message{discov: discov, conn: conn, Client: client, userClient: userClient}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Message) GetAllUserID(ctx context.Context, req *user.GetAllUserIDReq) (*user.GetAllUserIDResp, error) {
|
||||||
|
resp, err := m.userClient.GetAllUserID(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type MessageRpcClient Message
|
type MessageRpcClient Message
|
||||||
@ -138,10 +165,7 @@ func (m *MessageRpcClient) GetMaxSeq(ctx context.Context, req *sdkws.GetMaxSeqRe
|
|||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MessageRpcClient) PullMessageBySeqList(
|
func (m *MessageRpcClient) PullMessageBySeqList(ctx context.Context, req *sdkws.PullMessageBySeqsReq) (*sdkws.PullMessageBySeqsResp, error) {
|
||||||
ctx context.Context,
|
|
||||||
req *sdkws.PullMessageBySeqsReq,
|
|
||||||
) (*sdkws.PullMessageBySeqsResp, error) {
|
|
||||||
resp, err := m.Client.PullMessageBySeqs(ctx, req)
|
resp, err := m.Client.PullMessageBySeqs(ctx, req)
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
@ -163,9 +187,7 @@ type NotificationSender struct {
|
|||||||
|
|
||||||
type NotificationSenderOptions func(*NotificationSender)
|
type NotificationSenderOptions func(*NotificationSender)
|
||||||
|
|
||||||
func WithLocalSendMsg(
|
func WithLocalSendMsg(sendMsg func(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error)) NotificationSenderOptions {
|
||||||
sendMsg func(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error),
|
|
||||||
) NotificationSenderOptions {
|
|
||||||
return func(s *NotificationSender) {
|
return func(s *NotificationSender) {
|
||||||
s.sendMsg = sendMsg
|
s.sendMsg = sendMsg
|
||||||
}
|
}
|
||||||
@ -184,10 +206,7 @@ func WithUserRpcClient(userRpcClient *UserRpcClient) NotificationSenderOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewNotificationSender(opts ...NotificationSenderOptions) *NotificationSender {
|
func NewNotificationSender(opts ...NotificationSenderOptions) *NotificationSender {
|
||||||
notificationSender := &NotificationSender{
|
notificationSender := &NotificationSender{contentTypeConf: newContentTypeConf(), sessionTypeConf: newSessionTypeConf()}
|
||||||
contentTypeConf: newContentTypeConf(),
|
|
||||||
sessionTypeConf: newSessionTypeConf(),
|
|
||||||
}
|
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(notificationSender)
|
opt(notificationSender)
|
||||||
}
|
}
|
||||||
@ -206,29 +225,11 @@ func WithRpcGetUserName() NotificationOptions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *NotificationSender) NotificationWithSesstionType(
|
func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, sendID, recvID string, contentType, sesstionType int32, m proto.Message, opts ...NotificationOptions) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
sendID, recvID string,
|
|
||||||
contentType, sesstionType int32,
|
|
||||||
m proto.Message,
|
|
||||||
opts ...NotificationOptions,
|
|
||||||
) (err error) {
|
|
||||||
n := sdkws.NotificationElem{Detail: utils.StructToJsonString(m)}
|
n := sdkws.NotificationElem{Detail: utils.StructToJsonString(m)}
|
||||||
content, err := json.Marshal(&n)
|
content, err := json.Marshal(&n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(
|
log.ZError(ctx, "MsgClient Notification json.Marshal failed", err, "sendID", sendID, "recvID", recvID, "contentType", contentType, "msg", m)
|
||||||
ctx,
|
|
||||||
"MsgClient Notification json.Marshal failed",
|
|
||||||
err,
|
|
||||||
"sendID",
|
|
||||||
sendID,
|
|
||||||
"recvID",
|
|
||||||
recvID,
|
|
||||||
"contentType",
|
|
||||||
contentType,
|
|
||||||
"msg",
|
|
||||||
m,
|
|
||||||
)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
notificationOpt := ¬ificationOpt{}
|
notificationOpt := ¬ificationOpt{}
|
||||||
@ -275,25 +276,6 @@ func (s *NotificationSender) NotificationWithSesstionType(
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *NotificationSender) Notification(
|
func (s *NotificationSender) Notification(ctx context.Context, sendID, recvID string, contentType int32, m proto.Message, opts ...NotificationOptions) error {
|
||||||
ctx context.Context,
|
|
||||||
sendID, recvID string,
|
|
||||||
contentType int32,
|
|
||||||
m proto.Message,
|
|
||||||
opts ...NotificationOptions,
|
|
||||||
) error {
|
|
||||||
return s.NotificationWithSesstionType(ctx, sendID, recvID, contentType, s.sessionTypeConf[contentType], m, opts...)
|
return s.NotificationWithSesstionType(ctx, sendID, recvID, contentType, s.sessionTypeConf[contentType], m, opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Message) GetAllUserID(ctx context.Context, req *user.GetAllUserIDReq) (*user.GetAllUserIDResp, error) {
|
|
||||||
conn, err := m.discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImMsgName)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
client := user.NewUserClient(conn)
|
|
||||||
resp, err := client.GetAllUserID(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package notification
|
package notification
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -16,19 +30,11 @@ import (
|
|||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewGroupNotificationSender(
|
func NewGroupNotificationSender(db controller.GroupDatabase, msgRpcClient *rpcclient.MessageRpcClient, userRpcClient *rpcclient.UserRpcClient, fn func(ctx context.Context, userIDs []string) ([]CommonUser, error)) *GroupNotificationSender {
|
||||||
db controller.GroupDatabase,
|
|
||||||
msgRpcClient *rpcclient.MessageRpcClient,
|
|
||||||
userRpcClient *rpcclient.UserRpcClient,
|
|
||||||
fn func(ctx context.Context, userIDs []string) ([]CommonUser, error),
|
|
||||||
) *GroupNotificationSender {
|
|
||||||
return &GroupNotificationSender{
|
return &GroupNotificationSender{
|
||||||
NotificationSender: rpcclient.NewNotificationSender(
|
NotificationSender: rpcclient.NewNotificationSender(rpcclient.WithRpcClient(msgRpcClient), rpcclient.WithUserRpcClient(userRpcClient)),
|
||||||
rpcclient.WithRpcClient(msgRpcClient),
|
getUsersInfo: fn,
|
||||||
rpcclient.WithUserRpcClient(userRpcClient),
|
db: db,
|
||||||
),
|
|
||||||
getUsersInfo: fn,
|
|
||||||
db: db,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,11 +94,7 @@ func (g *GroupNotificationSender) getGroupInfo(ctx context.Context, groupID stri
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) getGroupMembers(
|
func (g *GroupNotificationSender) getGroupMembers(ctx context.Context, groupID string, userIDs []string) ([]*sdkws.GroupMemberFullInfo, error) {
|
||||||
ctx context.Context,
|
|
||||||
groupID string,
|
|
||||||
userIDs []string,
|
|
||||||
) ([]*sdkws.GroupMemberFullInfo, error) {
|
|
||||||
members, err := g.db.FindGroupMember(ctx, []string{groupID}, userIDs, nil)
|
members, err := g.db.FindGroupMember(ctx, []string{groupID}, userIDs, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -107,9 +109,7 @@ func (g *GroupNotificationSender) getGroupMembers(
|
|||||||
for _, member := range members {
|
for _, member := range members {
|
||||||
user, ok := users[member.UserID]
|
user, ok := users[member.UserID]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errs.ErrUserIDNotFound.Wrap(
|
return nil, errs.ErrUserIDNotFound.Wrap(fmt.Sprintf("group %s member %s not in user", member.GroupID, member.UserID))
|
||||||
fmt.Sprintf("group %s member %s not in user", member.GroupID, member.UserID),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
if member.Nickname == "" {
|
if member.Nickname == "" {
|
||||||
member.Nickname = user.Nickname
|
member.Nickname = user.Nickname
|
||||||
@ -131,11 +131,7 @@ func (g *GroupNotificationSender) getGroupMembers(
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) getGroupMemberMap(
|
func (g *GroupNotificationSender) getGroupMemberMap(ctx context.Context, groupID string, userIDs []string) (map[string]*sdkws.GroupMemberFullInfo, error) {
|
||||||
ctx context.Context,
|
|
||||||
groupID string,
|
|
||||||
userIDs []string,
|
|
||||||
) (map[string]*sdkws.GroupMemberFullInfo, error) {
|
|
||||||
members, err := g.getGroupMembers(ctx, groupID, userIDs)
|
members, err := g.getGroupMembers(ctx, groupID, userIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -147,11 +143,7 @@ func (g *GroupNotificationSender) getGroupMemberMap(
|
|||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) getGroupMember(
|
func (g *GroupNotificationSender) getGroupMember(ctx context.Context, groupID string, userID string) (*sdkws.GroupMemberFullInfo, error) {
|
||||||
ctx context.Context,
|
|
||||||
groupID string,
|
|
||||||
userID string,
|
|
||||||
) (*sdkws.GroupMemberFullInfo, error) {
|
|
||||||
members, err := g.getGroupMembers(ctx, groupID, []string{userID})
|
members, err := g.getGroupMembers(ctx, groupID, []string{userID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -171,11 +163,7 @@ func (g *GroupNotificationSender) getGroupOwnerAndAdminUserID(ctx context.Contex
|
|||||||
return utils.Slice(members, fn), nil
|
return utils.Slice(members, fn), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) groupDB2PB(
|
func (g *GroupNotificationSender) groupDB2PB(group *relation.GroupModel, ownerUserID string, memberCount uint32) *sdkws.GroupInfo {
|
||||||
group *relation.GroupModel,
|
|
||||||
ownerUserID string,
|
|
||||||
memberCount uint32,
|
|
||||||
) *sdkws.GroupInfo {
|
|
||||||
return &sdkws.GroupInfo{
|
return &sdkws.GroupInfo{
|
||||||
GroupID: group.GroupID,
|
GroupID: group.GroupID,
|
||||||
GroupName: group.GroupName,
|
GroupName: group.GroupName,
|
||||||
@ -197,10 +185,7 @@ func (g *GroupNotificationSender) groupDB2PB(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) groupMemberDB2PB(
|
func (g *GroupNotificationSender) groupMemberDB2PB(member *relation.GroupMemberModel, appMangerLevel int32) *sdkws.GroupMemberFullInfo {
|
||||||
member *relation.GroupMemberModel,
|
|
||||||
appMangerLevel int32,
|
|
||||||
) *sdkws.GroupMemberFullInfo {
|
|
||||||
return &sdkws.GroupMemberFullInfo{
|
return &sdkws.GroupMemberFullInfo{
|
||||||
GroupID: member.GroupID,
|
GroupID: member.GroupID,
|
||||||
UserID: member.UserID,
|
UserID: member.UserID,
|
||||||
@ -217,10 +202,7 @@ func (g *GroupNotificationSender) groupMemberDB2PB(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) getUsersInfoMap(
|
func (g *GroupNotificationSender) getUsersInfoMap(ctx context.Context, userIDs []string) (map[string]*sdkws.UserInfo, error) {
|
||||||
ctx context.Context,
|
|
||||||
userIDs []string,
|
|
||||||
) (map[string]*sdkws.UserInfo, error) {
|
|
||||||
users, err := g.getUsersInfo(ctx, userIDs)
|
users, err := g.getUsersInfo(ctx, userIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -232,11 +214,7 @@ func (g *GroupNotificationSender) getUsersInfoMap(
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) fillOpUser(
|
func (g *GroupNotificationSender) fillOpUser(ctx context.Context, opUser **sdkws.GroupMemberFullInfo, groupID string) error {
|
||||||
ctx context.Context,
|
|
||||||
opUser **sdkws.GroupMemberFullInfo,
|
|
||||||
groupID string,
|
|
||||||
) error {
|
|
||||||
if opUser == nil {
|
if opUser == nil {
|
||||||
return errs.ErrInternalServer.Wrap("**sdkws.GroupMemberFullInfo is nil")
|
return errs.ErrInternalServer.Wrap("**sdkws.GroupMemberFullInfo is nil")
|
||||||
}
|
}
|
||||||
@ -275,70 +253,35 @@ func (g *GroupNotificationSender) fillOpUser(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) GroupCreatedNotification(
|
func (g *GroupNotificationSender) GroupCreatedNotification(ctx context.Context, tips *sdkws.GroupCreatedTips) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
tips *sdkws.GroupCreatedTips,
|
|
||||||
) (err error) {
|
|
||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupCreatedNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupCreatedNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) GroupInfoSetNotification(
|
func (g *GroupNotificationSender) GroupInfoSetNotification(ctx context.Context, tips *sdkws.GroupInfoSetTips) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
tips *sdkws.GroupInfoSetTips,
|
|
||||||
) (err error) {
|
|
||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return g.Notification(
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetNotification, tips, rpcclient.WithRpcGetUserName())
|
||||||
ctx,
|
|
||||||
mcontext.GetOpUserID(ctx),
|
|
||||||
tips.Group.GroupID,
|
|
||||||
constant.GroupInfoSetNotification,
|
|
||||||
tips,
|
|
||||||
rpcclient.WithRpcGetUserName(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) GroupInfoSetNameNotification(
|
func (g *GroupNotificationSender) GroupInfoSetNameNotification(ctx context.Context, tips *sdkws.GroupInfoSetNameTips) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
tips *sdkws.GroupInfoSetNameTips,
|
|
||||||
) (err error) {
|
|
||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return g.Notification(
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetNameNotification, tips)
|
||||||
ctx,
|
|
||||||
mcontext.GetOpUserID(ctx),
|
|
||||||
tips.Group.GroupID,
|
|
||||||
constant.GroupInfoSetNameNotification,
|
|
||||||
tips,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) GroupInfoSetAnnouncementNotification(
|
func (g *GroupNotificationSender) GroupInfoSetAnnouncementNotification(ctx context.Context, tips *sdkws.GroupInfoSetAnnouncementTips) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
tips *sdkws.GroupInfoSetAnnouncementTips,
|
|
||||||
) (err error) {
|
|
||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return g.Notification(
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupInfoSetAnnouncementNotification, tips, rpcclient.WithRpcGetUserName())
|
||||||
ctx,
|
|
||||||
mcontext.GetOpUserID(ctx),
|
|
||||||
tips.Group.GroupID,
|
|
||||||
constant.GroupInfoSetAnnouncementNotification,
|
|
||||||
tips,
|
|
||||||
rpcclient.WithRpcGetUserName(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) JoinGroupApplicationNotification(
|
func (g *GroupNotificationSender) JoinGroupApplicationNotification(ctx context.Context, req *pbGroup.JoinGroupReq) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.JoinGroupReq,
|
|
||||||
) (err error) {
|
|
||||||
group, err := g.getGroupInfo(ctx, req.GroupID)
|
group, err := g.getGroupInfo(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -362,10 +305,7 @@ func (g *GroupNotificationSender) JoinGroupApplicationNotification(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) MemberQuitNotification(
|
func (g *GroupNotificationSender) MemberQuitNotification(ctx context.Context, member *sdkws.GroupMemberFullInfo) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
member *sdkws.GroupMemberFullInfo,
|
|
||||||
) (err error) {
|
|
||||||
defer log.ZDebug(ctx, "return")
|
defer log.ZDebug(ctx, "return")
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -380,10 +320,7 @@ func (g *GroupNotificationSender) MemberQuitNotification(
|
|||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), member.GroupID, constant.MemberQuitNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), member.GroupID, constant.MemberQuitNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(
|
func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.GroupApplicationResponseReq,
|
|
||||||
) (err error) {
|
|
||||||
defer log.ZDebug(ctx, "return")
|
defer log.ZDebug(ctx, "return")
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -403,13 +340,7 @@ func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, userID := range append(userIDs, mcontext.GetOpUserID(ctx)) {
|
for _, userID := range append(userIDs, mcontext.GetOpUserID(ctx)) {
|
||||||
err = g.Notification(
|
err = g.Notification(ctx, mcontext.GetOpUserID(ctx), userID, constant.GroupApplicationAcceptedNotification, tips)
|
||||||
ctx,
|
|
||||||
mcontext.GetOpUserID(ctx),
|
|
||||||
userID,
|
|
||||||
constant.GroupApplicationAcceptedNotification,
|
|
||||||
tips,
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(ctx, "failed", err)
|
log.ZError(ctx, "failed", err)
|
||||||
}
|
}
|
||||||
@ -417,10 +348,7 @@ func (g *GroupNotificationSender) GroupApplicationAcceptedNotification(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) GroupApplicationRejectedNotification(
|
func (g *GroupNotificationSender) GroupApplicationRejectedNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.GroupApplicationResponseReq,
|
|
||||||
) (err error) {
|
|
||||||
group, err := g.getGroupInfo(ctx, req.GroupID)
|
group, err := g.getGroupInfo(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -434,13 +362,7 @@ func (g *GroupNotificationSender) GroupApplicationRejectedNotification(
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, userID := range append(userIDs, mcontext.GetOpUserID(ctx)) {
|
for _, userID := range append(userIDs, mcontext.GetOpUserID(ctx)) {
|
||||||
err = g.Notification(
|
err = g.Notification(ctx, mcontext.GetOpUserID(ctx), userID, constant.GroupApplicationRejectedNotification, tips)
|
||||||
ctx,
|
|
||||||
mcontext.GetOpUserID(ctx),
|
|
||||||
userID,
|
|
||||||
constant.GroupApplicationRejectedNotification,
|
|
||||||
tips,
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(ctx, "failed", err)
|
log.ZError(ctx, "failed", err)
|
||||||
}
|
}
|
||||||
@ -448,10 +370,7 @@ func (g *GroupNotificationSender) GroupApplicationRejectedNotification(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) GroupOwnerTransferredNotification(
|
func (g *GroupNotificationSender) GroupOwnerTransferredNotification(ctx context.Context, req *pbGroup.TransferGroupOwnerReq) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.TransferGroupOwnerReq,
|
|
||||||
) (err error) {
|
|
||||||
group, err := g.getGroupInfo(ctx, req.GroupID)
|
group, err := g.getGroupInfo(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -461,38 +380,21 @@ func (g *GroupNotificationSender) GroupOwnerTransferredNotification(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tips := &sdkws.GroupOwnerTransferredTips{
|
tips := &sdkws.GroupOwnerTransferredTips{Group: group, OpUser: member[opUserID], NewGroupOwner: member[req.NewOwnerUserID]}
|
||||||
Group: group,
|
|
||||||
OpUser: member[opUserID],
|
|
||||||
NewGroupOwner: member[req.NewOwnerUserID],
|
|
||||||
}
|
|
||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return g.Notification(
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupOwnerTransferredNotification, tips)
|
||||||
ctx,
|
|
||||||
mcontext.GetOpUserID(ctx),
|
|
||||||
group.GroupID,
|
|
||||||
constant.GroupOwnerTransferredNotification,
|
|
||||||
tips,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) MemberKickedNotification(
|
func (g *GroupNotificationSender) MemberKickedNotification(ctx context.Context, tips *sdkws.MemberKickedTips) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
tips *sdkws.MemberKickedTips,
|
|
||||||
) (err error) {
|
|
||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.MemberKickedNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.MemberKickedNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) MemberInvitedNotification(
|
func (g *GroupNotificationSender) MemberInvitedNotification(ctx context.Context, groupID, reason string, invitedUserIDList []string) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
groupID, reason string,
|
|
||||||
invitedUserIDList []string,
|
|
||||||
) (err error) {
|
|
||||||
group, err := g.getGroupInfo(ctx, groupID)
|
group, err := g.getGroupInfo(ctx, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -511,10 +413,7 @@ func (g *GroupNotificationSender) MemberInvitedNotification(
|
|||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.MemberInvitedNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.MemberInvitedNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) MemberEnterNotification(
|
func (g *GroupNotificationSender) MemberEnterNotification(ctx context.Context, req *pbGroup.GroupApplicationResponseReq) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
req *pbGroup.GroupApplicationResponseReq,
|
|
||||||
) (err error) {
|
|
||||||
group, err := g.getGroupInfo(ctx, req.GroupID)
|
group, err := g.getGroupInfo(ctx, req.GroupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -527,21 +426,14 @@ func (g *GroupNotificationSender) MemberEnterNotification(
|
|||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.MemberEnterNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.MemberEnterNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) GroupDismissedNotification(
|
func (g *GroupNotificationSender) GroupDismissedNotification(ctx context.Context, tips *sdkws.GroupDismissedTips) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
tips *sdkws.GroupDismissedTips,
|
|
||||||
) (err error) {
|
|
||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupDismissedNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), tips.Group.GroupID, constant.GroupDismissedNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) GroupMemberMutedNotification(
|
func (g *GroupNotificationSender) GroupMemberMutedNotification(ctx context.Context, groupID, groupMemberUserID string, mutedSeconds uint32) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
groupID, groupMemberUserID string,
|
|
||||||
mutedSeconds uint32,
|
|
||||||
) (err error) {
|
|
||||||
group, err := g.getGroupInfo(ctx, groupID)
|
group, err := g.getGroupInfo(ctx, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -558,10 +450,7 @@ func (g *GroupNotificationSender) GroupMemberMutedNotification(
|
|||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberMutedNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberMutedNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) GroupMemberCancelMutedNotification(
|
func (g *GroupNotificationSender) GroupMemberCancelMutedNotification(ctx context.Context, groupID, groupMemberUserID string) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
groupID, groupMemberUserID string,
|
|
||||||
) (err error) {
|
|
||||||
group, err := g.getGroupInfo(ctx, groupID)
|
group, err := g.getGroupInfo(ctx, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -570,21 +459,11 @@ func (g *GroupNotificationSender) GroupMemberCancelMutedNotification(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tips := &sdkws.GroupMemberCancelMutedTips{
|
tips := &sdkws.GroupMemberCancelMutedTips{Group: group, OpUser: user[mcontext.GetOpUserID(ctx)], MutedUser: user[groupMemberUserID]}
|
||||||
Group: group,
|
|
||||||
OpUser: user[mcontext.GetOpUserID(ctx)],
|
|
||||||
MutedUser: user[groupMemberUserID],
|
|
||||||
}
|
|
||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return g.Notification(
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberCancelMutedNotification, tips)
|
||||||
ctx,
|
|
||||||
mcontext.GetOpUserID(ctx),
|
|
||||||
group.GroupID,
|
|
||||||
constant.GroupMemberCancelMutedNotification,
|
|
||||||
tips,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) GroupMutedNotification(ctx context.Context, groupID string) (err error) {
|
func (g *GroupNotificationSender) GroupMutedNotification(ctx context.Context, groupID string) (err error) {
|
||||||
@ -625,10 +504,7 @@ func (g *GroupNotificationSender) GroupCancelMutedNotification(ctx context.Conte
|
|||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupCancelMutedNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupCancelMutedNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) GroupMemberInfoSetNotification(
|
func (g *GroupNotificationSender) GroupMemberInfoSetNotification(ctx context.Context, groupID, groupMemberUserID string) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
groupID, groupMemberUserID string,
|
|
||||||
) (err error) {
|
|
||||||
group, err := g.getGroupInfo(ctx, groupID)
|
group, err := g.getGroupInfo(ctx, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -637,21 +513,14 @@ func (g *GroupNotificationSender) GroupMemberInfoSetNotification(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tips := &sdkws.GroupMemberInfoSetTips{
|
tips := &sdkws.GroupMemberInfoSetTips{Group: group, OpUser: user[mcontext.GetOpUserID(ctx)], ChangedUser: user[groupMemberUserID]}
|
||||||
Group: group,
|
|
||||||
OpUser: user[mcontext.GetOpUserID(ctx)],
|
|
||||||
ChangedUser: user[groupMemberUserID],
|
|
||||||
}
|
|
||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberInfoSetNotification, tips)
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberInfoSetNotification, tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) GroupMemberSetToAdminNotification(
|
func (g *GroupNotificationSender) GroupMemberSetToAdminNotification(ctx context.Context, groupID, groupMemberUserID string) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
groupID, groupMemberUserID string,
|
|
||||||
) (err error) {
|
|
||||||
group, err := g.getGroupInfo(ctx, groupID)
|
group, err := g.getGroupInfo(ctx, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -660,27 +529,14 @@ func (g *GroupNotificationSender) GroupMemberSetToAdminNotification(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tips := &sdkws.GroupMemberInfoSetTips{
|
tips := &sdkws.GroupMemberInfoSetTips{Group: group, OpUser: user[mcontext.GetOpUserID(ctx)], ChangedUser: user[groupMemberUserID]}
|
||||||
Group: group,
|
|
||||||
OpUser: user[mcontext.GetOpUserID(ctx)],
|
|
||||||
ChangedUser: user[groupMemberUserID],
|
|
||||||
}
|
|
||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return g.Notification(
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberSetToAdminNotification, tips)
|
||||||
ctx,
|
|
||||||
mcontext.GetOpUserID(ctx),
|
|
||||||
group.GroupID,
|
|
||||||
constant.GroupMemberSetToAdminNotification,
|
|
||||||
tips,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) GroupMemberSetToOrdinaryUserNotification(
|
func (g *GroupNotificationSender) GroupMemberSetToOrdinaryUserNotification(ctx context.Context, groupID, groupMemberUserID string) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
groupID, groupMemberUserID string,
|
|
||||||
) (err error) {
|
|
||||||
group, err := g.getGroupInfo(ctx, groupID)
|
group, err := g.getGroupInfo(ctx, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -689,28 +545,14 @@ func (g *GroupNotificationSender) GroupMemberSetToOrdinaryUserNotification(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
tips := &sdkws.GroupMemberInfoSetTips{
|
tips := &sdkws.GroupMemberInfoSetTips{Group: group, OpUser: user[mcontext.GetOpUserID(ctx)], ChangedUser: user[groupMemberUserID]}
|
||||||
Group: group,
|
|
||||||
OpUser: user[mcontext.GetOpUserID(ctx)],
|
|
||||||
ChangedUser: user[groupMemberUserID],
|
|
||||||
}
|
|
||||||
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
if err := g.fillOpUser(ctx, &tips.OpUser, tips.Group.GroupID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return g.Notification(
|
return g.Notification(ctx, mcontext.GetOpUserID(ctx), group.GroupID, constant.GroupMemberSetToOrdinaryUserNotification, tips)
|
||||||
ctx,
|
|
||||||
mcontext.GetOpUserID(ctx),
|
|
||||||
group.GroupID,
|
|
||||||
constant.GroupMemberSetToOrdinaryUserNotification,
|
|
||||||
tips,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GroupNotificationSender) MemberEnterDirectlyNotification(
|
func (g *GroupNotificationSender) MemberEnterDirectlyNotification(ctx context.Context, groupID string, entrantUserID string) (err error) {
|
||||||
ctx context.Context,
|
|
||||||
groupID string,
|
|
||||||
entrantUserID string,
|
|
||||||
) (err error) {
|
|
||||||
defer log.ZDebug(ctx, "return")
|
defer log.ZDebug(ctx, "return")
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
// Copyright © 2023 OpenIM. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
package notification
|
package notification
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -16,11 +30,7 @@ func NewMsgNotificationSender(opts ...rpcclient.NotificationSenderOptions) *MsgN
|
|||||||
return &MsgNotificationSender{rpcclient.NewNotificationSender(opts...)}
|
return &MsgNotificationSender{rpcclient.NewNotificationSender(opts...)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MsgNotificationSender) UserDeleteMsgsNotification(
|
func (m *MsgNotificationSender) UserDeleteMsgsNotification(ctx context.Context, userID, conversationID string, seqs []int64) error {
|
||||||
ctx context.Context,
|
|
||||||
userID, conversationID string,
|
|
||||||
seqs []int64,
|
|
||||||
) error {
|
|
||||||
tips := sdkws.DeleteMsgsTips{
|
tips := sdkws.DeleteMsgsTips{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
ConversationID: conversationID,
|
ConversationID: conversationID,
|
||||||
@ -29,14 +39,7 @@ func (m *MsgNotificationSender) UserDeleteMsgsNotification(
|
|||||||
return m.Notification(ctx, userID, userID, constant.MsgDeleteNotification, &tips)
|
return m.Notification(ctx, userID, userID, constant.MsgDeleteNotification, &tips)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MsgNotificationSender) MarkAsReadNotification(
|
func (m *MsgNotificationSender) MarkAsReadNotification(ctx context.Context, conversationID string, sesstionType int32, sendID, recvID string, seqs []int64, hasReadSeq int64) error {
|
||||||
ctx context.Context,
|
|
||||||
conversationID string,
|
|
||||||
sesstionType int32,
|
|
||||||
sendID, recvID string,
|
|
||||||
seqs []int64,
|
|
||||||
hasReadSeq int64,
|
|
||||||
) error {
|
|
||||||
tips := &sdkws.MarkAsReadTips{
|
tips := &sdkws.MarkAsReadTips{
|
||||||
MarkAsReadUserID: sendID,
|
MarkAsReadUserID: sendID,
|
||||||
ConversationID: conversationID,
|
ConversationID: conversationID,
|
||||||
|
@ -37,10 +37,12 @@ echo -e "${BOLD_PREFIX}_________________________________________________________
|
|||||||
bin_dir="$BIN_DIR"
|
bin_dir="$BIN_DIR"
|
||||||
logs_dir="$OPENIM_ROOT/logs"
|
logs_dir="$OPENIM_ROOT/logs"
|
||||||
sdk_db_dir="$OPENIM_ROOT/db/sdk/"
|
sdk_db_dir="$OPENIM_ROOT/db/sdk/"
|
||||||
|
|
||||||
|
echo "==> bin_dir=$bin_dir"
|
||||||
|
echo "==> logs_dir=$logs_dir"
|
||||||
|
echo "==> sdk_db_dir=$sdk_db_dir"
|
||||||
|
|
||||||
# Automatically created when there is no bin, logs folder
|
# Automatically created when there is no bin, logs folder
|
||||||
if [ ! -d $bin_dir ]; then
|
|
||||||
mkdir -p $bin_dir
|
|
||||||
fi
|
|
||||||
if [ ! -d $logs_dir ]; then
|
if [ ! -d $logs_dir ]; then
|
||||||
mkdir -p $logs_dir
|
mkdir -p $logs_dir
|
||||||
fi
|
fi
|
||||||
@ -48,20 +50,17 @@ if [ ! -d $sdk_db_dir ]; then
|
|||||||
mkdir -p $sdk_db_dir
|
mkdir -p $sdk_db_dir
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Include shell font styles and some basic information
|
|
||||||
OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
|
||||||
|
|
||||||
echo "PWD=================>$PWD"
|
|
||||||
|
|
||||||
#Include shell font styles and some basic information
|
|
||||||
source ./style_info.sh
|
|
||||||
source ./path_info.sh
|
|
||||||
source ./function.sh
|
|
||||||
|
|
||||||
cd $OPENIM_ROOT
|
cd $OPENIM_ROOT
|
||||||
|
|
||||||
# Execute 'make build'
|
# CPU core number
|
||||||
make build
|
cpu_count=$(lscpu | grep -e '^CPU(s):' | awk '{print $2}')
|
||||||
|
echo -e "${GREEN_PREFIX}======> cpu_count=$cpu_count${COLOR_SUFFIX}"
|
||||||
|
|
||||||
|
# Count the number of concurrent compilations (half the number of cpus)
|
||||||
|
compile_count=$((cpu_count / 2))
|
||||||
|
|
||||||
|
# Execute 'make build' run the make command for concurrent compilation
|
||||||
|
make -j$compile_count build
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "make build Error, script exits"
|
echo "make build Error, script exits"
|
||||||
|
@ -23,14 +23,14 @@ LICENSE_TEMPLATE ?= $(ROOT_DIR)/scripts/LICENSE/LICENSE_TEMPLATES
|
|||||||
.PHONY: copyright.verify
|
.PHONY: copyright.verify
|
||||||
copyright.verify: tools.verify.addlicense
|
copyright.verify: tools.verify.addlicense
|
||||||
@echo "===========> Validate boilerplate headers for assign files starting in the $(ROOT_DIR) directory"
|
@echo "===========> Validate boilerplate headers for assign files starting in the $(ROOT_DIR) directory"
|
||||||
@$(TOOLS_DIR)/addlicense -v -check -ignore **/test/** -f $(LICENSE_TEMPLATE) $(CODE_DIRS)
|
@$(TOOLS_DIR)/addlicense -v -check -ignore **/test/** -ignore **pb** -f $(LICENSE_TEMPLATE) $(CODE_DIRS)
|
||||||
@echo "===========> End of boilerplate headers check..."
|
@echo "===========> End of boilerplate headers check..."
|
||||||
|
|
||||||
## copyright.add: Add the boilerplate headers for all files
|
## copyright.add: Add the boilerplate headers for all files
|
||||||
.PHONY: copyright.add
|
.PHONY: copyright.add
|
||||||
copyright.add: tools.verify.addlicense
|
copyright.add: tools.verify.addlicense
|
||||||
@echo "===========> Adding $(LICENSE_TEMPLATE) the boilerplate headers for all files"
|
@echo "===========> Adding $(LICENSE_TEMPLATE) the boilerplate headers for all files"
|
||||||
@$(TOOLS_DIR)/addlicense -y $(shell date +"%Y") -v -c "OpenIM." -f $(LICENSE_TEMPLATE) $(CODE_DIRS)
|
@$(TOOLS_DIR)/addlicense -y $(shell date +"%Y") -ignore **pb** -v -c "OpenIM." -f $(LICENSE_TEMPLATE) $(CODE_DIRS)
|
||||||
@echo "===========> End the copyright is added..."
|
@echo "===========> End the copyright is added..."
|
||||||
|
|
||||||
# Addlicense Flags:
|
# Addlicense Flags:
|
||||||
|
@ -20,6 +20,34 @@
|
|||||||
# docker registry: registry.example.com/namespace/image:tag as: registry.hub.docker.com/cubxxw/<image-name>:<tag>
|
# docker registry: registry.example.com/namespace/image:tag as: registry.hub.docker.com/cubxxw/<image-name>:<tag>
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# # If you wish built the manager image targeting other platforms you can use the --platform flag.
|
||||||
|
# # (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
|
||||||
|
# # More info: https://docs.docker.com/develop/develop-images/build_enhancements/
|
||||||
|
# .PHONY: docker-build
|
||||||
|
# docker-build: test ## Build docker image with the manager.
|
||||||
|
# docker build -t ${IMG} .
|
||||||
|
|
||||||
|
# .PHONY: docker-push
|
||||||
|
# docker-push: ## Push docker image with the manager.
|
||||||
|
# docker push ${IMG}
|
||||||
|
|
||||||
|
# # PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
|
||||||
|
# # architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
|
||||||
|
# # - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
|
||||||
|
# # - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
|
||||||
|
# # - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
|
||||||
|
# # To properly provided solutions that supports more than one platform you should use this option.
|
||||||
|
# PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
|
||||||
|
# .PHONY: docker-buildx
|
||||||
|
# docker-buildx: test ## Build and push docker image for the manager for cross-platform support
|
||||||
|
# # copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
|
||||||
|
# sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
|
||||||
|
# - docker buildx create --name project-v3-builder
|
||||||
|
# docker buildx use project-v3-builder
|
||||||
|
# - docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
|
||||||
|
# - docker buildx rm project-v3-builder
|
||||||
|
# rm Dockerfile.cross
|
||||||
|
|
||||||
DOCKER := docker
|
DOCKER := docker
|
||||||
DOCKER_SUPPORTED_API_VERSION ?= 1.32|1.40|1.41
|
DOCKER_SUPPORTED_API_VERSION ?= 1.32|1.40|1.41
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ sleep 1
|
|||||||
cd ${msg_gateway_binary_root}
|
cd ${msg_gateway_binary_root}
|
||||||
for ((i = 0; i < ${#ws_ports[@]}; i++)); do
|
for ((i = 0; i < ${#ws_ports[@]}; i++)); do
|
||||||
echo "==========================start msg_gateway server===========================">>$OPENIM_ROOT/logs/openIM.log
|
echo "==========================start msg_gateway server===========================">>$OPENIM_ROOT/logs/openIM.log
|
||||||
nohup ./${openim_msggateway} --port ${rpc_ports[$i]} --ws_port ${ws_ports[$i]} --prometheus_port ${prome_ports[$i]} --config_folder_path ${configfile_path} --configFolderPath ${log_path} >>$OPENIM_ROOT/logs/openIM.log 2>&1 &
|
nohup ./${openim_msggateway} --port ${rpc_ports[$i]} --ws_port ${ws_ports[$i]} --prometheus_port ${prome_ports[$i]} --config_folder_path ${configfile_path} >>$OPENIM_ROOT/logs/openIM.log 2>&1 &
|
||||||
done
|
done
|
||||||
|
|
||||||
#Check launched service process
|
#Check launched service process
|
||||||
|
@ -55,9 +55,9 @@ sleep 1
|
|||||||
cd ${msg_transfer_binary_root}
|
cd ${msg_transfer_binary_root}
|
||||||
for ((i = 0; i < ${msg_transfer_service_num}; i++)); do
|
for ((i = 0; i < ${msg_transfer_service_num}; i++)); do
|
||||||
prome_port=${prome_ports[$i]}
|
prome_port=${prome_ports[$i]}
|
||||||
cmd="nohup ./${openim_msgtransfer} --config_folder_path ${configfile_path} --configFolderPath ${log_path}"
|
cmd="nohup ./${openim_msgtransfer} --config_folder_path ${configfile_path} "
|
||||||
if [ $prome_port != "" ]; then
|
if [ $prome_port != "" ]; then
|
||||||
cmd="$cmd --prometheus_port $prome_port --config_folder_path ${configfile_path} --configFolderPath ${log_path}"
|
cmd="$cmd --prometheus_port $prome_port --config_folder_path ${configfile_path} "
|
||||||
fi
|
fi
|
||||||
echo "==========================start msg_transfer server===========================">>$OPENIM_ROOT/logs/openIM.log
|
echo "==========================start msg_transfer server===========================">>$OPENIM_ROOT/logs/openIM.log
|
||||||
$cmd >>$OPENIM_ROOT/logs/openIM.log 2>&1 &
|
$cmd >>$OPENIM_ROOT/logs/openIM.log 2>&1 &
|
||||||
|
@ -100,9 +100,9 @@ for ((i = 0; i < ${#service_filename[*]}; i++)); do
|
|||||||
for ((j = 0; j < ${#service_ports[*]}; j++)); do
|
for ((j = 0; j < ${#service_ports[*]}; j++)); do
|
||||||
#Start the service in the background
|
#Start the service in the background
|
||||||
if [ -z "${prome_ports[$j]}" ]; then
|
if [ -z "${prome_ports[$j]}" ]; then
|
||||||
cmd="./${service_filename[$i]} --port ${service_ports[$j]} --config_folder_path ${configfile_path} --configFolderPath ${log_path}"
|
cmd="./${service_filename[$i]} --port ${service_ports[$j]} --config_folder_path ${configfile_path} "
|
||||||
else
|
else
|
||||||
cmd="./${service_filename[$i]} --port ${service_ports[$j]} --prometheus_port ${prome_ports[$j]} --config_folder_path ${configfile_path} --configFolderPath ${log_path}"
|
cmd="./${service_filename[$i]} --port ${service_ports[$j]} --prometheus_port ${prome_ports[$j]} --config_folder_path ${configfile_path} "
|
||||||
fi
|
fi
|
||||||
if [ $i -eq 0 -o $i -eq 1 ]; then
|
if [ $i -eq 0 -o $i -eq 1 ]; then
|
||||||
cmd="./${service_filename[$i]} --port ${service_ports[$j]}"
|
cmd="./${service_filename[$i]} --port ${service_ports[$j]}"
|
||||||
|
1
test/common.sh
Normal file
1
test/common.sh
Normal file
@ -0,0 +1 @@
|
|||||||
|
#!/usr/bin/env bash
|
Loading…
x
Reference in New Issue
Block a user