Skip to content

Commit

Permalink
feat: update openim pull message by seq (#1498)
Browse files Browse the repository at this point in the history
  • Loading branch information
cubxxw committed Nov 30, 2023
1 parent 0efc235 commit 5b697d5
Showing 1 changed file with 49 additions and 3 deletions.
52 changes: 49 additions & 3 deletions scripts/install/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,40 @@ EOF
openim::test::check_error "$response"
}

# Pulls messages by sequence.
openim::test::pull_msg_by_seq() {
local userID="${1}"
local conversationID="${2}"
local beginSeq="${3}"
local endSeq="${4}"
local num="${5}"
local order="${6}" # Assuming 0 for ascending, 1 for descending

# Construct the request body
local request_body=$(cat <<EOF
{
"userID": "${userID}",
"seqRanges": [
{
"conversationID": "${conversationID}",
"begin": ${beginSeq},
"end": ${endSeq},
"num": ${num}
}
],
"order": ${order}
}
EOF
)
echo "$request_body"

# Send the request
local response=$(${CCURL} "${Token}" "${OperationID}" "${Header}" "${INSECURE_OPENIMAPI}/msg/pull_msg_by_seq" -d "${request_body}")

# Check the response for errors
openim::test::check_error "$response"
}

# Revokes a message.
openim::test::revoke_msg() {
local userID="${1}"
Expand Down Expand Up @@ -1265,12 +1299,24 @@ function openim::test::msg()

echo "Searching for messages between ${SEND_USER_ID} and ${RECV_USER_ID}..."
openim::test::search_msg "${MANAGER_USERID_1}" "${RECV_USER_ID}" "${MSG_TYPE}" "${SEARCH_TIME}" "${SESSION_TYPE}" "${PAGE_NUMBER}" "${SHOW_NUMBER}"


# 3. Pull messages by sequence.
local CONVERSATION_ID="ci_${SEND_USER_ID}_${RECV_USER_ID}" # Adjust as per your conversation ID format
local BEGIN_SEQ=0
local END_SEQ=10
local NUM=5
local ORDER=0 # Assuming 0 for ascending order
openim::test::pull_msg_by_seq "${RECV_USER_ID}" "${CONVERSATION_ID}" "${BEGIN_SEQ}" "${END_SEQ}" "${NUM}" "${ORDER}"


# Assuming message sending was successful and returned a sequence number.
local SEQ_NUMBER=1 # This should be the actual sequence number of the message sent.

# 2. Revoke a message.
# TODO:
# openim::test::revoke_msg "${RECV_USER_ID}" "si_${SEND_USER_ID}_${RECV_USER_ID}" "${SEQ_NUMBER}"

# 3. Clear all messages for a user.
# 4. Clear all messages for a user.
openim::test::user_clear_all_msg "${RECV_USER_ID}"

# Log the completion of the message test suite.
Expand Down

0 comments on commit 5b697d5

Please sign in to comment.