Compare commits
2
Commits
0.5.5
..
20220718-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8491ced13d | ||
|
|
229d4e2e1d |
@@ -83,11 +83,11 @@ pub async fn req(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Transfer ownership
|
// Transfer ownership
|
||||||
*owner = new_owner.to_string();
|
let old_owner = std::mem::replace(owner, new_owner.to_string());
|
||||||
|
|
||||||
// Notify clients
|
// Notify clients
|
||||||
SystemMessage::ChannelOwnershipChanged {
|
SystemMessage::ChannelOwnershipChanged {
|
||||||
from: owner.to_string(),
|
from: old_owner,
|
||||||
to: new_owner,
|
to: new_owner,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -119,23 +119,28 @@ async fn calculate_channel_permission(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Channel::DirectMessage { recipients, .. } => {
|
Channel::DirectMessage { recipients, .. } => {
|
||||||
// 2. Fetch user.
|
// 2. Ensure we are a recipient.
|
||||||
let other_user = recipients
|
if recipients.contains(&data.perspective.id) {
|
||||||
.iter()
|
// 3. Fetch user.
|
||||||
.find(|x| x != &&data.perspective.id)
|
let other_user = recipients
|
||||||
.unwrap();
|
.iter()
|
||||||
|
.find(|x| x != &&data.perspective.id)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
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 {
|
||||||
|
(*DEFAULT_PERMISSION_VIEW_ONLY).into()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
(*DEFAULT_PERMISSION_VIEW_ONLY).into()
|
0_u64.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Channel::Group {
|
Channel::Group {
|
||||||
|
|||||||
Reference in New Issue
Block a user