Compare commits

...

5 Commits

Author SHA1 Message Date
WhereAreBugs
f65c6d6d57
Merge 6e7bfbea8e3506dd03cce1fab90e95b8281eba57 into 5211d43d9d86772a45b451e49d526400a4e0448e 2026-03-27 20:54:23 +00:00
icey-yu
5211d43d9d
Merge pull request #3707 from icey-yu/feat-comment-383
feat: enhance configuration files with detailed comments for clarity
2026-03-20 18:26:37 +08:00
icey-yu
801ac740b7 feat: enhance configuration files with detailed comments for clarity 2026-03-20 18:24:51 +08:00
dsx137
5028624fa3
feat: gomake upgrade (#3701) 2026-03-19 12:07:04 +08:00
WhereAreBugs
6e7bfbea8e remove(CopyStructFields):full datautil.CopyStructFields has been replaced due to performance issue. 2026-02-04 13:44:43 +08:00
23 changed files with 374 additions and 137 deletions

View File

@ -1,34 +1,36 @@
# Global Alertmanager runtime and SMTP settings.
global:
resolve_timeout: 5m
smtp_from: alert@openim.io
smtp_smarthost: smtp.163.com:465
smtp_auth_username: alert@openim.io
smtp_auth_password: YOURAUTHPASSWORD
smtp_require_tls: false
smtp_hello: xxx
resolve_timeout: 5m # Wait time before an alert is considered resolved when no further updates are received.
smtp_from: alert@openim.io # Sender address displayed in alert emails.
smtp_smarthost: smtp.163.com:465 # SMTP relay endpoint in host:port format.
smtp_auth_username: alert@openim.io # SMTP authentication username (commonly the same as smtp_from).
smtp_auth_password: YOURAUTHPASSWORD # SMTP authorization token or app password.
smtp_require_tls: false # Set to true when your SMTP provider requires STARTTLS.
smtp_hello: xxx # HELO/EHLO identity presented to the SMTP server.
templates:
- /etc/alertmanager/email.tmpl
- /etc/alertmanager/email.tmpl # Go template file used to render HTML email content.
# Root routing tree for all incoming alerts.
route:
group_by: [ 'alertname' ]
group_wait: 5s
group_interval: 5s
repeat_interval: 5m
receiver: email
group_by: [ 'alertname' ] # Alerts sharing this label value are batched into one notification.
group_wait: 5s # Initial delay before sending the first notification for a new alert group.
group_interval: 5s # Minimum interval between notifications for the same alert group.
repeat_interval: 5m # Reminder interval while an alert group remains firing.
receiver: email # Default receiver when no child route matches.
routes:
- matchers:
- alertname = "XXX"
group_by: [ 'instance' ]
- alertname = "XXX" # Example matcher; replace with a real alert name or remove this route.
group_by: [ 'instance' ] # Override grouping for this specific route.
group_wait: 5s
group_interval: 5s
repeat_interval: 5m
receiver: email
receivers:
- name: email
- name: email # Receiver name referenced by route.receiver.
email_configs:
- to: 'alert@example.com'
html: '{{ template "email.to.html" . }}'
headers: { Subject: "[OPENIM-SERVER]Alarm" }
send_resolved: true
- to: 'alert@example.com' # Recipient mailbox for alert notifications.
html: '{{ template "email.to.html" . }}' # Rendered with the template declared in email.tmpl.
headers: { Subject: "[OPENIM-SERVER]Alarm" } # Custom email subject line.
send_resolved: true # Also send a notification when the alert recovers.

View File

@ -1,3 +1,6 @@
{{/* OpenIM Alertmanager email template.
This template renders both firing and resolved alerts.
Each alert entry reads labels and annotations from Prometheus rule definitions. */}}
{{ define "email.to.html" }}
{{ if eq .Status "firing" }}
{{ range .Alerts }}

View File

@ -1,30 +1,31 @@
# Default Prometheus alert groups for OpenIM.
groups:
- name: instance_down
- name: instance_down # Fires when a monitored target remains unreachable.
rules:
- alert: InstanceDown
expr: up == 0
for: 1m
expr: up == 0 # The built-in "up" metric is 0 when the latest scrape fails.
for: 1m # Trigger only if the condition remains true for more than 1 minute.
labels:
severity: critical
severity: critical # Used by Alertmanager for routing and notification priority.
annotations:
summary: "Instance {{ $labels.instance }} down"
description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 1 minutes."
description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 1 minute."
- name: database_insert_failure_alerts
- name: database_insert_failure_alerts # Detects failures when persisting messages to Redis or MongoDB.
rules:
- alert: DatabaseInsertFailed
expr: (increase(msg_insert_redis_failed_total[5m]) > 0) or (increase(msg_insert_mongo_failed_total[5m]) > 0)
for: 1m
expr: (increase(msg_insert_redis_failed_total[5m]) > 0) or (increase(msg_insert_mongo_failed_total[5m]) > 0) # Any positive increase indicates write failures occurred in the last 5 minutes.
for: 1m # Avoid firing on very short spikes.
labels:
severity: critical
annotations:
summary: "Increase in MsgInsertRedisFailedCounter or MsgInsertMongoFailedCounter detected"
description: "Either MsgInsertRedisFailedCounter or MsgInsertMongoFailedCounter has increased in the last 5 minutes, indicating failures in message insert operations to Redis or MongoDB,maybe the redis or mongodb is crash."
description: "Either MsgInsertRedisFailedCounter or MsgInsertMongoFailedCounter increased in the last 5 minutes, indicating message insert failures to Redis or MongoDB and a possible backend outage."
- name: registrations_few
- name: registrations_few # Operational early-warning rule for unusually low login/registration activity.
rules:
- alert: RegistrationsFew
expr: increase(user_login_total[1h]) == 0
expr: increase(user_login_total[1h]) == 0 # No successful login/registration events observed in 1 hour.
for: 1m
labels:
severity: info
@ -32,10 +33,10 @@ groups:
summary: "Too few registrations within the time frame"
description: "The number of registrations in the last hour is 0. There might be some issues."
- name: messages_few
- name: messages_few # Operational early-warning rule for unusually low messaging activity.
rules:
- alert: MessagesFew
expr: (increase(single_chat_msg_process_success_total[1h])+increase(group_chat_msg_process_success_total[1h])) == 0
expr: (increase(single_chat_msg_process_success_total[1h])+increase(group_chat_msg_process_success_total[1h])) == 0 # No successful single or group messages observed in 1 hour.
for: 1m
labels:
severity: info

View File

@ -8,7 +8,7 @@ api:
prometheus:
# Whether to enable prometheus
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# autoSetPorts indicates whether to automatically set the ports
autoSetPorts: true

View File

@ -8,7 +8,7 @@ rpc:
ports: [ 10140, 10141, 10142, 10143, 10144, 10145, 10146, 10147, 10148, 10149, 10150, 10151, 10152, 10153, 10154, 10155 ]
prometheus:
# Enable or disable Prometheus monitoring
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
# It will only take effect when autoSetPorts is set to false.

View File

@ -1,5 +1,5 @@
prometheus:
# Enable or disable Prometheus monitoring
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# autoSetPorts indicates whether to automatically set the ports
autoSetPorts: true

View File

@ -10,7 +10,7 @@ rpc:
ports: [ 10170, 10171, 10172, 10173, 10174, 10175, 10176, 10177, 10178, 10179, 10180, 10181, 10182, 10183, 10184, 10185 ]
prometheus:
# Enable or disable Prometheus monitoring
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
# It will only take effect when autoSetPorts is set to false.

View File

@ -10,7 +10,7 @@ rpc:
ports: [ 10200 ]
prometheus:
# Enable or disable Prometheus monitoring
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
# It will only take effect when autoSetPorts is set to false.

View File

@ -10,7 +10,7 @@ rpc:
ports: [ 10220 ]
prometheus:
# Enable or disable Prometheus monitoring
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
# It will only take effect when autoSetPorts is set to false.

View File

@ -10,7 +10,7 @@ rpc:
ports: [ 10240 ]
prometheus:
# Enable or disable Prometheus monitoring
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
# It will only take effect when autoSetPorts is set to false.

View File

@ -10,7 +10,7 @@ rpc:
ports: [ 10260 ]
prometheus:
# Enable or disable Prometheus monitoring
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
# It will only take effect when autoSetPorts is set to false.

View File

@ -10,7 +10,7 @@ rpc:
ports: [ 10280 ]
prometheus:
# Enable or disable Prometheus monitoring
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
# It will only take effect when autoSetPorts is set to false.

View File

@ -10,7 +10,7 @@ rpc:
ports: [ 10300 ]
prometheus:
# Enable or disable Prometheus monitoring
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup
# It will only take effect when autoSetPorts is set to false.

View File

@ -10,7 +10,7 @@ rpc:
ports: [ 10320 ]
prometheus:
# Whether to enable prometheus
# Enable Prometheus metrics exposure for this service; set to true to allow scraping.
enable: true
# Prometheus listening ports, must be consistent with the number of rpc.ports
# It will only take effect when autoSetPorts is set to false.

View File

@ -1,35 +1,34 @@
# my global config
# Global Prometheus runtime settings.
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# scrape_timeout defaults to 10s unless overridden in a specific scrape job.
# Alertmanager configuration
# Alertmanager endpoints that receive alert events from Prometheus.
alerting:
alertmanagers:
- static_configs:
- targets: [127.0.0.1:19093]
- targets: [127.0.0.1:19093] # Alertmanager address in host:port format.
# Load rules once and periodically evaluate them according to the global evaluation_interval.
# Rule files loaded by Prometheus.
rule_files:
- instance-down-rules.yml
- instance-down-rules.yml # Default OpenIM alert rules; add more files here if needed.
# - first_rules.yml
# - second_rules.yml
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
# Scrape jobs used to collect infrastructure and OpenIM service metrics.
scrape_configs:
# The job name is added as a label "job=job_name" to any timeseries scraped from this config.
# Monitored information captured by prometheus
# prometheus fetches application services
# The job_name value is attached as the "job" label in collected time series.
- job_name: node_exporter
static_configs:
- targets: [ 127.0.0.1:19100 ]
- targets: [ 127.0.0.1:19100 ] # node_exporter endpoint for host CPU, memory, disk, and network metrics.
# OpenIM services are discovered dynamically from the admin API.
# For multi-host deployments, replace 127.0.0.1 with a reachable internal address.
- job_name: openimserver-openim-api
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/api"
- url: "http://127.0.0.1:10002/prometheus_discovery/api" # Service discovery endpoint for OpenIM API instances.
# static_configs:
# - targets: [ 127.0.0.1:12002 ]
# labels:
@ -37,7 +36,7 @@ scrape_configs:
- job_name: openimserver-openim-msggateway
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/msg_gateway"
- url: "http://127.0.0.1:10002/prometheus_discovery/msg_gateway" # Service discovery endpoint for msggateway instances.
# static_configs:
# - targets: [ 127.0.0.1:12140 ]
# # - targets: [ 127.0.0.1:12140, 127.0.0.1:12141, 127.0.0.1:12142, 127.0.0.1:12143, 127.0.0.1:12144, 127.0.0.1:12145, 127.0.0.1:12146, 127.0.0.1:12147, 127.0.0.1:12148, 127.0.0.1:12149, 127.0.0.1:12150, 127.0.0.1:12151, 127.0.0.1:12152, 127.0.0.1:12153, 127.0.0.1:12154, 127.0.0.1:12155 ]
@ -46,7 +45,7 @@ scrape_configs:
- job_name: openimserver-openim-msgtransfer
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/msg_transfer"
- url: "http://127.0.0.1:10002/prometheus_discovery/msg_transfer" # Service discovery endpoint for msgtransfer instances.
# static_configs:
# - targets: [ 127.0.0.1:12020, 127.0.0.1:12021, 127.0.0.1:12022, 127.0.0.1:12023, 127.0.0.1:12024, 127.0.0.1:12025, 127.0.0.1:12026, 127.0.0.1:12027 ]
# # - targets: [ 127.0.0.1:12020, 127.0.0.1:12021, 127.0.0.1:12022, 127.0.0.1:12023, 127.0.0.1:12024, 127.0.0.1:12025, 127.0.0.1:12026, 127.0.0.1:12027, 127.0.0.1:12028, 127.0.0.1:12029, 127.0.0.1:12030, 127.0.0.1:12031, 127.0.0.1:12032, 127.0.0.1:12033, 127.0.0.1:12034, 127.0.0.1:12035 ]
@ -55,7 +54,7 @@ scrape_configs:
- job_name: openimserver-openim-push
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/push"
- url: "http://127.0.0.1:10002/prometheus_discovery/push" # Service discovery endpoint for push service instances.
# static_configs:
# - targets: [ 127.0.0.1:12170, 127.0.0.1:12171, 127.0.0.1:12172, 127.0.0.1:12173, 127.0.0.1:12174, 127.0.0.1:12175, 127.0.0.1:12176, 127.0.0.1:12177 ]
## - targets: [ 127.0.0.1:12170, 127.0.0.1:12171, 127.0.0.1:12172, 127.0.0.1:12173, 127.0.0.1:12174, 127.0.0.1:12175, 127.0.0.1:12176, 127.0.0.1:12177, 127.0.0.1:12178, 127.0.0.1:12179, 127.0.0.1:12180, 127.0.0.1:12182, 127.0.0.1:12183, 127.0.0.1:12184, 127.0.0.1:12185, 127.0.0.1:12186 ]
@ -64,7 +63,7 @@ scrape_configs:
- job_name: openimserver-openim-rpc-auth
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/auth"
- url: "http://127.0.0.1:10002/prometheus_discovery/auth" # Service discovery endpoint for auth RPC instances.
# static_configs:
# - targets: [ 127.0.0.1:12200 ]
# labels:
@ -72,7 +71,7 @@ scrape_configs:
- job_name: openimserver-openim-rpc-conversation
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/conversation"
- url: "http://127.0.0.1:10002/prometheus_discovery/conversation" # Service discovery endpoint for conversation RPC instances.
# static_configs:
# - targets: [ 127.0.0.1:12220 ]
# labels:
@ -80,7 +79,7 @@ scrape_configs:
- job_name: openimserver-openim-rpc-friend
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/friend"
- url: "http://127.0.0.1:10002/prometheus_discovery/friend" # Service discovery endpoint for friend RPC instances.
# static_configs:
# - targets: [ 127.0.0.1:12240 ]
# labels:
@ -88,7 +87,7 @@ scrape_configs:
- job_name: openimserver-openim-rpc-group
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/group"
- url: "http://127.0.0.1:10002/prometheus_discovery/group" # Service discovery endpoint for group RPC instances.
# static_configs:
# - targets: [ 127.0.0.1:12260 ]
# labels:
@ -96,7 +95,7 @@ scrape_configs:
- job_name: openimserver-openim-rpc-msg
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/msg"
- url: "http://127.0.0.1:10002/prometheus_discovery/msg" # Service discovery endpoint for msg RPC instances.
# static_configs:
# - targets: [ 127.0.0.1:12280 ]
# labels:
@ -104,7 +103,7 @@ scrape_configs:
- job_name: openimserver-openim-rpc-third
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/third"
- url: "http://127.0.0.1:10002/prometheus_discovery/third" # Service discovery endpoint for third-party RPC instances.
# static_configs:
# - targets: [ 127.0.0.1:12300 ]
# labels:
@ -112,8 +111,8 @@ scrape_configs:
- job_name: openimserver-openim-rpc-user
http_sd_configs:
- url: "http://127.0.0.1:10002/prometheus_discovery/user"
- url: "http://127.0.0.1:10002/prometheus_discovery/user" # Service discovery endpoint for user RPC instances.
# static_configs:
# - targets: [ 127.0.0.1:12320 ]
# labels:
# namespace: default
# namespace: default

27
go.mod
View File

@ -1,6 +1,6 @@
module github.com/openimsdk/open-im-server/v3
go 1.22.7
go 1.25.0
require (
firebase.google.com/go/v4 v4.14.1
@ -12,11 +12,11 @@ require (
github.com/gorilla/websocket v1.5.1
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/mitchellh/mapstructure v1.5.0
github.com/openimsdk/protocol v0.0.73-alpha.19
github.com/openimsdk/tools v0.0.50-alpha.106
github.com/openimsdk/protocol v0.0.73-alpha.12
github.com/openimsdk/tools v0.0.50-alpha.113
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.18.0
github.com/stretchr/testify v1.10.0
github.com/stretchr/testify v1.11.1
go.mongodb.org/mongo-driver v1.14.0
google.golang.org/api v0.170.0
google.golang.org/grpc v1.71.0
@ -35,7 +35,7 @@ require (
github.com/hashicorp/golang-lru/v2 v2.0.7
github.com/kelindar/bitmap v1.5.2
github.com/likexian/gokit v0.25.13
github.com/openimsdk/gomake v0.0.15-alpha.5
github.com/openimsdk/gomake v0.0.17
github.com/redis/go-redis/v9 v9.4.0
github.com/robfig/cron/v3 v3.0.1
github.com/shirou/gopsutil v3.21.11+incompatible
@ -72,6 +72,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/sts v1.33.1 // indirect
github.com/aws/smithy-go v1.22.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bmatcuk/doublestar/v4 v4.10.0 // indirect
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
@ -86,6 +87,7 @@ require (
github.com/eapache/go-resiliency v1.6.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/ebitengine/purego v0.10.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
@ -94,7 +96,7 @@ require (
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
@ -104,7 +106,7 @@ require (
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
@ -131,7 +133,8 @@ require (
github.com/leodido/go-urn v1.4.0 // indirect
github.com/lestrrat-go/strftime v1.0.6 // indirect
github.com/lithammer/shortuuid v3.0.0+incompatible // indirect
github.com/magefile/mage v1.15.0 // indirect
github.com/lufia/plan9stats v0.0.0-20260216142805-b3301c5f2a88 // indirect
github.com/magefile/mage v1.16.1 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
@ -147,6 +150,7 @@ require (
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
@ -156,6 +160,7 @@ require (
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sercand/kuberesolver/v6 v6.0.1 // indirect
github.com/shirou/gopsutil/v4 v4.26.2 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
@ -163,8 +168,8 @@ require (
github.com/stretchr/objx v0.5.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tencentyun/cos-go-sdk-v5 v0.7.47 // indirect
github.com/tklauser/go-sysconf v0.3.13 // indirect
github.com/tklauser/numcpus v0.7.0 // indirect
github.com/tklauser/go-sysconf v0.3.16 // indirect
github.com/tklauser/numcpus v0.11.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
@ -189,7 +194,7 @@ require (
golang.org/x/image v0.15.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/oauth2 v0.25.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/sys v0.42.0 // indirect
golang.org/x/term v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.5.0 // indirect

50
go.sum
View File

@ -61,6 +61,8 @@ github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLj
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bmatcuk/doublestar/v4 v4.10.0 h1:zU9WiOla1YA122oLM6i4EXvGW62DvKZVxIe6TYWexEs=
github.com/bmatcuk/doublestar/v4 v4.10.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
@ -103,6 +105,8 @@ github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 h1:Oy0F4A
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3/go.mod h1:YvSRo5mw33fLEx1+DlK6L2VV43tJt5Eyel9n9XBcR+0=
github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
github.com/ebitengine/purego v0.10.0 h1:QIw4xfpWT6GWTzaW5XEKy3HXoqrJGx1ijYHzTF0/ISU=
github.com/ebitengine/purego v0.10.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
@ -134,8 +138,9 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE=
github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs=
github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE=
@ -202,8 +207,8 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
@ -303,8 +308,10 @@ github.com/likexian/gokit v0.25.13 h1:p2Uw3+6fGG53CwdU2Dz0T6bOycdb2+bAFAa3ymwWVk
github.com/likexian/gokit v0.25.13/go.mod h1:qQhEWFBEfqLCO3/vOEo2EDKd+EycekVtUK4tex+l2H4=
github.com/lithammer/shortuuid v3.0.0+incompatible h1:NcD0xWW/MZYXEHa6ITy6kaXN5nwm/V115vj2YXfhS0w=
github.com/lithammer/shortuuid v3.0.0+incompatible/go.mod h1:FR74pbAuElzOUuenUHTK2Tciko1/vKuIKS9dSkDrA4w=
github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg=
github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
github.com/lufia/plan9stats v0.0.0-20260216142805-b3301c5f2a88 h1:PTw+yKnXcOFCR6+8hHTyWBeQ/P4Nb7dd4/0ohEcWQuM=
github.com/lufia/plan9stats v0.0.0-20260216142805-b3301c5f2a88/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg=
github.com/magefile/mage v1.16.1 h1:j5UwkdA48xTlGs0Hcm1Q3sSAcxBorntQjiewDNMsqlo=
github.com/magefile/mage v1.16.1/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
@ -345,12 +352,12 @@ github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA
github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To=
github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y=
github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
github.com/openimsdk/gomake v0.0.15-alpha.5 h1:eEZCEHm+NsmcO3onXZPIUbGFCYPYbsX5beV3ZyOsGhY=
github.com/openimsdk/gomake v0.0.15-alpha.5/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
github.com/openimsdk/protocol v0.0.73-alpha.19 h1:CvXoDF2U73UcMhLnrtMFks2Aw+bXiDgH8AITEt783/s=
github.com/openimsdk/protocol v0.0.73-alpha.19/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw=
github.com/openimsdk/tools v0.0.50-alpha.106 h1:gaqU08IbRxOdL16ZEQNyYLhCTf7K1HNkrik8KZLA+BM=
github.com/openimsdk/tools v0.0.50-alpha.106/go.mod h1:x9i/e+WJFW4tocy6RNJQ9NofQiP3KJ1Y576/06TqOG4=
github.com/openimsdk/gomake v0.0.17 h1:q8haP48VOH45WhJRiLj1YSBJyUFJqD8CTedH65i1YH8=
github.com/openimsdk/gomake v0.0.17/go.mod h1:nnjS8yCtrPJAt1knMbyPiUwCH2gpyBzj/EZAONfUOXg=
github.com/openimsdk/protocol v0.0.73-alpha.12 h1:2NYawXeHChYUeSme6QJ9pOLh+Empce2WmwEtbP4JvKk=
github.com/openimsdk/protocol v0.0.73-alpha.12/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw=
github.com/openimsdk/tools v0.0.50-alpha.113 h1:rhLWaSJuhjgJFNVzmpChLCG7dPXS0+bte+CPI0008Us=
github.com/openimsdk/tools v0.0.50-alpha.113/go.mod h1:x9i/e+WJFW4tocy6RNJQ9NofQiP3KJ1Y576/06TqOG4=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
@ -361,6 +368,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU=
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk=
@ -397,6 +406,8 @@ github.com/sercand/kuberesolver/v6 v6.0.1 h1:XZUTA0gy/lgDYp/UhEwv7Js24F1j8NJ833Q
github.com/sercand/kuberesolver/v6 v6.0.1/go.mod h1:C0tsTuRMONSY+Xf7pv7RMW1/JlewY1+wS8SZE+1lf1s=
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil/v4 v4.26.2 h1:X8i6sicvUFih4BmYIGT1m2wwgw2VG9YgrDTi7cIRGUI=
github.com/shirou/gopsutil/v4 v4.26.2/go.mod h1:LZ6ewCSkBqUpvSOf+LsTGnRinC6iaNUNMGBtDkJBaLQ=
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
@ -423,18 +434,18 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.563/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.563/go.mod h1:uom4Nvi9W+Qkom0exYiJ9VWJjXwyxtPYTkKkaLMlfE0=
github.com/tencentyun/cos-go-sdk-v5 v0.7.47 h1:uoS4Sob16qEYoapkqJq1D1Vnsy9ira9BfNUMtoFYTI4=
github.com/tencentyun/cos-go-sdk-v5 v0.7.47/go.mod h1:DH9US8nB+AJXqwu/AMOrCFN1COv3dpytXuJWHgdg7kE=
github.com/tklauser/go-sysconf v0.3.13 h1:GBUpcahXSpR2xN01jhkNAbTLRk2Yzgggk8IM08lq3r4=
github.com/tklauser/go-sysconf v0.3.13/go.mod h1:zwleP4Q4OehZHGn4CYZDipCgg9usW5IJePewFCGVEa0=
github.com/tklauser/numcpus v0.7.0 h1:yjuerZP127QG9m5Zh/mSO4wqurYil27tHrqwRoRjpr4=
github.com/tklauser/numcpus v0.7.0/go.mod h1:bb6dMVcj8A42tSE7i32fsIUCbQNllK5iDguyOZRUzAY=
github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA=
github.com/tklauser/go-sysconf v0.3.16/go.mod h1:/qNL9xxDhc7tx3HSRsLWNnuzbVfh3e7gh/BmM179nYI=
github.com/tklauser/numcpus v0.11.0 h1:nSTwhKH5e1dMNsCdVBukSZrURJRoHbSEQjdEbY+9RXw=
github.com/tklauser/numcpus v0.11.0/go.mod h1:z+LwcLq54uWZTX0u/bGobaV34u6V7KNlTZejzM6/3MQ=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
@ -548,6 +559,7 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@ -556,8 +568,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=

View File

@ -233,9 +233,28 @@ func (c *conversationServer) getConversations(ctx context.Context, ownerUserID s
// Deprecated
func (c *conversationServer) SetConversation(ctx context.Context, req *pbconversation.SetConversationReq) (*pbconversation.SetConversationResp, error) {
if req.Conversation == nil {
return nil, errs.ErrArgs.WrapMsg("conversation must not be nil")
}
var conversation dbModel.Conversation
if err := datautil.CopyStructFields(&conversation, req.Conversation); err != nil {
return nil, err
conversation.OwnerUserID = req.Conversation.OwnerUserID
conversation.ConversationID = req.Conversation.ConversationID
conversation.RecvMsgOpt = req.Conversation.RecvMsgOpt
conversation.ConversationType = req.Conversation.ConversationType
conversation.UserID = req.Conversation.UserID
conversation.GroupID = req.Conversation.GroupID
conversation.IsPinned = req.Conversation.IsPinned
conversation.AttachedInfo = req.Conversation.AttachedInfo
conversation.IsPrivateChat = req.Conversation.IsPrivateChat
conversation.GroupAtType = req.Conversation.GroupAtType
conversation.Ex = req.Conversation.Ex
conversation.BurnDuration = req.Conversation.BurnDuration
conversation.MinSeq = req.Conversation.MinSeq
conversation.MaxSeq = req.Conversation.MaxSeq
conversation.MsgDestructTime = req.Conversation.MsgDestructTime
conversation.IsMsgDestruct = req.Conversation.IsMsgDestruct
if req.Conversation.LatestMsgDestructTime != 0 {
conversation.LatestMsgDestructTime = time.UnixMilli(req.Conversation.LatestMsgDestructTime)
}
err := c.conversationDatabase.SetUserConversations(ctx, req.Conversation.OwnerUserID, []*dbModel.Conversation{&conversation})
if err != nil {
@ -606,9 +625,17 @@ func (c *conversationServer) getConversationInfo(
}
for conversationID, chatLog := range chatLogs {
pbchatLog := &pbconversation.ConversationElem{}
msgInfo := &pbconversation.MsgInfo{}
if err := datautil.CopyStructFields(msgInfo, chatLog); err != nil {
return nil, err
msgInfo := &pbconversation.MsgInfo{
ServerMsgID: chatLog.ServerMsgID,
ClientMsgID: chatLog.ClientMsgID,
SessionType: chatLog.SessionType,
SendID: chatLog.SendID,
RecvID: chatLog.RecvID,
GroupID: chatLog.GroupID,
MsgFrom: chatLog.MsgFrom,
ContentType: chatLog.ContentType,
Content: string(chatLog.Content),
Ex: chatLog.Ex,
}
switch chatLog.SessionType {
case constant.SingleChatType:

View File

@ -24,7 +24,6 @@ import (
"github.com/openimsdk/protocol/msg"
"github.com/openimsdk/protocol/sdkws"
"github.com/openimsdk/tools/log"
"github.com/openimsdk/tools/utils/datautil"
"github.com/openimsdk/tools/utils/timeutil"
)
@ -216,9 +215,24 @@ func (m *msgServer) SearchMessage(ctx context.Context, req *msg.SearchMessageReq
// Construct response with updated information
for _, chatLog := range chatLogs {
pbchatLog := &msg.ChatLog{}
datautil.CopyStructFields(pbchatLog, chatLog.MsgData)
pbchatLog.SendTime = chatLog.MsgData.SendTime
pbchatLog.CreateTime = chatLog.MsgData.CreateTime
msgData := chatLog.MsgData
pbchatLog.ServerMsgID = msgData.ServerMsgID
pbchatLog.ClientMsgID = msgData.ClientMsgID
pbchatLog.SendID = msgData.SendID
pbchatLog.RecvID = msgData.RecvID
pbchatLog.GroupID = msgData.GroupID
pbchatLog.SenderPlatformID = msgData.SenderPlatformID
pbchatLog.SenderNickname = msgData.SenderNickname
pbchatLog.SenderFaceURL = msgData.SenderFaceURL
pbchatLog.SessionType = msgData.SessionType
pbchatLog.MsgFrom = msgData.MsgFrom
pbchatLog.ContentType = msgData.ContentType
pbchatLog.Content = string(msgData.Content)
pbchatLog.Status = msgData.Status
pbchatLog.SendTime = msgData.SendTime
pbchatLog.CreateTime = msgData.CreateTime
pbchatLog.Ex = msgData.Ex
pbchatLog.Seq = msgData.Seq
if chatLog.MsgData.SenderNickname == "" {
pbchatLog.SenderNickname = sendMap[chatLog.MsgData.SendID]
}

View File

@ -5,22 +5,58 @@ package main
import (
"flag"
"fmt"
"os"
"github.com/openimsdk/gomake/mageutil"
"github.com/openimsdk/open-im-server/v3/version"
"github.com/openimsdk/tools/utils/datautil"
)
var Default = Build
var Aliases = map[string]any{
"buildcc": BuildWithCustomConfig,
"startcc": StartWithCustomConfig,
}
var (
customRootDir = "." // workDir in mage, default is "./"(project root directory)
customSrcDir = "cmd" // source code directory, default is "cmd"
customOutputDir = "_output" // output directory, default is "_output"
customConfigDir = "config" // configuration directory, default is "config"
customToolsDir = "tools" // tools source code directory, default is "tools"
)
// Build support specifical binary build.
//
// Example: `mage build openim-api openim-rpc-user seq`
func Build() {
flag.Parse()
bin := flag.Args()
if len(bin) != 0 {
bin = bin[1:]
}
mageutil.WithSpinner("Building binaries...", func() { mageutil.Build(bin, nil, nil) })
}
func BuildWithCustomConfig() {
flag.Parse()
bin := flag.Args()
if len(bin) != 0 {
bin = bin[1:]
}
mageutil.Build(bin)
config := &mageutil.PathOptions{
RootDir: &customRootDir,
OutputDir: &customOutputDir,
SrcDir: &customSrcDir,
ToolsDir: &customToolsDir,
}
mageutil.WithSpinner("Building binaries with custom config...", func() {
mageutil.Build(bin, config, nil)
})
}
func Start() {
@ -30,13 +66,74 @@ func Start() {
mageutil.PrintRed("setMaxOpenFiles failed " + err.Error())
os.Exit(1)
}
mageutil.StartToolsAndServices()
flag.Parse()
bin := flag.Args()
if len(bin) != 0 {
bin = bin[1:]
}
mageutil.WithSpinner("Starting...", func() {
mageutil.StartToolsAndServices(bin, nil)
})
}
func StartWithCustomConfig() {
mageutil.InitForSSC()
err := setMaxOpenFiles()
if err != nil {
mageutil.PrintRed("setMaxOpenFiles failed " + err.Error())
os.Exit(1)
}
flag.Parse()
bin := flag.Args()
if len(bin) != 0 {
bin = bin[1:]
}
config := &mageutil.PathOptions{
RootDir: &customRootDir,
OutputDir: &customOutputDir,
ConfigDir: &customConfigDir,
}
mageutil.WithSpinner("Starting with custom config...", func() {
mageutil.StartToolsAndServices(bin, config)
})
}
func Stop() {
mageutil.StopAndCheckBinaries()
mageutil.WithSpinner("Stopping...", mageutil.StopAndCheckBinaries)
}
func Check() {
mageutil.CheckAndReportBinariesStatus()
mageutil.WithSpinner("Checking binaries...", mageutil.CheckAndReportBinariesStatus)
}
func Export() {
mappingPaths, err := mageutil.GetDefaultExportMappingPaths([]string{
"cmd",
"internal",
"pkg",
"test",
"tools",
"**/*.go",
"go.mod",
"go.work",
})
if err != nil {
mageutil.PrintRed("GetDefaultExportMappingPaths failed " + err.Error())
os.Exit(1)
}
mageutil.WithSpinner("Exporting...", func() {
mageutil.ExportMageLauncherArchived(mappingPaths, &mageutil.ExportOptions{
ProjectName: datautil.ToPtr(fmt.Sprintf("open-im-server_%s", version.Version)),
BuildOpt: &mageutil.BuildOptions{
Release: datautil.ToPtr(true),
Compress: datautil.ToPtr(true),
},
})
})
}

View File

@ -15,46 +15,120 @@
package convert
import (
"time"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
"github.com/openimsdk/protocol/conversation"
"github.com/openimsdk/tools/utils/datautil"
)
func ConversationDB2Pb(conversationDB *model.Conversation) *conversation.Conversation {
conversationPB := &conversation.Conversation{}
conversationPB.LatestMsgDestructTime = conversationDB.LatestMsgDestructTime.UnixMilli()
if err := datautil.CopyStructFields(conversationPB, conversationDB); err != nil {
if conversationDB == nil {
return nil
}
return conversationPB
return &conversation.Conversation{
OwnerUserID: conversationDB.OwnerUserID,
ConversationID: conversationDB.ConversationID,
RecvMsgOpt: conversationDB.RecvMsgOpt,
ConversationType: conversationDB.ConversationType,
UserID: conversationDB.UserID,
GroupID: conversationDB.GroupID,
IsPinned: conversationDB.IsPinned,
AttachedInfo: conversationDB.AttachedInfo,
IsPrivateChat: conversationDB.IsPrivateChat,
GroupAtType: conversationDB.GroupAtType,
Ex: conversationDB.Ex,
BurnDuration: conversationDB.BurnDuration,
MinSeq: conversationDB.MinSeq,
MaxSeq: conversationDB.MaxSeq,
MsgDestructTime: conversationDB.MsgDestructTime,
LatestMsgDestructTime: conversationDB.LatestMsgDestructTime.UnixMilli(),
IsMsgDestruct: conversationDB.IsMsgDestruct,
}
}
func ConversationsDB2Pb(conversationsDB []*model.Conversation) (conversationsPB []*conversation.Conversation) {
for _, conversationDB := range conversationsDB {
conversationPB := &conversation.Conversation{}
if err := datautil.CopyStructFields(conversationPB, conversationDB); err != nil {
if conversationDB == nil {
continue
}
conversationPB.LatestMsgDestructTime = conversationDB.LatestMsgDestructTime.UnixMilli()
conversationPB := &conversation.Conversation{
OwnerUserID: conversationDB.OwnerUserID,
ConversationID: conversationDB.ConversationID,
RecvMsgOpt: conversationDB.RecvMsgOpt,
ConversationType: conversationDB.ConversationType,
UserID: conversationDB.UserID,
GroupID: conversationDB.GroupID,
IsPinned: conversationDB.IsPinned,
AttachedInfo: conversationDB.AttachedInfo,
IsPrivateChat: conversationDB.IsPrivateChat,
GroupAtType: conversationDB.GroupAtType,
Ex: conversationDB.Ex,
BurnDuration: conversationDB.BurnDuration,
MinSeq: conversationDB.MinSeq,
MaxSeq: conversationDB.MaxSeq,
MsgDestructTime: conversationDB.MsgDestructTime,
LatestMsgDestructTime: conversationDB.LatestMsgDestructTime.UnixMilli(),
IsMsgDestruct: conversationDB.IsMsgDestruct,
}
conversationsPB = append(conversationsPB, conversationPB)
}
return conversationsPB
}
func ConversationPb2DB(conversationPB *conversation.Conversation) *model.Conversation {
conversationDB := &model.Conversation{}
if err := datautil.CopyStructFields(conversationDB, conversationPB); err != nil {
if conversationPB == nil {
return nil
}
conversationDB := &model.Conversation{
OwnerUserID: conversationPB.OwnerUserID,
ConversationID: conversationPB.ConversationID,
RecvMsgOpt: conversationPB.RecvMsgOpt,
ConversationType: conversationPB.ConversationType,
UserID: conversationPB.UserID,
GroupID: conversationPB.GroupID,
IsPinned: conversationPB.IsPinned,
AttachedInfo: conversationPB.AttachedInfo,
IsPrivateChat: conversationPB.IsPrivateChat,
GroupAtType: conversationPB.GroupAtType,
Ex: conversationPB.Ex,
BurnDuration: conversationPB.BurnDuration,
MinSeq: conversationPB.MinSeq,
MaxSeq: conversationPB.MaxSeq,
MsgDestructTime: conversationPB.MsgDestructTime,
IsMsgDestruct: conversationPB.IsMsgDestruct,
}
if conversationPB.LatestMsgDestructTime != 0 {
conversationDB.LatestMsgDestructTime = time.UnixMilli(conversationPB.LatestMsgDestructTime)
}
return conversationDB
}
func ConversationsPb2DB(conversationsPB []*conversation.Conversation) (conversationsDB []*model.Conversation) {
for _, conversationPB := range conversationsPB {
conversationDB := &model.Conversation{}
if err := datautil.CopyStructFields(conversationDB, conversationPB); err != nil {
if conversationPB == nil {
continue
}
conversationDB := &model.Conversation{
OwnerUserID: conversationPB.OwnerUserID,
ConversationID: conversationPB.ConversationID,
RecvMsgOpt: conversationPB.RecvMsgOpt,
ConversationType: conversationPB.ConversationType,
UserID: conversationPB.UserID,
GroupID: conversationPB.GroupID,
IsPinned: conversationPB.IsPinned,
AttachedInfo: conversationPB.AttachedInfo,
IsPrivateChat: conversationPB.IsPrivateChat,
GroupAtType: conversationPB.GroupAtType,
Ex: conversationPB.Ex,
BurnDuration: conversationPB.BurnDuration,
MinSeq: conversationPB.MinSeq,
MaxSeq: conversationPB.MaxSeq,
MsgDestructTime: conversationPB.MsgDestructTime,
IsMsgDestruct: conversationPB.IsMsgDestruct,
}
if conversationPB.LatestMsgDestructTime != 0 {
conversationDB.LatestMsgDestructTime = time.UnixMilli(conversationPB.LatestMsgDestructTime)
}
conversationsDB = append(conversationsDB, conversationDB)
}
return conversationsDB

View File

@ -21,18 +21,22 @@ import (
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/model"
"github.com/openimsdk/open-im-server/v3/pkg/notification/common_user"
"github.com/openimsdk/protocol/relation"
"github.com/openimsdk/protocol/sdkws"
"github.com/openimsdk/tools/utils/datautil"
"github.com/openimsdk/tools/utils/timeutil"
)
func FriendPb2DB(friend *sdkws.FriendInfo) *model.Friend {
dbFriend := &model.Friend{}
err := datautil.CopyStructFields(dbFriend, friend)
if err != nil {
if friend == nil {
return nil
}
dbFriend := &model.Friend{}
dbFriend.OwnerUserID = friend.OwnerUserID
dbFriend.Remark = friend.Remark
dbFriend.AddSource = friend.AddSource
dbFriend.OperatorUserID = friend.OperatorUserID
dbFriend.Ex = friend.Ex
dbFriend.IsPinned = friend.IsPinned
dbFriend.FriendUserID = friend.FriendUser.UserID
dbFriend.CreateTime = timeutil.UnixSecondToTime(friend.CreateTime)
return dbFriend
@ -69,10 +73,12 @@ func FriendsDB2Pb(ctx context.Context, friendsDB []*model.Friend, getUsers func(
}
for _, friend := range friendsDB {
friendPb := &sdkws.FriendInfo{FriendUser: &sdkws.UserInfo{}}
err := datautil.CopyStructFields(friendPb, friend)
if err != nil {
return nil, err
}
friendPb.OwnerUserID = friend.OwnerUserID
friendPb.Remark = friend.Remark
friendPb.AddSource = friend.AddSource
friendPb.OperatorUserID = friend.OperatorUserID
friendPb.Ex = friend.Ex
friendPb.IsPinned = friend.IsPinned
friendPb.FriendUser.UserID = users[friend.FriendUserID].UserID
friendPb.FriendUser.Nickname = users[friend.FriendUserID].Nickname

View File

@ -127,13 +127,10 @@ func (c *conversationDatabase) SetUsersConversationFieldTx(ctx context.Context,
var conversations []*relationtb.Conversation
now := time.Now()
for _, v := range NotUserIDs {
temp := new(relationtb.Conversation)
if err = datautil.CopyStructFields(temp, conversation); err != nil {
return err
}
temp := *conversation
temp.OwnerUserID = v
temp.CreateTime = now
conversations = append(conversations, temp)
conversations = append(conversations, &temp)
}
if len(conversations) > 0 {
err = c.conversationDB.Create(ctx, conversations)