if resolved {
CommentReport::resolve(conn, report_id.clone(), user_id)
} else {
- CommentReport::unresolve(conn, report_id.clone())
+ CommentReport::unresolve(conn, report_id.clone(), user_id)
}
};
}
}
-// is this the right place for this?
#[async_trait::async_trait(?Send)]
impl Perform for ModJoin {
type Response = ModJoinResponse;
if resolved {
PostReport::resolve(conn, report_id.clone(), user_id)
} else {
- PostReport::unresolve(conn, report_id.clone())
+ PostReport::unresolve(conn, report_id.clone(), user_id)
}
};
post_id -> Int4,
current_comment_text -> Text,
community_id -> Int4,
+ creator_actor_id -> Text,
creator_name -> Varchar,
+ creator_preferred_username -> Nullable<Varchar>,
+ creator_avatar -> Nullable<Text>,
+ creator_local -> Bool,
comment_creator_id -> Int4,
+ comment_creator_actor_id -> Text,
comment_creator_name -> Varchar,
+ comment_creator_preferred_username -> Nullable<Varchar>,
+ comment_creator_avatar -> Nullable<Text>,
+ comment_creator_local -> Bool,
+ resolver_actor_id -> Nullable<Text>,
+ resolver_name -> Nullable<Varchar>,
+ resolver_preferred_username -> Nullable<Varchar>,
+ resolver_avatar -> Nullable<Text>,
+ resolver_local -> Nullable<Bool>,
}
}
.get_result::<Self>(conn)
}
- fn resolve(conn: &PgConnection, report_id: i32, by_user_id: i32) -> Result<usize, Error> {
+ fn resolve(conn: &PgConnection, report_id: i32, by_resolver_id: i32) -> Result<usize, Error> {
use crate::schema::comment_report::dsl::*;
update(comment_report.find(report_id))
.set((
resolved.eq(true),
- resolver_id.eq(by_user_id),
+ resolver_id.eq(by_resolver_id),
updated.eq(naive_now()),
))
.execute(conn)
}
- fn unresolve(conn: &PgConnection, report_id: i32) -> Result<usize, Error> {
+ fn unresolve(conn: &PgConnection, report_id: i32, by_resolver_id: i32) -> Result<usize, Error> {
use crate::schema::comment_report::dsl::*;
update(comment_report.find(report_id))
.set((
resolved.eq(false),
+ resolver_id.eq(by_resolver_id),
updated.eq(naive_now()),
))
.execute(conn)
pub post_id: i32,
pub current_comment_text: String,
pub community_id: i32,
+ pub creator_actor_id: String,
pub creator_name: String,
+ pub creator_preferred_username: Option<String>,
+ pub creator_avatar: Option<String>,
+ pub creator_local: bool,
pub comment_creator_id: i32,
+ pub comment_creator_actor_id: String,
pub comment_creator_name: String,
+ pub comment_creator_preferred_username: Option<String>,
+ pub comment_creator_avatar: Option<String>,
+ pub comment_creator_local: bool,
+ pub resolver_actor_id: Option<String>,
+ pub resolver_name: Option<String>,
+ pub resolver_preferred_username: Option<String>,
+ pub resolver_avatar: Option<String>,
+ pub resolver_local: Option<bool>,
}
pub struct CommentReportQueryBuilder<'a> {
fn report(conn: &PgConnection, form: &T) -> Result<Self, Error>
where
Self: Sized;
- fn resolve(conn: &PgConnection, report_id: i32, user_id: i32) -> Result<usize, Error>
+ fn resolve(conn: &PgConnection, report_id: i32, resolver_id: i32) -> Result<usize, Error>
where
Self: Sized;
- fn unresolve(conn: &PgConnection, report_id: i32) -> Result<usize, Error>
+ fn unresolve(conn: &PgConnection, report_id: i32, resolver_id: i32) -> Result<usize, Error>
where
Self: Sized;
}
current_post_url -> Nullable<Text>,
current_post_body -> Nullable<Text>,
community_id -> Int4,
+ creator_actor_id -> Text,
creator_name -> Varchar,
+ creator_preferred_username -> Nullable<Varchar>,
+ creator_avatar -> Nullable<Text>,
+ creator_local -> Bool,
post_creator_id -> Int4,
+ post_creator_actor_id -> Text,
post_creator_name -> Varchar,
+ post_creator_preferred_username -> Nullable<Varchar>,
+ post_creator_avatar -> Nullable<Text>,
+ post_creator_local -> Bool,
+ resolver_actor_id -> Nullable<Text>,
+ resolver_name -> Nullable<Varchar>,
+ resolver_preferred_username -> Nullable<Varchar>,
+ resolver_avatar -> Nullable<Text>,
+ resolver_local -> Nullable<Bool>,
}
}
.get_result::<Self>(conn)
}
- fn resolve(conn: &PgConnection, report_id: i32, by_user_id: i32) -> Result<usize, Error> {
+ fn resolve(conn: &PgConnection, report_id: i32, by_resolver_id: i32) -> Result<usize, Error> {
use crate::schema::post_report::dsl::*;
update(post_report.find(report_id))
.set((
resolved.eq(true),
- resolver_id.eq(by_user_id),
+ resolver_id.eq(by_resolver_id),
updated.eq(naive_now()),
))
.execute(conn)
}
- fn unresolve(conn: &PgConnection, report_id: i32) -> Result<usize, Error> {
+ fn unresolve(conn: &PgConnection, report_id: i32, by_resolver_id: i32) -> Result<usize, Error> {
use crate::schema::post_report::dsl::*;
update(post_report.find(report_id))
.set((
resolved.eq(false),
+ resolver_id.eq(by_resolver_id),
updated.eq(naive_now()),
))
.execute(conn)
pub current_post_url: Option<String>,
pub current_post_body: Option<String>,
pub community_id: i32,
+ pub creator_actor_id: String,
pub creator_name: String,
+ pub creator_preferred_username: Option<String>,
+ pub creator_avatar: Option<String>,
+ pub creator_local: bool,
pub post_creator_id: i32,
+ pub post_creator_actor_id: String,
pub post_creator_name: String,
+ pub post_creator_preferred_username: Option<String>,
+ pub post_creator_avatar: Option<String>,
+ pub post_creator_local: bool,
+ pub resolver_actor_id: Option<String>,
+ pub resolver_name: Option<String>,
+ pub resolver_preferred_username: Option<String>,
+ pub resolver_avatar: Option<String>,
+ pub resolver_local: Option<bool>,
}
impl PostReportView {
c.post_id,
c.content as current_comment_text,
p.community_id,
+-- report creator details
+f.actor_id as creator_actor_id,
f.name as creator_name,
+f.preferred_username as creator_preferred_username,
+f.avatar as creator_avatar,
+f.local as creator_local,
+-- comment creator details
u.id as comment_creator_id,
-u.name as comment_creator_name
+u.actor_id as comment_creator_actor_id,
+u.name as comment_creator_name,
+u.preferred_username as comment_creator_preferred_username,
+u.avatar as comment_creator_avatar,
+u.local as comment_creator_local,
+-- resolver details
+r.actor_id as resolver_actor_id,
+r.name as resolver_name,
+r.preferred_username as resolver_preferred_username,
+r.avatar as resolver_avatar,
+r.local as resolver_local
from comment_report cr
left join comment c on c.id = cr.comment_id
left join post p on p.id = c.post_id
left join user_ u on u.id = c.creator_id
left join user_ f on f.id = cr.creator_id;
+left join user_ r on r.id = cr.resolver_id;
create or replace view post_report_view as
select pr.*,
p.body as current_post_body,
p.community_id,
f.name as creator_name,
+-- report creator details
+f.actor_id as creator_actor_id,
+f.name as creator_name,
+f.preferred_username as creator_preferred_username,
+f.avatar as creator_avatar,
+f.local as creator_local,
+-- post creator details
u.id as post_creator_id,
-u.name as post_creator_name
+u.actor_id as post_creator_actor_id,
+u.name as post_creator_name,
+u.preferred_username as post_creator_preferred_username,
+u.avatar as post_creator_avatar,
+u.local as post_creator_local,
+-- resolver details
+r.actor_id as resolver_actor_id,
+r.name as resolver_name,
+r.preferred_username as resolver_preferred_username,
+r.avatar as resolver_avatar,
+r.local as resolver_local
from post_report pr
left join post p on p.id = pr.post_id
left join user_ u on u.id = p.creator_id
left join user_ f on f.id = pr.creator_id;
+left join user_ r on r.id = pr.resolver_id;