Some issue fixes
This commit is contained in:
parent
96b5ccd17d
commit
b98c5f8907
@ -1203,7 +1203,7 @@ void VirtualServer::send_text_message(const std::shared_ptr<BasicChannel> &chann
|
||||
if(flag_password)
|
||||
continue; /* TODO: Send notification about new message. The client then could request messages via message history */
|
||||
|
||||
if(!client->calculate_and_get_join_state(channel))
|
||||
if(auto err_perm{client->calculate_and_get_join_state(channel)}; err_perm)
|
||||
continue;
|
||||
}
|
||||
client->notifyTextMessage(ChatMessageMode::TEXTMODE_CHANNEL, sender, client_id, channel_id, now, message);
|
||||
|
@ -987,5 +987,5 @@ permission::PermissionType ConnectedClient::calculate_and_get_join_state(const s
|
||||
if(permission::v2::permission_granted(1, this->calculate_permission(permission::b_client_is_sticky, this->currentChannel ? this->currentChannel->channelId() : 0)))
|
||||
if(!permission::v2::permission_granted(1, this->calculate_permission(permission::b_client_ignore_sticky, channel_id)))
|
||||
RESULT(permission::b_client_is_sticky);
|
||||
RESULT(permission::unknown);
|
||||
RESULT(permission::ok);
|
||||
}
|
@ -541,6 +541,10 @@ command_result ConnectedClient::handleCommandSendTextMessage(Command &cmd) {
|
||||
channel = this->currentChannel;
|
||||
channel_id = this->currentChannel->channelId();
|
||||
}
|
||||
|
||||
if(!permission::v2::permission_granted(1, this->calculate_permission(permission::b_client_channel_textmessage_send, channel_id), false)) \
|
||||
return command_result{permission::b_client_channel_textmessage_send};
|
||||
|
||||
if(channel == this->currentChannel) {
|
||||
channel_tree_read_lock.unlock(); //Method may creates a music bot which modifies the channel tree
|
||||
if(this->handleTextMessage(ChatMessageMode::TEXTMODE_CHANNEL, cmd["msg"], nullptr))
|
||||
@ -548,16 +552,13 @@ command_result ConnectedClient::handleCommandSendTextMessage(Command &cmd) {
|
||||
channel_tree_read_lock.lock();
|
||||
}
|
||||
|
||||
if(!permission::v2::permission_granted(1, this->calculate_permission(permission::b_client_channel_textmessage_send, channel_id), false)) \
|
||||
return command_result{permission::b_client_channel_textmessage_send};
|
||||
|
||||
bool conversation_private = channel->properties()[property::CHANNEL_FLAG_CONVERSATION_PRIVATE].as<bool>();
|
||||
if(channel != this->currentChannel) {
|
||||
if(conversation_private)
|
||||
return command_result{error::conversation_is_private};
|
||||
|
||||
if(!this->calculate_and_get_join_state(channel))
|
||||
return command_result{permission::b_client_channel_textmessage_send}; /* You're not allowed to send messages :) */
|
||||
if(auto fail_perm{this->calculate_and_get_join_state(channel)}; fail_perm != permission::ok)
|
||||
return command_result{fail_perm}; /* You're not allowed to send messages :) */
|
||||
}
|
||||
|
||||
this->server->send_text_message(channel, this->ref(), cmd["msg"].string());
|
||||
@ -2502,7 +2503,7 @@ command_result ConnectedClient::handleCommandConversationMessageDelete(ts::Comma
|
||||
if (!permission::v2::permission_granted(1, this->calculate_permission(permission::b_channel_conversation_message_delete, 1, channel->channelId())))
|
||||
return command_result{permission::b_channel_conversation_message_delete};
|
||||
|
||||
if(auto error_perm = this->calculate_and_get_join_state(channel); error_perm != permission::b_client_is_sticky)
|
||||
if(auto error_perm = this->calculate_and_get_join_state(channel); error_perm && error_perm != permission::b_client_is_sticky)
|
||||
return command_result{error_perm};
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ command_result ConnectedClient::handleCommandMusicBotCreate(Command& cmd) {
|
||||
if(!channel) {
|
||||
if(cmd[0].has("cid")) return command_result{error::channel_invalid_id};
|
||||
} else {
|
||||
if(!this->calculate_and_get_join_state(channel))
|
||||
if(this->calculate_and_get_join_state(channel) != permission::ok)
|
||||
channel = nullptr;
|
||||
}
|
||||
if(!channel)
|
||||
|
Loading…
Reference in New Issue
Block a user