From 7a3e02b4cc903c2aeebdc70419f85337d08b96bd Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:06:22 +0800 Subject: [PATCH 01/33] log --- scripts/install/openim-msgtransfer.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh index 569cb03d5..41e854909 100755 --- a/scripts/install/openim-msgtransfer.sh +++ b/scripts/install/openim-msgtransfer.sh @@ -65,7 +65,7 @@ function openim::msgtransfer::start() { function openim::msgtransfer::check() { PIDS=$(pgrep -f "${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer") - echo "transsssssssssssssssssssssss" $PIDS + echo "transsssssssssssssssssssssss" [$PIDS] echo "$PIDS" | wc -l echo "tdddddddddddddddddranssssssssssssssssssssssss" $PIDS NUM_PROCESSES=$(echo "$PIDS" | wc -l) From c806549f5959f43fe5008f61bbc187bbce9c917a Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:08:38 +0800 Subject: [PATCH 02/33] log --- scripts/install/openim-msgtransfer.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh index 41e854909..9fdf07fe2 100755 --- a/scripts/install/openim-msgtransfer.sh +++ b/scripts/install/openim-msgtransfer.sh @@ -65,10 +65,11 @@ function openim::msgtransfer::start() { function openim::msgtransfer::check() { PIDS=$(pgrep -f "${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer") - echo "transsssssssssssssssssssssss" [$PIDS] - echo "$PIDS" | wc -l - echo "tdddddddddddddddddranssssssssssssssssssssssss" $PIDS - NUM_PROCESSES=$(echo "$PIDS" | wc -l) + if [ -z "$PIDS" ]; then + NUM_PROCESSES=0 + else + NUM_PROCESSES=$(echo "$PIDS" | wc -l) + fi if [ "$NUM_PROCESSES" -eq "$OPENIM_MSGGATEWAY_NUM" ]; then for PID in $PIDS; do if [[ "$OSTYPE" == "linux-gnu"* ]]; then From c0dddb4d010c34eb4787c1e35fe1667651cc2e03 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:13:47 +0800 Subject: [PATCH 03/33] log --- scripts/lib/util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 6cf5a0343..ac0f8d77c 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -432,7 +432,7 @@ openim::util::check_process_names() { if [[ ${#not_started[@]} -ne 0 ]]; then echo "Not started processes:" for process_name in "${not_started[@]}"; do - openim::log::error "Process $process_name is not started." + #openim::log::error "Process $process_name is not started." done fi From 14a0b8e272851b5b3667761c68da44a9be47a5c6 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:14:35 +0800 Subject: [PATCH 04/33] log --- scripts/check-all.sh | 3 ++- scripts/lib/util.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index ca43876d4..9e353bb93 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -97,7 +97,8 @@ done result=$(openim::util::check_process_names ${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}) if [[ $? -ne 0 ]]; then echo "+++ cat openim log file >>> ${LOG_FILE}" - openim::log::error "check process failed.\n $result" + openim::log::error "check process failed.\n " + echo "$result" else openim::color::echo $COLOR_GREEN "All openim services are running normally! " fi diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index ac0f8d77c..6cf5a0343 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -432,7 +432,7 @@ openim::util::check_process_names() { if [[ ${#not_started[@]} -ne 0 ]]; then echo "Not started processes:" for process_name in "${not_started[@]}"; do - #openim::log::error "Process $process_name is not started." + openim::log::error "Process $process_name is not started." done fi From 5c0062964494c6b8523976b91742adc5d9423776 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:15:13 +0800 Subject: [PATCH 05/33] log --- scripts/lib/util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 6cf5a0343..b9d29fd96 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -432,7 +432,7 @@ openim::util::check_process_names() { if [[ ${#not_started[@]} -ne 0 ]]; then echo "Not started processes:" for process_name in "${not_started[@]}"; do - openim::log::error "Process $process_name is not started." + echo "Process $process_name is not started." done fi From 9bba016a8cba414a2f02e129b554cd7e4369d47e Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:16:11 +0800 Subject: [PATCH 06/33] log --- scripts/lib/util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index b9d29fd96..3f61a2df9 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -477,7 +477,7 @@ openim::util::check_process_names_for_stop() { local not_started=() local started=() - echo "Checking processes: $*" + # Iterate over each given process name for process_name in "$@"; do # Use `pgrep` to find process IDs related to the given process name From c176cf594ba59bf300d3f26a60c5b40c965fa974 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:17:04 +0800 Subject: [PATCH 07/33] log --- scripts/lib/util.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 3f61a2df9..b5442d9cb 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -402,7 +402,6 @@ openim::util::check_process_names() { local not_started=() local started=() - echo "Checking processes: $*" # Iterate over each given process name for process_name in "$@"; do # Use `pgrep` to find process IDs related to the given process name From a84dbac876c34c88b42d549114bb5b7805331aa8 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:21:00 +0800 Subject: [PATCH 08/33] log --- scripts/stop-all.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index ffba4c70e..fd156cc0f 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -33,7 +33,7 @@ echo -e "\n++ Stop all processes in the path ${OPENIM_OUTPUT_HOSTBIN}" openim::util::stop_services_with_name "${OPENIM_OUTPUT_HOSTBIN}" # todo OPENIM_ALL_SERVICE_LIBRARIES -sleep 1 + max_retries=15 @@ -44,9 +44,11 @@ do result=$(openim::util::check_process_names_for_stop) if [[ $? -ne 0 ]]; then - echo "+++ cat openim log file >>> ${LOG_FILE}" - openim::log::error "stop process failed. continue waiting\n" "${result}" - sleep 1 + if [[$attempt -ne 0 ]] ; then + echo "+++ cat openim log file >>> ${LOG_FILE}" + openim::log::error "stop process failed. continue waiting\n" "${result}" + fi + sleep 1 ((attempt++)) else openim::log::success "✨ All processes to be stopped" From 795b003210ffeb16c6348dc4315dcf73435f3c4b Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:22:55 +0800 Subject: [PATCH 09/33] log --- scripts/check-all.sh | 2 +- scripts/start-all.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 9e353bb93..0a8577724 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -100,6 +100,6 @@ if [[ $? -ne 0 ]]; then openim::log::error "check process failed.\n " echo "$result" else - openim::color::echo $COLOR_GREEN "All openim services are running normally! " + openim::log::success "All openim services are running normally! " fi diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 0787e4592..3cc4d982f 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -109,7 +109,7 @@ if [[ $? -ne 0 ]]; then fi -openim::log::info "\n## Post Starting OpenIM services" +openim::log::info "\n## Post Starting openim services" ${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start -openim::color::echo $COLOR_GREEN "✨ All OpenIM services have been successfully started!" \ No newline at end of file +openim::log::success "✨ All openim services have been successfully started!" \ No newline at end of file From 2c48d848db47d7f0b3c2bf92d5f0bc5bcc77f2ef Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:23:51 +0800 Subject: [PATCH 10/33] log --- scripts/stop-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index fd156cc0f..328392d29 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -51,7 +51,7 @@ do sleep 1 ((attempt++)) else - openim::log::success "✨ All processes to be stopped" + openim::log::success "✨ All openim processes to be stopped" exit 0 fi done From 202a1fff733dffa42de9ccce813bece6423dbf08 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:26:57 +0800 Subject: [PATCH 11/33] log --- scripts/start-all.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 3cc4d982f..4ba09d135 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -57,7 +57,7 @@ function execute_start_scripts() { -openim::log::info "\n# Begin to start all openim service scripts" + openim::golang::check_openim_binaries @@ -88,7 +88,7 @@ fi -openim::log::info "\n## Starting OpenIM services" +openim::log::info "\n## Starting openim services" execute_start_scripts sleep 2 From 169b7feafd96a1e5c49894f65fbec9f16e819bbc Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:27:23 +0800 Subject: [PATCH 12/33] log --- scripts/start-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 4ba09d135..22fbf4a79 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -112,4 +112,4 @@ fi openim::log::info "\n## Post Starting openim services" ${TOOLS_START_SCRIPTS_PATH} openim::tools::post-start -openim::log::success "✨ All openim services have been successfully started!" \ No newline at end of file +openim::log::success "All openim services have been successfully started!" \ No newline at end of file From b8c930d1519b7524d3115ad2fc00e33cfae8419f Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:28:51 +0800 Subject: [PATCH 13/33] log --- scripts/start-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 22fbf4a79..f6a4a2ea7 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -88,7 +88,7 @@ fi -openim::log::info "\n## Starting openim services" +openim::log::info "\n## Starting openim script " execute_start_scripts sleep 2 From dd846a4993b9026fb0c34697984ba34352e05661 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:30:03 +0800 Subject: [PATCH 14/33] log --- scripts/start-all.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/start-all.sh b/scripts/start-all.sh index f6a4a2ea7..67735ac1a 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -37,7 +37,7 @@ function execute_start_scripts() { # Check if the script file exists and is executable. if [[ -x "$script_path" ]]; then - openim::log::status "Starting script: ${script_path##*/}" # Log the script name. + openim::log::info "Starting script: ${script_path##*/}" # Log the script name. # Execute the script with the constructed argument. result=$("$script_path" "$arg") @@ -75,7 +75,7 @@ echo "You need to start the following scripts in order: ${OPENIM_SERVER_SCRIPTAR # TODO Prelaunch tools, simple for now, can abstract functions later TOOLS_START_SCRIPTS_PATH=${START_SCRIPTS_PATH}/openim-tools.sh -openim::log::info "\n## Pre Starting OpenIM services" +openim::log::status "\n## Pre Starting OpenIM services" ${TOOLS_START_SCRIPTS_PATH} openim::tools::pre-start From 001308cebf656cef59ee4b343dc553c0e7448ea5 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:31:10 +0800 Subject: [PATCH 15/33] log --- scripts/stop-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index 328392d29..1792efc6d 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -44,7 +44,7 @@ do result=$(openim::util::check_process_names_for_stop) if [[ $? -ne 0 ]]; then - if [[$attempt -ne 0 ]] ; then + if [[ $attempt -ne 0 ]] ; then echo "+++ cat openim log file >>> ${LOG_FILE}" openim::log::error "stop process failed. continue waiting\n" "${result}" fi From ea4afc6e122ca014bb2689c00512fea398aeec3c Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:32:08 +0800 Subject: [PATCH 16/33] log --- scripts/stop-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index 1792efc6d..451f77f6c 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -45,7 +45,7 @@ do if [[ $? -ne 0 ]]; then if [[ $attempt -ne 0 ]] ; then - echo "+++ cat openim log file >>> ${LOG_FILE}" + echo "+++ cat openim log file >>> ${LOG_FILE} " $attempt openim::log::error "stop process failed. continue waiting\n" "${result}" fi sleep 1 From de2eea713106bac87ee20829b40d56306b92a932 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:34:47 +0800 Subject: [PATCH 17/33] log --- scripts/lib/util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index b5442d9cb..69182bd7d 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2888,7 +2888,7 @@ function openim::util::check_process_names_for_stop() { openim::log::error "Unsupported OS type: $OSTYPE" fi done - openim::log::error "Processes for ${service} have not been stopped properly." + openim::log::error "Processes for ${service} have not been stopped properly. " "$NUM_PROCESSES" fi done From 9a2c74baaad4399639f0b528067ae2e64b6aea5a Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:37:03 +0800 Subject: [PATCH 18/33] log --- scripts/lib/util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 69182bd7d..2cd3cc432 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2888,7 +2888,7 @@ function openim::util::check_process_names_for_stop() { openim::log::error "Unsupported OS type: $OSTYPE" fi done - openim::log::error "Processes for ${service} have not been stopped properly. " "$NUM_PROCESSES" + echo "Processes for ${service} have not been stopped properly. " "$NUM_PROCESSES" fi done From df87f9405e8a5ecad658bb15315d40905b6f1835 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:38:09 +0800 Subject: [PATCH 19/33] log --- scripts/lib/util.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 2cd3cc432..023edc344 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -2878,7 +2878,7 @@ function openim::util::check_process_names_for_stop() { NUM_PROCESSES=$(echo "$PIDS" | wc -l | xargs) if [ "$NUM_PROCESSES" -gt 0 ]; then all_stopped=false - openim::log::error "Found $NUM_PROCESSES processes for ${service}" + echo "Found $NUM_PROCESSES processes for ${service}" for PID in $PIDS; do if [[ "$OSTYPE" == "linux-gnu"* ]]; then echo -e "\033[31m$(ps -p $PID -o pid,cmd)\033[0m" From 4c07027cf2df656989b2b13d98bbcf83390b5044 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:39:19 +0800 Subject: [PATCH 20/33] log --- scripts/start-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/start-all.sh b/scripts/start-all.sh index 67735ac1a..9a98bfca3 100755 --- a/scripts/start-all.sh +++ b/scripts/start-all.sh @@ -88,7 +88,7 @@ fi -openim::log::info "\n## Starting openim script " +openim::log::status "\n## Starting openim scripts: " execute_start_scripts sleep 2 From 96d493e732cce6eb35fe0dcb4669ae5490f47e63 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:41:34 +0800 Subject: [PATCH 21/33] log --- scripts/lib/logging.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh index 18fe1c9a4..a6ec5ff22 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -213,15 +213,20 @@ openim::log::status() { done } + openim::log::success() { local V="${V:-0}" if [[ ${OPENIM_VERBOSE} < ${V} ]]; then return fi - timestamp=$(date +"%m%d %H:%M:%S") - echo_log -e "${COLOR_GREEN}[success ${timestamp}] ${COLOR_SUFFIX}==> " "$@" + local timestamp=$(date +"%m%d %H:%M:%S") + local reset_color='\033[0m' + echo_log -e "${COLOR_GREEN}[success ${timestamp}]${COLOR_SUFFIX}==> ${COLOR_GREEN}$@${reset_color}" } + + + function openim::log::test_log() { echo_log "test log" openim::log::info "openim::log::info" From 7a1d4612b72c19d2aeaa1793556408d3d3619cc8 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:43:14 +0800 Subject: [PATCH 22/33] log --- scripts/stop-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index 451f77f6c..e7f0f47e0 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -26,7 +26,7 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/install/common.sh" -openim::log::info "\n# Begin to stop all openim service" +openim::log::stat "\n# Begin to stop all openim service" echo -e "\n++ Stop all processes in the path ${OPENIM_OUTPUT_HOSTBIN}" From 3b0a4bab2e324fc2850a44cd7f6f3188de61d5ff Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:43:51 +0800 Subject: [PATCH 23/33] log --- scripts/stop-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index e7f0f47e0..28b3b04bb 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -26,7 +26,7 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/install/common.sh" -openim::log::stat "\n# Begin to stop all openim service" +openim::log::status "\n# Begin to stop all openim service" echo -e "\n++ Stop all processes in the path ${OPENIM_OUTPUT_HOSTBIN}" From e09475dd3171e54a39946d6f51dc9a1da6ea9e40 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:45:12 +0800 Subject: [PATCH 24/33] log --- scripts/stop-all.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index 28b3b04bb..9b37696ac 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -28,7 +28,7 @@ source "${OPENIM_ROOT}/scripts/install/common.sh" openim::log::status "\n# Begin to stop all openim service" -echo -e "\n++ Stop all processes in the path ${OPENIM_OUTPUT_HOSTBIN}" +openim::log::status "\n++ Stop all processes in the path ${OPENIM_OUTPUT_HOSTBIN}" openim::util::stop_services_with_name "${OPENIM_OUTPUT_HOSTBIN}" # todo OPENIM_ALL_SERVICE_LIBRARIES @@ -51,10 +51,10 @@ do sleep 1 ((attempt++)) else - openim::log::success "✨ All openim processes to be stopped" + openim::log::success " All openim processes to be stopped" exit 0 fi done -openim::log::error "✨ openim processes stopped failed" +openim::log::error "openim processes stopped failed" exit 1 From 488c3a7c4775ecdf5150b7b2cc191b574216027c Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:46:00 +0800 Subject: [PATCH 25/33] log --- scripts/stop-all.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/stop-all.sh b/scripts/stop-all.sh index 9b37696ac..b2572f7d5 100755 --- a/scripts/stop-all.sh +++ b/scripts/stop-all.sh @@ -26,9 +26,9 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${OPENIM_ROOT}/scripts/install/common.sh" -openim::log::status "\n# Begin to stop all openim service" +openim::log::status "Begin to stop all openim service" -openim::log::status "\n++ Stop all processes in the path ${OPENIM_OUTPUT_HOSTBIN}" +openim::log::status "Stop all processes in the path ${OPENIM_OUTPUT_HOSTBIN}" openim::util::stop_services_with_name "${OPENIM_OUTPUT_HOSTBIN}" # todo OPENIM_ALL_SERVICE_LIBRARIES From d9e7523a2fa871fa6d2ae734e28944bc018e25cd Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:47:19 +0800 Subject: [PATCH 26/33] log --- scripts/lib/logging.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/logging.sh b/scripts/lib/logging.sh index a6ec5ff22..7afb6bfce 100755 --- a/scripts/lib/logging.sh +++ b/scripts/lib/logging.sh @@ -206,7 +206,7 @@ openim::log::status() { fi timestamp=$(date +"[%Y-%m-%d %H:%M:%S %Z]") - echo_log "+++ ${timestamp} ${1}" + echo_log "${timestamp} ${1}" shift for message; do echo_log " ${message}" From 6b927060f23b4c20bc009b912f6f3dc5192a64a3 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:49:59 +0800 Subject: [PATCH 27/33] log --- scripts/lib/util.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index 023edc344..8da669282 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -360,8 +360,8 @@ openim::util::check_ports() { # If any of the processes is not running, return a status of 1. if [[ ${#not_started[@]} -ne 0 ]]; then - openim::color::echo $COLOR_RED " OpenIM Stdout Log >> cat ${LOG_FILE}" - openim::color::echo $COLOR_RED " OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}" + openim::color::echo $COLOR_RED "OpenIM Stdout Log >> cat ${LOG_FILE}" + openim::color::echo $COLOR_RED "OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}" cat "$TMP_LOG_FILE" | awk '{print "\033[31m" $0 "\033[0m"}' return 1 else @@ -445,8 +445,8 @@ openim::util::check_process_names() { # Return status if [[ ${#not_started[@]} -ne 0 ]]; then - openim::color::echo $COLOR_RED " OpenIM Stdout Log >> cat ${LOG_FILE}" - openim::color::echo $COLOR_RED " OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}" + openim::color::echo $COLOR_RED "OpenIM Stdout Log >> cat ${LOG_FILE}" + openim::color::echo $COLOR_RED "OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}" cat "$TMP_LOG_FILE" | awk '{print "\033[31m" $0 "\033[0m"}' return 1 else @@ -1634,8 +1634,8 @@ openim::util::check_ports() { # If any of the processes is not running, return a status of 1. if [[ ${#not_started[@]} -ne 0 ]]; then - openim::color::echo $COLOR_RED " OpenIM Stdout Log >> cat ${LOG_FILE}" - openim::color::echo $COLOR_RED " OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}" + openim::color::echo $COLOR_RED "OpenIM Stdout Log >> cat ${LOG_FILE}" + openim::color::echo $COLOR_RED "OpenIM Stderr Log >> cat ${STDERR_LOG_FILE}" echo "" cat "$TMP_LOG_FILE" | awk '{print "\033[31m" $0 "\033[0m"}' return 1 From 83fb847d3db961018dddedb7896c472349ba0b05 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:51:29 +0800 Subject: [PATCH 28/33] log --- scripts/check-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 0a8577724..759db029a 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -81,7 +81,7 @@ else fi -openim::log::info "\n## Check OpenIM service name: \n ${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer" +openim::log::info "\n## Check OpenIM service name:\n${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer" result=$(. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check) if [[ $? -ne 0 ]]; then echo "+++ cat openim log file >>> ${LOG_FILE}" From 51ca0512b465a7b0526ca2e36e0e7b325b76180e Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:51:59 +0800 Subject: [PATCH 29/33] log --- scripts/check-all.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 759db029a..1a92f3f69 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -81,7 +81,7 @@ else fi -openim::log::info "\n## Check OpenIM service name:\n${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer" +openim::log::info "\n## Check openim service name:\n${OPENIM_OUTPUT_HOSTBIN}/openim-msgtransfer" result=$(. $(dirname ${BASH_SOURCE})/install/openim-msgtransfer.sh openim::msgtransfer::check) if [[ $? -ne 0 ]]; then echo "+++ cat openim log file >>> ${LOG_FILE}" @@ -89,7 +89,7 @@ if [[ $? -ne 0 ]]; then fi -echo "Check OpenIM service name:" +echo "Check openim service name:" for item in "${OPENIM_ALL_SERVICE_LIBRARIES_NO_TRANSFER[@]}"; do echo "$item" done From 716c5c668bdd7191af4a36839e9aee006e30f294 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Thu, 22 Feb 2024 22:55:00 +0800 Subject: [PATCH 30/33] log --- scripts/check-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 1a92f3f69..a9b07d65b 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -77,7 +77,7 @@ if [[ $? -ne 0 ]]; then openim::log::error_exit "The service does not start properly, please check the port, query variable definition!" echo "+++ https://github.com/openimsdk/open-im-server/tree/main/scripts/install/environment.sh +++" else - openim::color::echo $COLOR_GREEN "All components depended on by openim are running normally! " + openim::log::success "All components depended on by openim are running normally! " fi From b13f2614b880d6d0e73253514be882035cdfb3f5 Mon Sep 17 00:00:00 2001 From: xuan <146319162+wxuanF@users.noreply.github.com> Date: Sun, 25 Feb 2024 22:23:29 +0800 Subject: [PATCH 31/33] makelint internal/ (#1951) Signed-off-by: xuan <146319162+wxuanF@users.noreply.github.com> --- internal/msggateway/client.go | 21 ++-- internal/msggateway/long_conn.go | 10 +- internal/msggateway/n_ws_server.go | 11 +- internal/msggateway/user_map.go | 4 +- internal/msgtransfer/init.go | 2 +- .../msgtransfer/online_history_msg_handler.go | 107 +++++++++--------- 6 files changed, 78 insertions(+), 77 deletions(-) diff --git a/internal/msggateway/client.go b/internal/msggateway/client.go index d3b0e6a5f..9a4005e6c 100644 --- a/internal/msggateway/client.go +++ b/internal/msggateway/client.go @@ -78,16 +78,17 @@ type Client struct { token string } -func newClient(ctx *UserConnContext, conn LongConn, isCompress bool) *Client { - return &Client{ - w: new(sync.Mutex), - conn: conn, - PlatformID: utils.StringToInt(ctx.GetPlatformID()), - IsCompress: isCompress, - UserID: ctx.GetUserID(), - ctx: ctx, - } -} +// function not used +// func newClient(ctx *UserConnContext, conn LongConn, isCompress bool) *Client { +// return &Client{ +// w: new(sync.Mutex), +// conn: conn, +// PlatformID: utils.StringToInt(ctx.GetPlatformID()), +// IsCompress: isCompress, +// UserID: ctx.GetUserID(), +// ctx: ctx, +// } +// } // ResetClient updates the client's state with new connection and context information. func (c *Client) ResetClient( diff --git a/internal/msggateway/long_conn.go b/internal/msggateway/long_conn.go index 93e5cc33f..a4251a50f 100644 --- a/internal/msggateway/long_conn.go +++ b/internal/msggateway/long_conn.go @@ -108,10 +108,12 @@ func (d *GWebSocket) Dial(urlStr string, requestHeader http.Header) (*http.Respo } func (d *GWebSocket) IsNil() bool { - if d.conn != nil { - return false - } - return true + return d.conn == nil + // + // if d.conn != nil { + // return false + // } + // return true } func (d *GWebSocket) SetConnNil() { diff --git a/internal/msggateway/n_ws_server.go b/internal/msggateway/n_ws_server.go index c16da7c64..b734dee6d 100644 --- a/internal/msggateway/n_ws_server.go +++ b/internal/msggateway/n_ws_server.go @@ -61,11 +61,12 @@ type LongConnServer interface { MessageHandler } -var bufferPool = sync.Pool{ - New: func() any { - return make([]byte, 1024) - }, -} +// bufferPool is unused +// var bufferPool = sync.Pool{ +// New: func() any { +// return make([]byte, 1024) +// }, +// } type WsServer struct { port int diff --git a/internal/msggateway/user_map.go b/internal/msggateway/user_map.go index 052d7de2d..b4cec59fa 100644 --- a/internal/msggateway/user_map.go +++ b/internal/msggateway/user_map.go @@ -58,12 +58,12 @@ func (u *UserMap) Get(key string, platformID int) ([]*Client, bool, bool) { func (u *UserMap) Set(key string, v *Client) { allClients, existed := u.m.Load(key) if existed { - log.ZDebug(context.Background(), "Set existed", "user_id", key, "client", *v) + log.ZDebug(context.Background(), "Set existed", "user_id", key, "client_user_id", v.UserID) oldClients := allClients.([]*Client) oldClients = append(oldClients, v) u.m.Store(key, oldClients) } else { - log.ZDebug(context.Background(), "Set not existed", "user_id", key, "client", *v) + log.ZDebug(context.Background(), "Set not existed", "user_id", key, "client_user_id", v.UserID) var clients []*Client clients = append(clients, v) u.m.Store(key, clients) diff --git a/internal/msgtransfer/init.go b/internal/msgtransfer/init.go index 16d8613db..8ef3efd83 100644 --- a/internal/msgtransfer/init.go +++ b/internal/msgtransfer/init.go @@ -71,7 +71,7 @@ func StartTransfer(prometheusPort int) error { return err } - if err := client.CreateRpcRootNodes(config.Config.GetServiceNames()); err != nil { + if err2 := client.CreateRpcRootNodes(config.Config.GetServiceNames()); err2 != nil { return err } client.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy": "%s"}`, "round_robin"))) diff --git a/internal/msgtransfer/online_history_msg_handler.go b/internal/msgtransfer/online_history_msg_handler.go index 6678715d4..6f0ee7706 100644 --- a/internal/msgtransfer/online_history_msg_handler.go +++ b/internal/msgtransfer/online_history_msg_handler.go @@ -74,10 +74,10 @@ type OnlineHistoryRedisConsumerHandler struct { chArrays [ChannelNum]chan Cmd2Value msgDistributionCh chan Cmd2Value - singleMsgSuccessCount uint64 - singleMsgFailedCount uint64 - singleMsgSuccessCountMutex sync.Mutex - singleMsgFailedCountMutex sync.Mutex + // singleMsgSuccessCount uint64 + // singleMsgFailedCount uint64 + // singleMsgSuccessCountMutex sync.Mutex + // singleMsgFailedCountMutex sync.Mutex msgDatabase controller.CommonMsgDatabase conversationRpcClient *rpcclient.ConversationRpcClient @@ -111,62 +111,59 @@ func NewOnlineHistoryRedisConsumerHandler( } func (och *OnlineHistoryRedisConsumerHandler) Run(channelID int) { - for { - select { - case cmd := <-och.chArrays[channelID]: - switch cmd.Cmd { - case SourceMessages: - msgChannelValue := cmd.Value.(MsgChannelValue) - ctxMsgList := msgChannelValue.ctxMsgList - ctx := msgChannelValue.ctx - log.ZDebug( + for cmd := range och.chArrays[channelID] { + switch cmd.Cmd { + case SourceMessages: + msgChannelValue := cmd.Value.(MsgChannelValue) + ctxMsgList := msgChannelValue.ctxMsgList + ctx := msgChannelValue.ctx + log.ZDebug( + ctx, + "msg arrived channel", + "channel id", + channelID, + "msgList length", + len(ctxMsgList), + "uniqueKey", + msgChannelValue.uniqueKey, + ) + storageMsgList, notStorageMsgList, storageNotificationList, notStorageNotificationList, modifyMsgList := och.getPushStorageMsgList( + ctxMsgList, + ) + log.ZDebug( + ctx, + "msg lens", + "storageMsgList", + len(storageMsgList), + "notStorageMsgList", + len(notStorageMsgList), + "storageNotificationList", + len(storageNotificationList), + "notStorageNotificationList", + len(notStorageNotificationList), + "modifyMsgList", + len(modifyMsgList), + ) + conversationIDMsg := msgprocessor.GetChatConversationIDByMsg(ctxMsgList[0].message) + conversationIDNotification := msgprocessor.GetNotificationConversationIDByMsg(ctxMsgList[0].message) + och.handleMsg(ctx, msgChannelValue.uniqueKey, conversationIDMsg, storageMsgList, notStorageMsgList) + och.handleNotification( + ctx, + msgChannelValue.uniqueKey, + conversationIDNotification, + storageNotificationList, + notStorageNotificationList, + ) + if err := och.msgDatabase.MsgToModifyMQ(ctx, msgChannelValue.uniqueKey, conversationIDNotification, modifyMsgList); err != nil { + log.ZError( ctx, - "msg arrived channel", - "channel id", - channelID, - "msgList length", - len(ctxMsgList), + "msg to modify mq error", + err, "uniqueKey", msgChannelValue.uniqueKey, - ) - storageMsgList, notStorageMsgList, storageNotificationList, notStorageNotificationList, modifyMsgList := och.getPushStorageMsgList( - ctxMsgList, - ) - log.ZDebug( - ctx, - "msg lens", - "storageMsgList", - len(storageMsgList), - "notStorageMsgList", - len(notStorageMsgList), - "storageNotificationList", - len(storageNotificationList), - "notStorageNotificationList", - len(notStorageNotificationList), "modifyMsgList", - len(modifyMsgList), + modifyMsgList, ) - conversationIDMsg := msgprocessor.GetChatConversationIDByMsg(ctxMsgList[0].message) - conversationIDNotification := msgprocessor.GetNotificationConversationIDByMsg(ctxMsgList[0].message) - och.handleMsg(ctx, msgChannelValue.uniqueKey, conversationIDMsg, storageMsgList, notStorageMsgList) - och.handleNotification( - ctx, - msgChannelValue.uniqueKey, - conversationIDNotification, - storageNotificationList, - notStorageNotificationList, - ) - if err := och.msgDatabase.MsgToModifyMQ(ctx, msgChannelValue.uniqueKey, conversationIDNotification, modifyMsgList); err != nil { - log.ZError( - ctx, - "msg to modify mq error", - err, - "uniqueKey", - msgChannelValue.uniqueKey, - "modifyMsgList", - modifyMsgList, - ) - } } } } From ae6d21e4ea523a386aa081131accf22a3ee2df90 Mon Sep 17 00:00:00 2001 From: xuan <146319162+wxuanF@users.noreply.github.com> Date: Sun, 25 Feb 2024 23:01:22 +0800 Subject: [PATCH 32/33] docs:update README Community (#1943) Signed-off-by: wxuanF <2569456943@qq.com> --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 90848124f..e83afe5aa 100644 --- a/README.md +++ b/README.md @@ -53,12 +53,12 @@ ## :busts_in_silhouette: Community -+ 📚 [OpenIM Community](https://github.com/OpenIMSDK/community) -+ 💕 [OpenIM Interest Group](https://github.com/Openim-sigs) ++ 💬 [Follow our Twitter account](https://twitter.com/founder_im63606) ++ 👫 [Join our Reddit](https://www.reddit.com/r/OpenIMessaging) + 🚀 [Join our Slack community](https://join.slack.com/t/openimsdk/shared_invite/zt-22720d66b-o_FvKxMTGXtcnnnHiMqe9Q) + :eyes: [Join our wechat (微信群)](https://openim-1253691595.cos.ap-nanjing.myqcloud.com/WechatIMG20.jpeg) -+ 👫 [Join our Reddit](https://www.reddit.com/r/OpenIMessaging) -+ 💬 [Follow our Twitter account](https://twitter.com/founder_im63606) ++ 📚 [OpenIM Community](https://github.com/OpenIMSDK/community) ++ 💕 [OpenIM Interest Group](https://github.com/Openim-sigs) ## Ⓜ️ About OpenIM From c8eed847113dc3badae45e77656b5641f246762f Mon Sep 17 00:00:00 2001 From: longyuqing112 <105913803+longyuqing112@users.noreply.github.com> Date: Mon, 26 Feb 2024 10:55:36 +0800 Subject: [PATCH 33/33] Fix lint errors in modified code (#1952) * pkg:makelint-#779 Signed-off-by: longyuqing112 <105913803+longyuqing112@users.noreply.github.com> * Update msg_utils.go * Update msg_utils.go * Update msg_utils.go * Update msg_utils.go * Update msg_utils.go * Update msg_utils.go * Update minio.go --------- Signed-off-by: longyuqing112 <105913803+longyuqing112@users.noreply.github.com> Co-authored-by: Xinwei Xiong <3293172751NSS@gmail.com> --- pkg/common/cmd/msg_utils.go | 18 ++++----- pkg/common/convert/friend.go | 12 +++++- pkg/common/db/cache/conversation.go | 49 ++++++++++++------------ pkg/common/db/controller/auth.go | 1 + pkg/common/db/controller/conversation.go | 2 +- pkg/common/db/controller/msg.go | 2 +- pkg/common/db/s3/cont/controller.go | 2 +- pkg/common/db/s3/cos/cos.go | 4 +- pkg/common/db/s3/minio/minio.go | 2 +- 9 files changed, 50 insertions(+), 42 deletions(-) diff --git a/pkg/common/cmd/msg_utils.go b/pkg/common/cmd/msg_utils.go index cfaf631ec..8c5ffb16c 100644 --- a/pkg/common/cmd/msg_utils.go +++ b/pkg/common/cmd/msg_utils.go @@ -22,7 +22,6 @@ import ( type MsgUtilsCmd struct { cobra.Command - msgTool *tools.MsgTool } func (m *MsgUtilsCmd) AddUserIDFlag() { @@ -38,19 +37,19 @@ func (m *MsgUtilsCmd) AddFixAllFlag() { m.Command.PersistentFlags().BoolP("fixAll", "f", false, "openIM fix all seqs") } -func (m *MsgUtilsCmd) getFixAllFlag(cmdLines *cobra.Command) bool { +/* func (m *MsgUtilsCmd) getFixAllFlag(cmdLines *cobra.Command) bool { fixAll, _ := cmdLines.Flags().GetBool("fixAll") return fixAll -} +} */ func (m *MsgUtilsCmd) AddClearAllFlag() { m.Command.PersistentFlags().BoolP("clearAll", "c", false, "openIM clear all seqs") } -func (m *MsgUtilsCmd) getClearAllFlag(cmdLines *cobra.Command) bool { +/* func (m *MsgUtilsCmd) getClearAllFlag(cmdLines *cobra.Command) bool { clearAll, _ := cmdLines.Flags().GetBool("clearAll") return clearAll -} +} */ func (m *MsgUtilsCmd) AddSuperGroupIDFlag() { m.Command.PersistentFlags().StringP("superGroupID", "g", "", "openIM superGroupID") @@ -65,19 +64,19 @@ func (m *MsgUtilsCmd) AddBeginSeqFlag() { m.Command.PersistentFlags().Int64P("beginSeq", "b", 0, "openIM beginSeq") } -func (m *MsgUtilsCmd) getBeginSeqFlag(cmdLines *cobra.Command) int64 { +/* func (m *MsgUtilsCmd) getBeginSeqFlag(cmdLines *cobra.Command) int64 { beginSeq, _ := cmdLines.Flags().GetInt64("beginSeq") return beginSeq -} +} */ func (m *MsgUtilsCmd) AddLimitFlag() { m.Command.PersistentFlags().Int64P("limit", "l", 0, "openIM limit") } -func (m *MsgUtilsCmd) getLimitFlag(cmdLines *cobra.Command) int64 { +/* func (m *MsgUtilsCmd) getLimitFlag(cmdLines *cobra.Command) int64 { limit, _ := cmdLines.Flags().GetInt64("limit") return limit -} +} */ func (m *MsgUtilsCmd) Execute() error { return m.Command.Execute() @@ -134,6 +133,7 @@ func NewSeqCmd() *SeqCmd { return seqCmd } + func (s *SeqCmd) GetSeqCmd() *cobra.Command { s.Command.Run = func(cmdLines *cobra.Command, args []string) { _, err := tools.InitMsgTool() diff --git a/pkg/common/convert/friend.go b/pkg/common/convert/friend.go index 27bd595ad..f3a19e459 100644 --- a/pkg/common/convert/friend.go +++ b/pkg/common/convert/friend.go @@ -26,7 +26,10 @@ import ( func FriendPb2DB(friend *sdkws.FriendInfo) *relation.FriendModel { dbFriend := &relation.FriendModel{} - utils.CopyStructFields(dbFriend, friend) + err := utils.CopyStructFields(dbFriend, friend) + if err != nil { + return nil + } dbFriend.FriendUserID = friend.FriendUser.UserID dbFriend.CreateTime = utils.UnixSecondToTime(friend.CreateTime) return dbFriend @@ -69,7 +72,11 @@ func FriendsDB2Pb( } for _, friend := range friendsDB { friendPb := &sdkws.FriendInfo{FriendUser: &sdkws.UserInfo{}} - utils.CopyStructFields(friendPb, friend) + err := utils.CopyStructFields(friendPb, friend) + if err != nil { + return nil, err + } + friendPb.FriendUser.UserID = users[friend.FriendUserID].UserID friendPb.FriendUser.Nickname = users[friend.FriendUserID].Nickname friendPb.FriendUser.FaceURL = users[friend.FriendUserID].FaceURL @@ -79,6 +86,7 @@ func FriendsDB2Pb( friendsPb = append(friendsPb, friendPb) } return friendsPb, nil + } func FriendRequestDB2Pb( diff --git a/pkg/common/db/cache/conversation.go b/pkg/common/db/cache/conversation.go index a7018bc18..047188947 100644 --- a/pkg/common/db/cache/conversation.go +++ b/pkg/common/db/cache/conversation.go @@ -16,7 +16,6 @@ package cache import ( "context" - "errors" "math/big" "strings" "time" @@ -220,16 +219,16 @@ func (c *ConversationRedisCache) DelConversations(ownerUserID string, conversati return cache } -func (c *ConversationRedisCache) getConversationIndex(convsation *relationtb.ConversationModel, keys []string) (int, error) { - key := c.getConversationKey(convsation.OwnerUserID, convsation.ConversationID) - for _i, _key := range keys { - if _key == key { - return _i, nil - } - } +// func (c *ConversationRedisCache) getConversationIndex(convsation *relationtb.ConversationModel, keys []string) (int, error) { +// key := c.getConversationKey(convsation.OwnerUserID, convsation.ConversationID) +// for _i, _key := range keys { +// if _key == key { +// return _i, nil +// } +// } - return 0, errors.New("not found key:" + key + " in keys") -} +// return 0, errors.New("not found key:" + key + " in keys") +// } func (c *ConversationRedisCache) GetConversations(ctx context.Context, ownerUserID string, conversationIDs []string) ([]*relationtb.ConversationModel, error) { //var keys []string @@ -333,7 +332,7 @@ func (c *ConversationRedisCache) DelSuperGroupRecvMsgNotNotifyUserIDsHash(groupI return cache } -func (c *ConversationRedisCache) getUserAllHasReadSeqsIndex(conversationID string, conversationIDs []string) (int, error) { +/* func (c *ConversationRedisCache) getUserAllHasReadSeqsIndex(conversationID string, conversationIDs []string) (int, error) { for _i, _conversationID := range conversationIDs { if _conversationID == conversationID { return _i, nil @@ -341,21 +340,21 @@ func (c *ConversationRedisCache) getUserAllHasReadSeqsIndex(conversationID strin } return 0, errors.New("not found key:" + conversationID + " in keys") -} +} */ -//func (c *ConversationRedisCache) GetUserAllHasReadSeqs(ctx context.Context, ownerUserID string) (map[string]int64, error) { -// conversationIDs, err := c.GetUserConversationIDs(ctx, ownerUserID) -// if err != nil { -// return nil, err -// } -// var keys []string -// for _, conversarionID := range conversationIDs { -// keys = append(keys, c.getConversationHasReadSeqKey(ownerUserID, conversarionID)) -// } -// return batchGetCacheMap(ctx, c.rcClient, keys, conversationIDs, c.expireTime, c.getUserAllHasReadSeqsIndex, func(ctx context.Context) (map[string]int64, error) { -// return c.conversationDB.GetUserAllHasReadSeqs(ctx, ownerUserID) -// }) -//} +/* func (c *ConversationRedisCache) GetUserAllHasReadSeqs(ctx context.Context, ownerUserID string) (map[string]int64, error) { + conversationIDs, err := c.GetUserConversationIDs(ctx, ownerUserID) + if err != nil { + return nil, err + } + var keys []string + for _, conversarionID := range conversationIDs { + keys = append(keys, c.getConversationHasReadSeqKey(ownerUserID, conversarionID)) + } + return batchGetCacheMap(ctx, c.rcClient, keys, conversationIDs, c.expireTime, c.getUserAllHasReadSeqsIndex, func(ctx context.Context) (map[string]int64, error) { + return c.conversationDB.GetUserAllHasReadSeqs(ctx, ownerUserID) + }) +} */ func (c *ConversationRedisCache) DelUserAllHasReadSeqs(ownerUserID string, conversationIDs ...string) ConversationCache { cache := c.NewCache() diff --git a/pkg/common/db/controller/auth.go b/pkg/common/db/controller/auth.go index 163a25c1c..d3d5f7da9 100644 --- a/pkg/common/db/controller/auth.go +++ b/pkg/common/db/controller/auth.go @@ -75,6 +75,7 @@ func (a *authDatabase) CreateToken(ctx context.Context, userID string, platformI return "", err } } + claims := tokenverify.BuildClaims(userID, platformID, a.accessExpire) token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) tokenString, err := token.SignedString([]byte(a.accessSecret)) diff --git a/pkg/common/db/controller/conversation.go b/pkg/common/db/controller/conversation.go index c6629e9c8..c53d4ab87 100644 --- a/pkg/common/db/controller/conversation.go +++ b/pkg/common/db/controller/conversation.go @@ -105,7 +105,7 @@ func (c *conversationDatabase) SetUsersConversationFiledTx(ctx context.Context, now := time.Now() for _, v := range NotUserIDs { temp := new(relationtb.ConversationModel) - if err := utils.CopyStructFields(temp, conversation); err != nil { + if err = utils.CopyStructFields(temp, conversation); err != nil { return err } temp.OwnerUserID = v diff --git a/pkg/common/db/controller/msg.go b/pkg/common/db/controller/msg.go index d427cc3a1..7eac624a7 100644 --- a/pkg/common/db/controller/msg.go +++ b/pkg/common/db/controller/msg.go @@ -846,7 +846,7 @@ func (db *commonMsgDatabase) deleteMsgRecursion(ctx context.Context, conversatio } } if len(delMsgIndexs) > 0 { - if err := db.msgDocDatabase.DeleteMsgsInOneDocByIndex(ctx, msgDocModel.DocID, delMsgIndexs); err != nil { + if err = db.msgDocDatabase.DeleteMsgsInOneDocByIndex(ctx, msgDocModel.DocID, delMsgIndexs); err != nil { log.ZError(ctx, "deleteMsgRecursion DeleteMsgsInOneDocByIndex failed", err, "conversationID", conversationID, "index", index) } delStruct.minSeq = int64(msgDocModel.Msg[delMsgIndexs[len(delMsgIndexs)-1]].Msg.Seq) diff --git a/pkg/common/db/s3/cont/controller.go b/pkg/common/db/s3/cont/controller.go index 82c27c1f2..2a66aeaf6 100644 --- a/pkg/common/db/s3/cont/controller.go +++ b/pkg/common/db/s3/cont/controller.go @@ -106,7 +106,7 @@ func (c *Controller) InitiateUpload(ctx context.Context, hash string, size int64 partNumber++ } if maxParts > 0 && partNumber > 0 && partNumber < maxParts { - return nil, errors.New(fmt.Sprintf("too many parts: %d", partNumber)) + return nil, fmt.Errorf("too many parts: %d", partNumber) } if info, err := c.StatObject(ctx, c.HashPath(hash)); err == nil { return nil, &HashAlreadyExistsError{Object: info} diff --git a/pkg/common/db/s3/cos/cos.go b/pkg/common/db/s3/cos/cos.go index a82ffe670..b302f1de6 100644 --- a/pkg/common/db/s3/cos/cos.go +++ b/pkg/common/db/s3/cos/cos.go @@ -52,8 +52,8 @@ const ( const successCode = http.StatusOK const ( - videoSnapshotImagePng = "png" - videoSnapshotImageJpg = "jpg" +// videoSnapshotImagePng = "png" +// videoSnapshotImageJpg = "jpg" ) func NewCos() (s3.Interface, error) { diff --git a/pkg/common/db/s3/minio/minio.go b/pkg/common/db/s3/minio/minio.go index 5a615dcfd..53a2864ef 100644 --- a/pkg/common/db/s3/minio/minio.go +++ b/pkg/common/db/s3/minio/minio.go @@ -140,7 +140,7 @@ func (m *Minio) initMinio(ctx context.Context) error { return fmt.Errorf("check bucket exists error: %w", err) } if !exists { - if err := m.core.Client.MakeBucket(ctx, conf.Bucket, minio.MakeBucketOptions{}); err != nil { + if err = m.core.Client.MakeBucket(ctx, conf.Bucket, minio.MakeBucketOptions{}); err != nil { return fmt.Errorf("make bucket error: %w", err) } }