-
-
Notifications
You must be signed in to change notification settings - Fork 880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow disabling private messages. Fixes #3640 #4094
base: main
Are you sure you want to change the base?
Conversation
This is greatly needed 👍 Can there also be a global setting? |
Global setting should probably be in a different PR / issue. This is specifically to prevent harassment on a user-level. |
Outdated, feel free to reopen when you work on it again. |
I'm not sure how to handle this, because its a local user setting, not something that gets federated with person. For example the |
LocalUserView::read_person(&mut context.pool(), recipient.id).await | ||
{ | ||
check_private_messages_enabled(&recipient_local_user)?; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check for apub is done here, so it is working, its just not a publicized setting, so like blocks, senders don't know.
@@ -130,9 +136,18 @@ impl Object for ApubPrivateMessage { | |||
let recipient = note.to[0].dereference(context).await?; | |||
PersonBlock::read(&mut context.pool(), recipient.id, creator.id).await?; | |||
|
|||
// If its a local user, check that they can receive private messages | |||
if recipient.local { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is not really needed because the recipient of a federated private message is always a local user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
K fixed.
Ah youre also getting the same random image test failure as in private community PR. |
Weird, we haven't touched that at all. |
if !local_user_view.local_user.enable_private_messages { | ||
Err(LemmyErrorType::CouldntCreatePrivateMessage)? | ||
} else { | ||
Ok(()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be expressed in a different way that you may or may not prefer:
local_user_view
.local_user
.enable_private_messages
.then_some(())
.ok_or_else(|| LemmyErrorType::CouldntCreatePrivateMessage.into())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a huge fan of that one at least in this case, because it unnecessarily coerces it into an option, when it's already a bool.
This adds a local user setting:
enable_private_messages
default true.It then checks when sending to a local user, that both you and the recipient have that setting enabled.
It also checks on an apub private message receive, that you have it enabled, before creating it.