Channel_loadMessageBlock
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user