1 use crate::newtypes::{CommunityId, DbUrl, PersonId};
2 use diesel::{result::Error, PgConnection};
8 fn create(conn: &mut PgConnection, form: &Self::InsertForm) -> Result<Self, Error>
11 fn read(conn: &mut PgConnection, id: Self::IdType) -> Result<Self, Error>
14 /// when you want to null out a column, you have to send Some(None)), since sending None means you just don't want to update that column.
16 conn: &mut PgConnection,
18 form: &Self::UpdateForm,
19 ) -> Result<Self, Error>
22 fn delete(_conn: &mut PgConnection, _id: Self::IdType) -> Result<usize, Error>
30 pub trait Followable {
32 fn follow(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
36 conn: &mut PgConnection,
37 community_id: CommunityId,
39 ) -> Result<Self, Error>
42 fn unfollow(conn: &mut PgConnection, form: &Self::Form) -> Result<usize, Error>
45 fn has_local_followers(conn: &mut PgConnection, community_id: CommunityId)
46 -> Result<bool, Error>;
51 fn join(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
54 fn leave(conn: &mut PgConnection, form: &Self::Form) -> Result<usize, Error>
62 fn like(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
66 conn: &mut PgConnection,
68 item_id: Self::IdType,
69 ) -> Result<usize, Error>
76 fn ban(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
79 fn unban(conn: &mut PgConnection, form: &Self::Form) -> Result<usize, Error>
86 fn save(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
89 fn unsave(conn: &mut PgConnection, form: &Self::Form) -> Result<usize, Error>
96 fn block(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
99 fn unblock(conn: &mut PgConnection, form: &Self::Form) -> Result<usize, Error>
106 fn mark_as_read(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
109 fn mark_as_unread(conn: &mut PgConnection, form: &Self::Form) -> Result<usize, Error>
114 pub trait Reportable {
117 fn report(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
121 conn: &mut PgConnection,
122 report_id: Self::IdType,
123 resolver_id: PersonId,
124 ) -> Result<usize, Error>
128 conn: &mut PgConnection,
129 report_id: Self::IdType,
130 resolver_id: PersonId,
131 ) -> Result<usize, Error>
136 pub trait DeleteableOrRemoveable {
137 fn blank_out_deleted_or_removed_info(self) -> Self;
142 fn safe_columns_tuple() -> Self::SafeColumns;
145 pub trait ToSafeSettings {
146 type SafeSettingsColumns;
147 fn safe_settings_columns_tuple() -> Self::SafeSettingsColumns;
150 pub trait ViewToVec {
152 fn from_tuple_to_vec(tuple: Vec<Self::DbTuple>) -> Vec<Self>
157 pub trait ApubActor {
158 // TODO: this should be in a trait ApubObject (and implemented for Post, Comment, PrivateMessage as well)
159 fn read_from_apub_id(conn: &mut PgConnection, object_id: &DbUrl) -> Result<Option<Self>, Error>
162 /// - actor_name is the name of the community or user to read.
163 /// - include_deleted, if true, will return communities or users that were deleted/removed
165 conn: &mut PgConnection,
167 include_deleted: bool,
168 ) -> Result<Self, Error>
171 fn read_from_name_and_domain(
172 conn: &mut PgConnection,
174 protocol_domain: &str,
175 ) -> Result<Self, Error>