mirror of
https://github.com/LemmyNet/lemmy
synced 2024-11-11 01:10:29 +00:00
Mark account as bot. Fixes #1357
This commit is contained in:
parent
1a3a215f59
commit
fb954e946c
@ -176,6 +176,7 @@ impl Perform for SaveUserSettings {
|
|||||||
let bio = diesel_option_overwrite(&data.bio);
|
let bio = diesel_option_overwrite(&data.bio);
|
||||||
let preferred_username = diesel_option_overwrite(&data.preferred_username);
|
let preferred_username = diesel_option_overwrite(&data.preferred_username);
|
||||||
let matrix_user_id = diesel_option_overwrite(&data.matrix_user_id);
|
let matrix_user_id = diesel_option_overwrite(&data.matrix_user_id);
|
||||||
|
let bot_account = data.bot_account;
|
||||||
|
|
||||||
if let Some(Some(bio)) = &bio {
|
if let Some(Some(bio)) = &bio {
|
||||||
if bio.chars().count() > 300 {
|
if bio.chars().count() > 300 {
|
||||||
@ -249,6 +250,7 @@ impl Perform for SaveUserSettings {
|
|||||||
last_refreshed_at: None,
|
last_refreshed_at: None,
|
||||||
shared_inbox_url: None,
|
shared_inbox_url: None,
|
||||||
matrix_user_id,
|
matrix_user_id,
|
||||||
|
bot_account,
|
||||||
};
|
};
|
||||||
|
|
||||||
let person_res = blocking(context.pool(), move |conn| {
|
let person_res = blocking(context.pool(), move |conn| {
|
||||||
@ -267,6 +269,7 @@ impl Perform for SaveUserSettings {
|
|||||||
email,
|
email,
|
||||||
password_encrypted,
|
password_encrypted,
|
||||||
show_nsfw: data.show_nsfw,
|
show_nsfw: data.show_nsfw,
|
||||||
|
show_bot_accounts: data.show_bot_accounts,
|
||||||
theme: data.theme.to_owned(),
|
theme: data.theme.to_owned(),
|
||||||
default_sort_type,
|
default_sort_type,
|
||||||
default_listing_type,
|
default_listing_type,
|
||||||
@ -458,11 +461,14 @@ impl Perform for GetReplies {
|
|||||||
let limit = data.limit;
|
let limit = data.limit;
|
||||||
let unread_only = data.unread_only;
|
let unread_only = data.unread_only;
|
||||||
let person_id = local_user_view.person.id;
|
let person_id = local_user_view.person.id;
|
||||||
|
let show_bot_accounts = local_user_view.local_user.show_bot_accounts;
|
||||||
|
|
||||||
let replies = blocking(context.pool(), move |conn| {
|
let replies = blocking(context.pool(), move |conn| {
|
||||||
CommentQueryBuilder::create(conn)
|
CommentQueryBuilder::create(conn)
|
||||||
.sort(&sort)
|
.sort(&sort)
|
||||||
.unread_only(unread_only)
|
.unread_only(unread_only)
|
||||||
.recipient_id(person_id)
|
.recipient_id(person_id)
|
||||||
|
.show_bot_accounts(show_bot_accounts)
|
||||||
.my_person_id(person_id)
|
.my_person_id(person_id)
|
||||||
.page(page)
|
.page(page)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
|
@ -9,6 +9,8 @@ use lemmy_api_common::{
|
|||||||
get_local_user_view_from_jwt_opt,
|
get_local_user_view_from_jwt_opt,
|
||||||
is_admin,
|
is_admin,
|
||||||
site::*,
|
site::*,
|
||||||
|
user_show_bot_accounts,
|
||||||
|
user_show_nsfw,
|
||||||
};
|
};
|
||||||
use lemmy_apub::fetcher::search::search_by_apub_id;
|
use lemmy_apub::fetcher::search::search_by_apub_id;
|
||||||
use lemmy_db_queries::{source::site::Site_, Crud, SearchType, SortType};
|
use lemmy_db_queries::{source::site::Site_, Crud, SearchType, SortType};
|
||||||
@ -136,6 +138,10 @@ impl Perform for Search {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let local_user_view = get_local_user_view_from_jwt_opt(&data.auth, context.pool()).await?;
|
let local_user_view = get_local_user_view_from_jwt_opt(&data.auth, context.pool()).await?;
|
||||||
|
|
||||||
|
let show_nsfw = user_show_nsfw(&local_user_view);
|
||||||
|
let show_bot_accounts = user_show_bot_accounts(&local_user_view);
|
||||||
|
|
||||||
let person_id = local_user_view.map(|u| u.person.id);
|
let person_id = local_user_view.map(|u| u.person.id);
|
||||||
|
|
||||||
let type_ = SearchType::from_str(&data.type_)?;
|
let type_ = SearchType::from_str(&data.type_)?;
|
||||||
@ -158,7 +164,8 @@ impl Perform for Search {
|
|||||||
posts = blocking(context.pool(), move |conn| {
|
posts = blocking(context.pool(), move |conn| {
|
||||||
PostQueryBuilder::create(conn)
|
PostQueryBuilder::create(conn)
|
||||||
.sort(&sort)
|
.sort(&sort)
|
||||||
.show_nsfw(true)
|
.show_nsfw(show_nsfw)
|
||||||
|
.show_bot_accounts(show_bot_accounts)
|
||||||
.community_id(community_id)
|
.community_id(community_id)
|
||||||
.community_name(community_name)
|
.community_name(community_name)
|
||||||
.my_person_id(person_id)
|
.my_person_id(person_id)
|
||||||
@ -174,6 +181,7 @@ impl Perform for Search {
|
|||||||
CommentQueryBuilder::create(&conn)
|
CommentQueryBuilder::create(&conn)
|
||||||
.sort(&sort)
|
.sort(&sort)
|
||||||
.search_term(q)
|
.search_term(q)
|
||||||
|
.show_bot_accounts(show_bot_accounts)
|
||||||
.my_person_id(person_id)
|
.my_person_id(person_id)
|
||||||
.page(page)
|
.page(page)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
@ -208,7 +216,8 @@ impl Perform for Search {
|
|||||||
posts = blocking(context.pool(), move |conn| {
|
posts = blocking(context.pool(), move |conn| {
|
||||||
PostQueryBuilder::create(conn)
|
PostQueryBuilder::create(conn)
|
||||||
.sort(&sort)
|
.sort(&sort)
|
||||||
.show_nsfw(true)
|
.show_nsfw(show_nsfw)
|
||||||
|
.show_bot_accounts(show_bot_accounts)
|
||||||
.community_id(community_id)
|
.community_id(community_id)
|
||||||
.community_name(community_name)
|
.community_name(community_name)
|
||||||
.my_person_id(person_id)
|
.my_person_id(person_id)
|
||||||
@ -226,6 +235,7 @@ impl Perform for Search {
|
|||||||
CommentQueryBuilder::create(conn)
|
CommentQueryBuilder::create(conn)
|
||||||
.sort(&sort)
|
.sort(&sort)
|
||||||
.search_term(q)
|
.search_term(q)
|
||||||
|
.show_bot_accounts(show_bot_accounts)
|
||||||
.my_person_id(person_id)
|
.my_person_id(person_id)
|
||||||
.page(page)
|
.page(page)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
@ -264,7 +274,8 @@ impl Perform for Search {
|
|||||||
posts = blocking(context.pool(), move |conn| {
|
posts = blocking(context.pool(), move |conn| {
|
||||||
PostQueryBuilder::create(conn)
|
PostQueryBuilder::create(conn)
|
||||||
.sort(&sort)
|
.sort(&sort)
|
||||||
.show_nsfw(true)
|
.show_nsfw(show_nsfw)
|
||||||
|
.show_bot_accounts(show_bot_accounts)
|
||||||
.my_person_id(person_id)
|
.my_person_id(person_id)
|
||||||
.community_id(community_id)
|
.community_id(community_id)
|
||||||
.community_name(community_name)
|
.community_name(community_name)
|
||||||
|
@ -236,6 +236,22 @@ pub fn is_admin(local_user_view: &LocalUserView) -> Result<(), LemmyError> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A helper method for showing the bot account
|
||||||
|
pub fn user_show_bot_accounts(local_user_view: &Option<LocalUserView>) -> bool {
|
||||||
|
match local_user_view {
|
||||||
|
Some(uv) => uv.to_owned().local_user.show_bot_accounts,
|
||||||
|
None => true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A helper method for showing nsfw
|
||||||
|
pub fn user_show_nsfw(local_user_view: &Option<LocalUserView>) -> bool {
|
||||||
|
match &local_user_view {
|
||||||
|
Some(uv) => uv.local_user.show_nsfw,
|
||||||
|
None => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn get_post(post_id: PostId, pool: &DbPool) -> Result<Post, LemmyError> {
|
pub async fn get_post(post_id: PostId, pool: &DbPool) -> Result<Post, LemmyError> {
|
||||||
match blocking(pool, move |conn| Post::read(conn, post_id)).await? {
|
match blocking(pool, move |conn| Post::read(conn, post_id)).await? {
|
||||||
Ok(post) => Ok(post),
|
Ok(post) => Ok(post),
|
||||||
|
@ -62,6 +62,8 @@ pub struct SaveUserSettings {
|
|||||||
pub old_password: Option<String>,
|
pub old_password: Option<String>,
|
||||||
pub show_avatars: Option<bool>,
|
pub show_avatars: Option<bool>,
|
||||||
pub send_notifications_to_email: Option<bool>,
|
pub send_notifications_to_email: Option<bool>,
|
||||||
|
pub bot_account: Option<bool>,
|
||||||
|
pub show_bot_accounts: Option<bool>,
|
||||||
pub auth: String,
|
pub auth: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
use crate::PerformCrud;
|
use crate::PerformCrud;
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use lemmy_api_common::{blocking, comment::*, get_local_user_view_from_jwt_opt};
|
use lemmy_api_common::{
|
||||||
|
blocking,
|
||||||
|
comment::*,
|
||||||
|
get_local_user_view_from_jwt_opt,
|
||||||
|
user_show_bot_accounts,
|
||||||
|
};
|
||||||
use lemmy_db_queries::{ListingType, SortType};
|
use lemmy_db_queries::{ListingType, SortType};
|
||||||
use lemmy_db_views::comment_view::CommentQueryBuilder;
|
use lemmy_db_views::comment_view::CommentQueryBuilder;
|
||||||
use lemmy_utils::{ApiError, ConnectionId, LemmyError};
|
use lemmy_utils::{ApiError, ConnectionId, LemmyError};
|
||||||
@ -18,6 +23,8 @@ impl PerformCrud for GetComments {
|
|||||||
) -> Result<GetCommentsResponse, LemmyError> {
|
) -> Result<GetCommentsResponse, LemmyError> {
|
||||||
let data: &GetComments = &self;
|
let data: &GetComments = &self;
|
||||||
let local_user_view = get_local_user_view_from_jwt_opt(&data.auth, context.pool()).await?;
|
let local_user_view = get_local_user_view_from_jwt_opt(&data.auth, context.pool()).await?;
|
||||||
|
|
||||||
|
let show_bot_accounts = user_show_bot_accounts(&local_user_view);
|
||||||
let person_id = local_user_view.map(|u| u.person.id);
|
let person_id = local_user_view.map(|u| u.person.id);
|
||||||
|
|
||||||
let type_ = ListingType::from_str(&data.type_)?;
|
let type_ = ListingType::from_str(&data.type_)?;
|
||||||
@ -36,6 +43,7 @@ impl PerformCrud for GetComments {
|
|||||||
.community_id(community_id)
|
.community_id(community_id)
|
||||||
.community_name(community_name)
|
.community_name(community_name)
|
||||||
.my_person_id(person_id)
|
.my_person_id(person_id)
|
||||||
|
.show_bot_accounts(show_bot_accounts)
|
||||||
.page(page)
|
.page(page)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.list()
|
.list()
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
use crate::PerformCrud;
|
use crate::PerformCrud;
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use lemmy_api_common::{blocking, get_local_user_view_from_jwt_opt, post::*};
|
use lemmy_api_common::{
|
||||||
|
blocking,
|
||||||
|
get_local_user_view_from_jwt_opt,
|
||||||
|
post::*,
|
||||||
|
user_show_bot_accounts,
|
||||||
|
user_show_nsfw,
|
||||||
|
};
|
||||||
use lemmy_db_queries::{ListingType, SortType};
|
use lemmy_db_queries::{ListingType, SortType};
|
||||||
use lemmy_db_views::{
|
use lemmy_db_views::{
|
||||||
comment_view::CommentQueryBuilder,
|
comment_view::CommentQueryBuilder,
|
||||||
@ -25,6 +31,9 @@ impl PerformCrud for GetPost {
|
|||||||
) -> Result<GetPostResponse, LemmyError> {
|
) -> Result<GetPostResponse, LemmyError> {
|
||||||
let data: &GetPost = &self;
|
let data: &GetPost = &self;
|
||||||
let local_user_view = get_local_user_view_from_jwt_opt(&data.auth, context.pool()).await?;
|
let local_user_view = get_local_user_view_from_jwt_opt(&data.auth, context.pool()).await?;
|
||||||
|
|
||||||
|
let show_bot_accounts = user_show_bot_accounts(&local_user_view);
|
||||||
|
|
||||||
let person_id = local_user_view.map(|u| u.person.id);
|
let person_id = local_user_view.map(|u| u.person.id);
|
||||||
|
|
||||||
let id = data.id;
|
let id = data.id;
|
||||||
@ -41,6 +50,7 @@ impl PerformCrud for GetPost {
|
|||||||
let comments = blocking(context.pool(), move |conn| {
|
let comments = blocking(context.pool(), move |conn| {
|
||||||
CommentQueryBuilder::create(conn)
|
CommentQueryBuilder::create(conn)
|
||||||
.my_person_id(person_id)
|
.my_person_id(person_id)
|
||||||
|
.show_bot_accounts(show_bot_accounts)
|
||||||
.post_id(id)
|
.post_id(id)
|
||||||
.limit(9999)
|
.limit(9999)
|
||||||
.list()
|
.list()
|
||||||
@ -94,10 +104,8 @@ impl PerformCrud for GetPosts {
|
|||||||
|
|
||||||
let person_id = local_user_view.to_owned().map(|l| l.person.id);
|
let person_id = local_user_view.to_owned().map(|l| l.person.id);
|
||||||
|
|
||||||
let show_nsfw = match &local_user_view {
|
let show_nsfw = user_show_nsfw(&local_user_view);
|
||||||
Some(uv) => uv.local_user.show_nsfw,
|
let show_bot_accounts = user_show_bot_accounts(&local_user_view);
|
||||||
None => false,
|
|
||||||
};
|
|
||||||
|
|
||||||
let type_ = ListingType::from_str(&data.type_)?;
|
let type_ = ListingType::from_str(&data.type_)?;
|
||||||
let sort = SortType::from_str(&data.sort)?;
|
let sort = SortType::from_str(&data.sort)?;
|
||||||
@ -113,6 +121,7 @@ impl PerformCrud for GetPosts {
|
|||||||
.listing_type(&type_)
|
.listing_type(&type_)
|
||||||
.sort(&sort)
|
.sort(&sort)
|
||||||
.show_nsfw(show_nsfw)
|
.show_nsfw(show_nsfw)
|
||||||
|
.show_bot_accounts(show_bot_accounts)
|
||||||
.community_id(community_id)
|
.community_id(community_id)
|
||||||
.community_name(community_name)
|
.community_name(community_name)
|
||||||
.saved_only(saved_only)
|
.saved_only(saved_only)
|
||||||
|
@ -128,6 +128,7 @@ impl PerformCrud for Register {
|
|||||||
email: Some(data.email.to_owned()),
|
email: Some(data.email.to_owned()),
|
||||||
password_encrypted: data.password.to_owned(),
|
password_encrypted: data.password.to_owned(),
|
||||||
show_nsfw: Some(data.show_nsfw),
|
show_nsfw: Some(data.show_nsfw),
|
||||||
|
show_bot_accounts: Some(true),
|
||||||
theme: Some("browser".into()),
|
theme: Some("browser".into()),
|
||||||
default_sort_type: Some(SortType::Active as i16),
|
default_sort_type: Some(SortType::Active as i16),
|
||||||
default_listing_type: Some(ListingType::Subscribed as i16),
|
default_listing_type: Some(ListingType::Subscribed as i16),
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
use crate::PerformCrud;
|
use crate::PerformCrud;
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use lemmy_api_common::{blocking, get_local_user_view_from_jwt_opt, person::*};
|
use lemmy_api_common::{
|
||||||
|
blocking,
|
||||||
|
get_local_user_view_from_jwt_opt,
|
||||||
|
person::*,
|
||||||
|
user_show_bot_accounts,
|
||||||
|
user_show_nsfw,
|
||||||
|
};
|
||||||
use lemmy_db_queries::{source::person::Person_, SortType};
|
use lemmy_db_queries::{source::person::Person_, SortType};
|
||||||
use lemmy_db_schema::source::person::*;
|
use lemmy_db_schema::source::person::*;
|
||||||
use lemmy_db_views::{comment_view::CommentQueryBuilder, post_view::PostQueryBuilder};
|
use lemmy_db_views::{comment_view::CommentQueryBuilder, post_view::PostQueryBuilder};
|
||||||
@ -25,10 +31,8 @@ impl PerformCrud for GetPersonDetails {
|
|||||||
let data: &GetPersonDetails = &self;
|
let data: &GetPersonDetails = &self;
|
||||||
let local_user_view = get_local_user_view_from_jwt_opt(&data.auth, context.pool()).await?;
|
let local_user_view = get_local_user_view_from_jwt_opt(&data.auth, context.pool()).await?;
|
||||||
|
|
||||||
let show_nsfw = match &local_user_view {
|
let show_nsfw = user_show_nsfw(&local_user_view);
|
||||||
Some(uv) => uv.local_user.show_nsfw,
|
let show_bot_accounts = user_show_bot_accounts(&local_user_view);
|
||||||
None => false,
|
|
||||||
};
|
|
||||||
|
|
||||||
let sort = SortType::from_str(&data.sort)?;
|
let sort = SortType::from_str(&data.sort)?;
|
||||||
|
|
||||||
@ -68,6 +72,7 @@ impl PerformCrud for GetPersonDetails {
|
|||||||
let mut posts_query = PostQueryBuilder::create(conn)
|
let mut posts_query = PostQueryBuilder::create(conn)
|
||||||
.sort(&sort)
|
.sort(&sort)
|
||||||
.show_nsfw(show_nsfw)
|
.show_nsfw(show_nsfw)
|
||||||
|
.show_bot_accounts(show_bot_accounts)
|
||||||
.saved_only(saved_only)
|
.saved_only(saved_only)
|
||||||
.community_id(community_id)
|
.community_id(community_id)
|
||||||
.my_person_id(person_id)
|
.my_person_id(person_id)
|
||||||
@ -76,6 +81,7 @@ impl PerformCrud for GetPersonDetails {
|
|||||||
|
|
||||||
let mut comments_query = CommentQueryBuilder::create(conn)
|
let mut comments_query = CommentQueryBuilder::create(conn)
|
||||||
.my_person_id(person_id)
|
.my_person_id(person_id)
|
||||||
|
.show_bot_accounts(show_bot_accounts)
|
||||||
.sort(&sort)
|
.sort(&sort)
|
||||||
.saved_only(saved_only)
|
.saved_only(saved_only)
|
||||||
.community_id(community_id)
|
.community_id(community_id)
|
||||||
|
@ -9,11 +9,18 @@ use serde::{Deserialize, Serialize};
|
|||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct PersonExtension {
|
pub struct PersonExtension {
|
||||||
pub matrix_user_id: Option<String>,
|
pub matrix_user_id: Option<String>,
|
||||||
|
pub bot_account: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PersonExtension {
|
impl PersonExtension {
|
||||||
pub fn new(matrix_user_id: Option<String>) -> Result<PersonExtension, LemmyError> {
|
pub fn new(
|
||||||
Ok(PersonExtension { matrix_user_id })
|
matrix_user_id: Option<String>,
|
||||||
|
bot_account: bool,
|
||||||
|
) -> Result<PersonExtension, LemmyError> {
|
||||||
|
Ok(PersonExtension {
|
||||||
|
matrix_user_id,
|
||||||
|
bot_account,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,11 +33,13 @@ where
|
|||||||
fn try_from_unparsed(unparsed_mut: &mut U) -> Result<Self, Self::Error> {
|
fn try_from_unparsed(unparsed_mut: &mut U) -> Result<Self, Self::Error> {
|
||||||
Ok(PersonExtension {
|
Ok(PersonExtension {
|
||||||
matrix_user_id: unparsed_mut.remove("matrix_user_id")?,
|
matrix_user_id: unparsed_mut.remove("matrix_user_id")?,
|
||||||
|
bot_account: unparsed_mut.remove("bot_account")?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_into_unparsed(self, unparsed_mut: &mut U) -> Result<(), Self::Error> {
|
fn try_into_unparsed(self, unparsed_mut: &mut U) -> Result<(), Self::Error> {
|
||||||
unparsed_mut.insert("matrix_user_id", self.matrix_user_id)?;
|
unparsed_mut.insert("matrix_user_id", self.matrix_user_id)?;
|
||||||
|
unparsed_mut.insert("bot_account", self.bot_account)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,8 @@ impl ToApub for DbPerson {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
let person_ext = PersonExtension::new(self.matrix_user_id.to_owned())?;
|
let person_ext =
|
||||||
|
PersonExtension::new(self.matrix_user_id.to_owned(), self.bot_account.to_owned())?;
|
||||||
Ok(Ext2::new(ap_actor, person_ext, self.get_public_key_ext()?))
|
Ok(Ext2::new(ap_actor, person_ext, self.get_public_key_ext()?))
|
||||||
}
|
}
|
||||||
fn to_tombstone(&self) -> Result<Tombstone, LemmyError> {
|
fn to_tombstone(&self) -> Result<Tombstone, LemmyError> {
|
||||||
@ -192,6 +193,7 @@ impl FromApubToForm<PersonExt> for PersonForm {
|
|||||||
bio: Some(bio),
|
bio: Some(bio),
|
||||||
local: Some(false),
|
local: Some(false),
|
||||||
admin: Some(false),
|
admin: Some(false),
|
||||||
|
bot_account: Some(person.ext_one.bot_account),
|
||||||
private_key: None,
|
private_key: None,
|
||||||
public_key: Some(Some(person.ext_two.public_key.to_owned().public_key_pem)),
|
public_key: Some(Some(person.ext_two.public_key.to_owned().public_key_pem)),
|
||||||
last_refreshed_at: Some(naive_now()),
|
last_refreshed_at: Some(naive_now()),
|
||||||
|
@ -24,6 +24,7 @@ mod safe_settings_type {
|
|||||||
show_avatars,
|
show_avatars,
|
||||||
send_notifications_to_email,
|
send_notifications_to_email,
|
||||||
validator_time,
|
validator_time,
|
||||||
|
show_bot_accounts,
|
||||||
);
|
);
|
||||||
|
|
||||||
impl ToSafeSettings for LocalUser {
|
impl ToSafeSettings for LocalUser {
|
||||||
@ -43,6 +44,7 @@ mod safe_settings_type {
|
|||||||
show_avatars,
|
show_avatars,
|
||||||
send_notifications_to_email,
|
send_notifications_to_email,
|
||||||
validator_time,
|
validator_time,
|
||||||
|
show_bot_accounts,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ mod safe_type {
|
|||||||
shared_inbox_url,
|
shared_inbox_url,
|
||||||
matrix_user_id,
|
matrix_user_id,
|
||||||
admin,
|
admin,
|
||||||
|
bot_account,
|
||||||
);
|
);
|
||||||
|
|
||||||
impl ToSafe for Person {
|
impl ToSafe for Person {
|
||||||
@ -51,6 +52,7 @@ mod safe_type {
|
|||||||
shared_inbox_url,
|
shared_inbox_url,
|
||||||
matrix_user_id,
|
matrix_user_id,
|
||||||
admin,
|
admin,
|
||||||
|
bot_account,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,6 +79,7 @@ mod safe_type_alias_1 {
|
|||||||
shared_inbox_url,
|
shared_inbox_url,
|
||||||
matrix_user_id,
|
matrix_user_id,
|
||||||
admin,
|
admin,
|
||||||
|
bot_account,
|
||||||
);
|
);
|
||||||
|
|
||||||
impl ToSafe for PersonAlias1 {
|
impl ToSafe for PersonAlias1 {
|
||||||
@ -99,6 +102,7 @@ mod safe_type_alias_1 {
|
|||||||
shared_inbox_url,
|
shared_inbox_url,
|
||||||
matrix_user_id,
|
matrix_user_id,
|
||||||
admin,
|
admin,
|
||||||
|
bot_account,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,6 +129,7 @@ mod safe_type_alias_2 {
|
|||||||
shared_inbox_url,
|
shared_inbox_url,
|
||||||
matrix_user_id,
|
matrix_user_id,
|
||||||
admin,
|
admin,
|
||||||
|
bot_account,
|
||||||
);
|
);
|
||||||
|
|
||||||
impl ToSafe for PersonAlias2 {
|
impl ToSafe for PersonAlias2 {
|
||||||
@ -147,6 +152,7 @@ mod safe_type_alias_2 {
|
|||||||
shared_inbox_url,
|
shared_inbox_url,
|
||||||
matrix_user_id,
|
matrix_user_id,
|
||||||
admin,
|
admin,
|
||||||
|
bot_account,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -274,6 +280,7 @@ mod tests {
|
|||||||
actor_id: inserted_person.actor_id.to_owned(),
|
actor_id: inserted_person.actor_id.to_owned(),
|
||||||
bio: None,
|
bio: None,
|
||||||
local: true,
|
local: true,
|
||||||
|
bot_account: false,
|
||||||
admin: false,
|
admin: false,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
public_key: None,
|
public_key: None,
|
||||||
|
@ -154,6 +154,7 @@ table! {
|
|||||||
show_avatars -> Bool,
|
show_avatars -> Bool,
|
||||||
send_notifications_to_email -> Bool,
|
send_notifications_to_email -> Bool,
|
||||||
validator_time -> Timestamp,
|
validator_time -> Timestamp,
|
||||||
|
show_bot_accounts -> Bool,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,6 +288,7 @@ table! {
|
|||||||
shared_inbox_url -> Nullable<Varchar>,
|
shared_inbox_url -> Nullable<Varchar>,
|
||||||
matrix_user_id -> Nullable<Text>,
|
matrix_user_id -> Nullable<Text>,
|
||||||
admin -> Bool,
|
admin -> Bool,
|
||||||
|
bot_account -> Bool,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,6 +489,7 @@ table! {
|
|||||||
shared_inbox_url -> Nullable<Varchar>,
|
shared_inbox_url -> Nullable<Varchar>,
|
||||||
matrix_user_id -> Nullable<Text>,
|
matrix_user_id -> Nullable<Text>,
|
||||||
admin -> Bool,
|
admin -> Bool,
|
||||||
|
bot_account -> Bool,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,6 +514,7 @@ table! {
|
|||||||
shared_inbox_url -> Nullable<Varchar>,
|
shared_inbox_url -> Nullable<Varchar>,
|
||||||
matrix_user_id -> Nullable<Text>,
|
matrix_user_id -> Nullable<Text>,
|
||||||
admin -> Bool,
|
admin -> Bool,
|
||||||
|
bot_account -> Bool,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ pub struct LocalUser {
|
|||||||
pub show_avatars: bool,
|
pub show_avatars: bool,
|
||||||
pub send_notifications_to_email: bool,
|
pub send_notifications_to_email: bool,
|
||||||
pub validator_time: chrono::NaiveDateTime,
|
pub validator_time: chrono::NaiveDateTime,
|
||||||
|
pub show_bot_accounts: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO redo these, check table defaults
|
// TODO redo these, check table defaults
|
||||||
@ -32,6 +33,7 @@ pub struct LocalUserForm {
|
|||||||
pub lang: Option<String>,
|
pub lang: Option<String>,
|
||||||
pub show_avatars: Option<bool>,
|
pub show_avatars: Option<bool>,
|
||||||
pub send_notifications_to_email: Option<bool>,
|
pub send_notifications_to_email: Option<bool>,
|
||||||
|
pub show_bot_accounts: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A local user view that removes password encrypted
|
/// A local user view that removes password encrypted
|
||||||
@ -49,4 +51,5 @@ pub struct LocalUserSettings {
|
|||||||
pub show_avatars: bool,
|
pub show_avatars: bool,
|
||||||
pub send_notifications_to_email: bool,
|
pub send_notifications_to_email: bool,
|
||||||
pub validator_time: chrono::NaiveDateTime,
|
pub validator_time: chrono::NaiveDateTime,
|
||||||
|
pub show_bot_accounts: bool,
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ pub struct Person {
|
|||||||
pub shared_inbox_url: Option<DbUrl>,
|
pub shared_inbox_url: Option<DbUrl>,
|
||||||
pub matrix_user_id: Option<String>,
|
pub matrix_user_id: Option<String>,
|
||||||
pub admin: bool,
|
pub admin: bool,
|
||||||
|
pub bot_account: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A safe representation of person, without the sensitive info
|
/// A safe representation of person, without the sensitive info
|
||||||
@ -49,6 +50,7 @@ pub struct PersonSafe {
|
|||||||
pub shared_inbox_url: Option<DbUrl>,
|
pub shared_inbox_url: Option<DbUrl>,
|
||||||
pub matrix_user_id: Option<String>,
|
pub matrix_user_id: Option<String>,
|
||||||
pub admin: bool,
|
pub admin: bool,
|
||||||
|
pub bot_account: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
||||||
@ -73,6 +75,7 @@ pub struct PersonAlias1 {
|
|||||||
pub shared_inbox_url: Option<DbUrl>,
|
pub shared_inbox_url: Option<DbUrl>,
|
||||||
pub matrix_user_id: Option<String>,
|
pub matrix_user_id: Option<String>,
|
||||||
pub admin: bool,
|
pub admin: bool,
|
||||||
|
pub bot_account: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
||||||
@ -94,6 +97,7 @@ pub struct PersonSafeAlias1 {
|
|||||||
pub shared_inbox_url: Option<DbUrl>,
|
pub shared_inbox_url: Option<DbUrl>,
|
||||||
pub matrix_user_id: Option<String>,
|
pub matrix_user_id: Option<String>,
|
||||||
pub admin: bool,
|
pub admin: bool,
|
||||||
|
pub bot_account: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
||||||
@ -118,6 +122,7 @@ pub struct PersonAlias2 {
|
|||||||
pub shared_inbox_url: Option<DbUrl>,
|
pub shared_inbox_url: Option<DbUrl>,
|
||||||
pub matrix_user_id: Option<String>,
|
pub matrix_user_id: Option<String>,
|
||||||
pub admin: bool,
|
pub admin: bool,
|
||||||
|
pub bot_account: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
||||||
@ -139,6 +144,7 @@ pub struct PersonSafeAlias2 {
|
|||||||
pub shared_inbox_url: Option<DbUrl>,
|
pub shared_inbox_url: Option<DbUrl>,
|
||||||
pub matrix_user_id: Option<String>,
|
pub matrix_user_id: Option<String>,
|
||||||
pub admin: bool,
|
pub admin: bool,
|
||||||
|
pub bot_account: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Insertable, AsChangeset, Clone, Default)]
|
#[derive(Insertable, AsChangeset, Clone, Default)]
|
||||||
@ -162,4 +168,5 @@ pub struct PersonForm {
|
|||||||
pub shared_inbox_url: Option<Option<DbUrl>>,
|
pub shared_inbox_url: Option<Option<DbUrl>>,
|
||||||
pub matrix_user_id: Option<Option<String>>,
|
pub matrix_user_id: Option<Option<String>>,
|
||||||
pub admin: Option<bool>,
|
pub admin: Option<bool>,
|
||||||
|
pub bot_account: Option<bool>,
|
||||||
}
|
}
|
||||||
|
@ -183,6 +183,7 @@ pub struct CommentQueryBuilder<'a> {
|
|||||||
search_term: Option<String>,
|
search_term: Option<String>,
|
||||||
saved_only: bool,
|
saved_only: bool,
|
||||||
unread_only: bool,
|
unread_only: bool,
|
||||||
|
show_bot_accounts: bool,
|
||||||
page: Option<i64>,
|
page: Option<i64>,
|
||||||
limit: Option<i64>,
|
limit: Option<i64>,
|
||||||
}
|
}
|
||||||
@ -202,6 +203,7 @@ impl<'a> CommentQueryBuilder<'a> {
|
|||||||
search_term: None,
|
search_term: None,
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
unread_only: false,
|
unread_only: false,
|
||||||
|
show_bot_accounts: true,
|
||||||
page: None,
|
page: None,
|
||||||
limit: None,
|
limit: None,
|
||||||
}
|
}
|
||||||
@ -262,6 +264,11 @@ impl<'a> CommentQueryBuilder<'a> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn show_bot_accounts(mut self, show_bot_accounts: bool) -> Self {
|
||||||
|
self.show_bot_accounts = show_bot_accounts;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn page<T: MaybeOptional<i64>>(mut self, page: T) -> Self {
|
pub fn page<T: MaybeOptional<i64>>(mut self, page: T) -> Self {
|
||||||
self.page = page.get_optional();
|
self.page = page.get_optional();
|
||||||
self
|
self
|
||||||
@ -380,6 +387,10 @@ impl<'a> CommentQueryBuilder<'a> {
|
|||||||
query = query.filter(comment_saved::id.is_not_null());
|
query = query.filter(comment_saved::id.is_not_null());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !self.show_bot_accounts {
|
||||||
|
query = query.filter(person::bot_account.eq(false));
|
||||||
|
};
|
||||||
|
|
||||||
query = match self.sort {
|
query = match self.sort {
|
||||||
SortType::Hot | SortType::Active => query
|
SortType::Hot | SortType::Active => query
|
||||||
.order_by(hot_rank(comment_aggregates::score, comment_aggregates::published).desc())
|
.order_by(hot_rank(comment_aggregates::score, comment_aggregates::published).desc())
|
||||||
@ -527,6 +538,7 @@ mod tests {
|
|||||||
banned: false,
|
banned: false,
|
||||||
deleted: false,
|
deleted: false,
|
||||||
admin: false,
|
admin: false,
|
||||||
|
bot_account: false,
|
||||||
bio: None,
|
bio: None,
|
||||||
banner: None,
|
banner: None,
|
||||||
updated: None,
|
updated: None,
|
||||||
|
@ -164,6 +164,7 @@ pub struct PostQueryBuilder<'a> {
|
|||||||
search_term: Option<String>,
|
search_term: Option<String>,
|
||||||
url_search: Option<String>,
|
url_search: Option<String>,
|
||||||
show_nsfw: bool,
|
show_nsfw: bool,
|
||||||
|
show_bot_accounts: bool,
|
||||||
saved_only: bool,
|
saved_only: bool,
|
||||||
unread_only: bool,
|
unread_only: bool,
|
||||||
page: Option<i64>,
|
page: Option<i64>,
|
||||||
@ -183,6 +184,7 @@ impl<'a> PostQueryBuilder<'a> {
|
|||||||
search_term: None,
|
search_term: None,
|
||||||
url_search: None,
|
url_search: None,
|
||||||
show_nsfw: true,
|
show_nsfw: true,
|
||||||
|
show_bot_accounts: true,
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
unread_only: false,
|
unread_only: false,
|
||||||
page: None,
|
page: None,
|
||||||
@ -235,6 +237,11 @@ impl<'a> PostQueryBuilder<'a> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn show_bot_accounts(mut self, show_bot_accounts: bool) -> Self {
|
||||||
|
self.show_bot_accounts = show_bot_accounts;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn saved_only(mut self, saved_only: bool) -> Self {
|
pub fn saved_only(mut self, saved_only: bool) -> Self {
|
||||||
self.saved_only = saved_only;
|
self.saved_only = saved_only;
|
||||||
self
|
self
|
||||||
@ -351,6 +358,10 @@ impl<'a> PostQueryBuilder<'a> {
|
|||||||
.filter(community::nsfw.eq(false));
|
.filter(community::nsfw.eq(false));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if !self.show_bot_accounts {
|
||||||
|
query = query.filter(person::bot_account.eq(false));
|
||||||
|
};
|
||||||
|
|
||||||
// TODO These two might be wrong
|
// TODO These two might be wrong
|
||||||
if self.saved_only {
|
if self.saved_only {
|
||||||
query = query.filter(post_saved::id.is_not_null());
|
query = query.filter(post_saved::id.is_not_null());
|
||||||
@ -451,6 +462,7 @@ mod tests {
|
|||||||
let person_name = "tegan".to_string();
|
let person_name = "tegan".to_string();
|
||||||
let community_name = "test_community_3".to_string();
|
let community_name = "test_community_3".to_string();
|
||||||
let post_name = "test post 3".to_string();
|
let post_name = "test post 3".to_string();
|
||||||
|
let bot_post_name = "test bot post".to_string();
|
||||||
|
|
||||||
let new_person = PersonForm {
|
let new_person = PersonForm {
|
||||||
name: person_name.to_owned(),
|
name: person_name.to_owned(),
|
||||||
@ -459,6 +471,14 @@ mod tests {
|
|||||||
|
|
||||||
let inserted_person = Person::create(&conn, &new_person).unwrap();
|
let inserted_person = Person::create(&conn, &new_person).unwrap();
|
||||||
|
|
||||||
|
let new_bot = PersonForm {
|
||||||
|
name: person_name.to_owned(),
|
||||||
|
bot_account: Some(true),
|
||||||
|
..PersonForm::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let inserted_bot = Person::create(&conn, &new_bot).unwrap();
|
||||||
|
|
||||||
let new_community = CommunityForm {
|
let new_community = CommunityForm {
|
||||||
name: community_name.to_owned(),
|
name: community_name.to_owned(),
|
||||||
title: "nada".to_owned(),
|
title: "nada".to_owned(),
|
||||||
@ -477,6 +497,15 @@ mod tests {
|
|||||||
|
|
||||||
let inserted_post = Post::create(&conn, &new_post).unwrap();
|
let inserted_post = Post::create(&conn, &new_post).unwrap();
|
||||||
|
|
||||||
|
let new_bot_post = PostForm {
|
||||||
|
name: bot_post_name.to_owned(),
|
||||||
|
creator_id: inserted_bot.id,
|
||||||
|
community_id: inserted_community.id,
|
||||||
|
..PostForm::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let _inserted_bot_post = Post::create(&conn, &new_bot_post).unwrap();
|
||||||
|
|
||||||
let post_like_form = PostLikeForm {
|
let post_like_form = PostLikeForm {
|
||||||
post_id: inserted_post.id,
|
post_id: inserted_post.id,
|
||||||
person_id: inserted_person.id,
|
person_id: inserted_person.id,
|
||||||
@ -496,6 +525,7 @@ mod tests {
|
|||||||
let read_post_listings_with_person = PostQueryBuilder::create(&conn)
|
let read_post_listings_with_person = PostQueryBuilder::create(&conn)
|
||||||
.listing_type(&ListingType::Community)
|
.listing_type(&ListingType::Community)
|
||||||
.sort(&SortType::New)
|
.sort(&SortType::New)
|
||||||
|
.show_bot_accounts(false)
|
||||||
.community_id(inserted_community.id)
|
.community_id(inserted_community.id)
|
||||||
.my_person_id(inserted_person.id)
|
.my_person_id(inserted_person.id)
|
||||||
.list()
|
.list()
|
||||||
@ -547,6 +577,7 @@ mod tests {
|
|||||||
actor_id: inserted_person.actor_id.to_owned(),
|
actor_id: inserted_person.actor_id.to_owned(),
|
||||||
local: true,
|
local: true,
|
||||||
admin: false,
|
admin: false,
|
||||||
|
bot_account: false,
|
||||||
banned: false,
|
banned: false,
|
||||||
deleted: false,
|
deleted: false,
|
||||||
bio: None,
|
bio: None,
|
||||||
@ -598,6 +629,7 @@ mod tests {
|
|||||||
let num_deleted = Post::delete(&conn, inserted_post.id).unwrap();
|
let num_deleted = Post::delete(&conn, inserted_post.id).unwrap();
|
||||||
Community::delete(&conn, inserted_community.id).unwrap();
|
Community::delete(&conn, inserted_community.id).unwrap();
|
||||||
Person::delete(&conn, inserted_person.id).unwrap();
|
Person::delete(&conn, inserted_person.id).unwrap();
|
||||||
|
Person::delete(&conn, inserted_bot.id).unwrap();
|
||||||
|
|
||||||
// The with user
|
// The with user
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -608,18 +640,20 @@ mod tests {
|
|||||||
expected_post_listing_with_user,
|
expected_post_listing_with_user,
|
||||||
read_post_listing_with_person
|
read_post_listing_with_person
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Should be only one person, IE the bot post should be missing
|
||||||
assert_eq!(1, read_post_listings_with_person.len());
|
assert_eq!(1, read_post_listings_with_person.len());
|
||||||
|
|
||||||
// Without the user
|
// Without the user
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
expected_post_listing_no_person,
|
expected_post_listing_no_person,
|
||||||
read_post_listings_no_person[0]
|
read_post_listings_no_person[1]
|
||||||
);
|
);
|
||||||
assert_eq!(expected_post_listing_no_person, read_post_listing_no_person);
|
assert_eq!(expected_post_listing_no_person, read_post_listing_no_person);
|
||||||
assert_eq!(1, read_post_listings_no_person.len());
|
|
||||||
|
|
||||||
// assert_eq!(expected_post, inserted_post);
|
// Should be 2 posts, with the bot post
|
||||||
// assert_eq!(expected_post, updated_post);
|
assert_eq!(2, read_post_listings_no_person.len());
|
||||||
|
|
||||||
assert_eq!(expected_post_like, inserted_post_like);
|
assert_eq!(expected_post_like, inserted_post_like);
|
||||||
assert_eq!(1, like_removed);
|
assert_eq!(1, like_removed);
|
||||||
assert_eq!(1, num_deleted);
|
assert_eq!(1, num_deleted);
|
||||||
|
@ -228,11 +228,14 @@ fn get_feed_front(
|
|||||||
) -> Result<ChannelBuilder, LemmyError> {
|
) -> Result<ChannelBuilder, LemmyError> {
|
||||||
let site_view = SiteView::read(&conn)?;
|
let site_view = SiteView::read(&conn)?;
|
||||||
let local_user_id = LocalUserId(Claims::decode(&jwt)?.claims.sub);
|
let local_user_id = LocalUserId(Claims::decode(&jwt)?.claims.sub);
|
||||||
let person_id = LocalUser::read(&conn, local_user_id)?.person_id;
|
let local_user = LocalUser::read(&conn, local_user_id)?;
|
||||||
|
let person_id = local_user.person_id;
|
||||||
|
let show_bot_accounts = local_user.show_bot_accounts;
|
||||||
|
|
||||||
let posts = PostQueryBuilder::create(&conn)
|
let posts = PostQueryBuilder::create(&conn)
|
||||||
.listing_type(&ListingType::Subscribed)
|
.listing_type(&ListingType::Subscribed)
|
||||||
.my_person_id(person_id)
|
.my_person_id(person_id)
|
||||||
|
.show_bot_accounts(show_bot_accounts)
|
||||||
.sort(sort_type)
|
.sort(sort_type)
|
||||||
.list()?;
|
.list()?;
|
||||||
|
|
||||||
@ -255,13 +258,16 @@ fn get_feed_front(
|
|||||||
fn get_feed_inbox(conn: &PgConnection, jwt: String) -> Result<ChannelBuilder, LemmyError> {
|
fn get_feed_inbox(conn: &PgConnection, jwt: String) -> Result<ChannelBuilder, LemmyError> {
|
||||||
let site_view = SiteView::read(&conn)?;
|
let site_view = SiteView::read(&conn)?;
|
||||||
let local_user_id = LocalUserId(Claims::decode(&jwt)?.claims.sub);
|
let local_user_id = LocalUserId(Claims::decode(&jwt)?.claims.sub);
|
||||||
let person_id = LocalUser::read(&conn, local_user_id)?.person_id;
|
let local_user = LocalUser::read(&conn, local_user_id)?;
|
||||||
|
let person_id = local_user.person_id;
|
||||||
|
let show_bot_accounts = local_user.show_bot_accounts;
|
||||||
|
|
||||||
let sort = SortType::New;
|
let sort = SortType::New;
|
||||||
|
|
||||||
let replies = CommentQueryBuilder::create(&conn)
|
let replies = CommentQueryBuilder::create(&conn)
|
||||||
.recipient_id(person_id)
|
.recipient_id(person_id)
|
||||||
.my_person_id(person_id)
|
.my_person_id(person_id)
|
||||||
|
.show_bot_accounts(show_bot_accounts)
|
||||||
.sort(&sort)
|
.sort(&sort)
|
||||||
.list()?;
|
.list()?;
|
||||||
|
|
||||||
|
6
migrations/2021-03-31-105915_add_bot_account/down.sql
Normal file
6
migrations/2021-03-31-105915_add_bot_account/down.sql
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
drop view person_alias_1, person_alias_2;
|
||||||
|
alter table person drop column bot_account;
|
||||||
|
create view person_alias_1 as select * from person;
|
||||||
|
create view person_alias_2 as select * from person;
|
||||||
|
|
||||||
|
alter table local_user drop column show_bot_accounts;
|
8
migrations/2021-03-31-105915_add_bot_account/up.sql
Normal file
8
migrations/2021-03-31-105915_add_bot_account/up.sql
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
-- Add the bot_account column to the person table
|
||||||
|
drop view person_alias_1, person_alias_2;
|
||||||
|
alter table person add column bot_account boolean not null default false;
|
||||||
|
create view person_alias_1 as select * from person;
|
||||||
|
create view person_alias_2 as select * from person;
|
||||||
|
|
||||||
|
-- Add the show_bot_accounts to the local user table as a setting
|
||||||
|
alter table local_user add column show_bot_accounts boolean not null default true;
|
Loading…
Reference in New Issue
Block a user