-
-
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?
Changes from 4 commits
9973a49
1d66c02
0204b35
0e9ea4d
2f398d3
5fb642e
d0a4e3d
a481671
d77ec13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,12 @@ use activitypub_federation::{ | |
use chrono::{DateTime, Utc}; | ||
use lemmy_api_common::{ | ||
context::LemmyContext, | ||
utils::{get_url_blocklist, local_site_opt_to_slur_regex, process_markdown}, | ||
utils::{ | ||
check_private_messages_enabled, | ||
get_url_blocklist, | ||
local_site_opt_to_slur_regex, | ||
process_markdown, | ||
}, | ||
}; | ||
use lemmy_db_schema::{ | ||
source::{ | ||
|
@@ -28,6 +33,7 @@ use lemmy_db_schema::{ | |
traits::Crud, | ||
utils::naive_now, | ||
}; | ||
use lemmy_db_views::structs::LocalUserView; | ||
use lemmy_utils::{ | ||
error::{FederationError, LemmyError, LemmyErrorType, LemmyResult}, | ||
utils::markdown::markdown_to_html, | ||
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. K fixed. |
||
if let Ok(recipient_local_user) = | ||
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 commentThe 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. |
||
} | ||
let local_site = LocalSite::read(&mut context.pool()).await.ok(); | ||
let slur_regex = &local_site_opt_to_slur_regex(&local_site); | ||
let url_blocklist = get_url_blocklist(context).await?; | ||
|
||
let content = read_from_string_or_source(¬e.content, &None, ¬e.source); | ||
let content = process_markdown(&content, slur_regex, &url_blocklist, context).await?; | ||
let content = markdown_rewrite_remote_links(content, context).await; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ALTER TABLE local_user | ||
DROP COLUMN enable_private_messages; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ALTER TABLE local_user | ||
ADD COLUMN enable_private_messages boolean DEFAULT TRUE NOT NULL; | ||
|
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:
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.