forked from jmug/stoatchat
Add check that people can message others in guild.
This commit is contained in:
@@ -431,6 +431,10 @@ pub fn send_message(
|
||||
let permissions = with_permissions!(user, target);
|
||||
|
||||
if !permissions.get_send_messages() {
|
||||
if target.channel_type == 0 {
|
||||
return Some(Response::LackingPermission(Permission::SendDirectMessages));
|
||||
}
|
||||
|
||||
return Some(Response::LackingPermission(Permission::SendMessages));
|
||||
}
|
||||
|
||||
|
||||
@@ -50,8 +50,9 @@ impl<'a> rocket::response::Responder<'a> for Permission {
|
||||
rocket::response::Response::build()
|
||||
.header(ContentType::JSON)
|
||||
.sized_body(Cursor::new(format!(
|
||||
"{{\"error\":\"Lacking {:?} permission.\"}}",
|
||||
self
|
||||
"{{\"error\":\"Lacking permission: {:?}.\",\"permission\":{}}}",
|
||||
self,
|
||||
self as u32,
|
||||
)))
|
||||
.ok()
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ pub fn dm(user: UserRef, target: UserRef) -> Response {
|
||||
).is_ok() {
|
||||
Response::Success(json!({ "id": id.to_string() }))
|
||||
} else {
|
||||
Response::InternalServerError(json!({ "error": "Failed to create new chanel." }))
|
||||
Response::InternalServerError(json!({ "error": "Failed to create new channel." }))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user