Channel_loadMessageBlock

This commit is contained in:
2025-12-08 05:23:24 +05:00
parent 6d1f450f32
commit 88c2f8aa51
14 changed files with 149 additions and 89 deletions

View File

@@ -17,20 +17,15 @@ declare_RequestHandler(SendMessage)
if(!conn->authorized){
try_void(sendErrorMessage(log_ctx, conn, res_head,
LogSeverity_Warn,
STR("is not authorized")
));
LogSeverity_Warn, STR("not authorized") ));
Return RESULT_VOID;
}
if(req.data_size < MESSAGE_SIZE_MIN || req.data_size > MESSAGE_SIZE_MAX){
try_void(sendErrorMessage_f(log_ctx, conn, res_head,
LogSeverity_Warn,
"message size must be >= %i and <= %i",
MESSAGE_SIZE_MIN, MESSAGE_SIZE_MAX
));
// this will close socket connection
Return RESULT_ERROR("invalid message size", false);
try_void(sendErrorMessage(log_ctx, conn, res_head,
LogSeverity_Warn, STR("invalid message size") ));
// close socket connection to reject incoming data
Return RESULT_ERROR_CODE_FMT(TcpChat, TcpChatError_RejectIncoming, "invalid message size: %u", req.data_size);
}
// receive message data
@@ -41,13 +36,12 @@ declare_RequestHandler(SendMessage)
Channel* ch = Server_tryGetChannel(conn->server, req.channel_id);
if(ch == NULL){
try_void(sendErrorMessage(log_ctx, conn, res_head,
LogSeverity_Warn,
STR("invalid channel id")
));
LogSeverity_Warn, STR("invalid channel id") ));
Return RESULT_VOID;
}
MessageMeta message_meta;
try_void(Channel_saveMessage(ch, message_data, conn->user_id, &message_meta));
try_void(Channel_saveMessage(ch, message_data, conn->user_id,
&message_meta, true));
// send response
SendMessageResponse res;