fix: ensure list matches

This commit is contained in:
Paul Makles
2022-07-18 12:46:33 +01:00
parent 229d4e2e1d
commit 8491ced13d

View File

@@ -119,7 +119,9 @@ async fn calculate_channel_permission(
} }
} }
Channel::DirectMessage { recipients, .. } => { Channel::DirectMessage { recipients, .. } => {
// 2. Fetch user. // 2. Ensure we are a recipient.
if recipients.contains(&data.perspective.id) {
// 3. Fetch user.
let other_user = recipients let other_user = recipients
.iter() .iter()
.find(|x| x != &&data.perspective.id) .find(|x| x != &&data.perspective.id)
@@ -128,15 +130,18 @@ async fn calculate_channel_permission(
let user = db.fetch_user(other_user).await?; let user = db.fetch_user(other_user).await?;
data.user.set(user); data.user.set(user);
// 3. Calculate user permissions. // 4. Calculate user permissions.
let perms = data.calc_user(db).await; let perms = data.calc_user(db).await;
// 4. Check if the user can send messages. // 5. Check if the user can send messages.
if perms.get_send_message() { if perms.get_send_message() {
(*DEFAULT_PERMISSION_DIRECT_MESSAGE).into() (*DEFAULT_PERMISSION_DIRECT_MESSAGE).into()
} else { } else {
(*DEFAULT_PERMISSION_VIEW_ONLY).into() (*DEFAULT_PERMISSION_VIEW_ONLY).into()
} }
} else {
0_u64.into()
}
} }
Channel::Group { Channel::Group {
owner, owner,