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
Be more explicit about returning deleted actors or not #2335
Changes from all commits
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 |
---|---|---|
|
@@ -332,12 +332,20 @@ impl ApubActor for Community { | |
) | ||
} | ||
|
||
fn read_from_name(conn: &PgConnection, community_name: &str) -> Result<Community, Error> { | ||
fn read_from_name( | ||
conn: &PgConnection, | ||
community_name: &str, | ||
include_deleted: bool, | ||
) -> Result<Community, Error> { | ||
use crate::schema::community::dsl::*; | ||
community | ||
let mut q = community | ||
.into_boxed() | ||
.filter(local.eq(true)) | ||
.filter(lower(name).eq(lower(community_name))) | ||
.first::<Self>(conn) | ||
.filter(lower(name).eq(lower(community_name))); | ||
if !include_deleted { | ||
q = q.filter(deleted.eq(false)).filter(removed.eq(false)); | ||
} | ||
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 is a little awkward, not sure if theres a better way to write the query. 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. Do Then you can do: `if .... { 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. Like this? Gives me error "overflow evaluating the requirement
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. You do the into_boxed before filters I think. |
||
q.first::<Self>(conn) | ||
} | ||
|
||
fn read_from_name_and_domain( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -305,12 +305,19 @@ impl ApubActor for Person { | |
) | ||
} | ||
|
||
fn read_from_name(conn: &PgConnection, from_name: &str) -> Result<Person, Error> { | ||
person | ||
.filter(deleted.eq(false)) | ||
fn read_from_name( | ||
conn: &PgConnection, | ||
from_name: &str, | ||
include_deleted: bool, | ||
) -> Result<Person, Error> { | ||
let mut q = person | ||
.into_boxed() | ||
.filter(local.eq(true)) | ||
.filter(lower(name).eq(lower(from_name))) | ||
.first::<Person>(conn) | ||
.filter(lower(name).eq(lower(from_name))); | ||
if !include_deleted { | ||
q = q.filter(deleted.eq(false)) | ||
} | ||
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. Same for this one here. |
||
q.first::<Self>(conn) | ||
} | ||
|
||
fn read_from_name_and_domain( | ||
|
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.
Search should probably not list deleted users or communities.