1 use crate::newtypes::{CommunityId, DbUrl, PersonId};
2 use diesel::{result::Error, PgConnection};
7 fn create(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
10 fn read(conn: &mut PgConnection, id: Self::IdType) -> Result<Self, Error>
13 fn update(conn: &mut PgConnection, id: Self::IdType, form: &Self::Form) -> Result<Self, Error>
16 fn delete(_conn: &mut PgConnection, _id: Self::IdType) -> Result<usize, Error>
24 pub trait Followable {
26 fn follow(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
30 conn: &mut PgConnection,
31 community_id: CommunityId,
33 ) -> Result<Self, Error>
36 fn unfollow(conn: &mut PgConnection, form: &Self::Form) -> Result<usize, Error>
39 fn has_local_followers(conn: &mut PgConnection, community_id: CommunityId)
40 -> Result<bool, Error>;
45 fn join(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
48 fn leave(conn: &mut PgConnection, form: &Self::Form) -> Result<usize, Error>
56 fn like(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
60 conn: &mut PgConnection,
62 item_id: Self::IdType,
63 ) -> Result<usize, Error>
70 fn ban(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
73 fn unban(conn: &mut PgConnection, form: &Self::Form) -> Result<usize, Error>
80 fn save(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
83 fn unsave(conn: &mut PgConnection, form: &Self::Form) -> Result<usize, Error>
90 fn block(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
93 fn unblock(conn: &mut PgConnection, form: &Self::Form) -> Result<usize, Error>
100 fn mark_as_read(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
103 fn mark_as_unread(conn: &mut PgConnection, form: &Self::Form) -> Result<usize, Error>
108 pub trait Reportable {
111 fn report(conn: &mut PgConnection, form: &Self::Form) -> Result<Self, Error>
115 conn: &mut PgConnection,
116 report_id: Self::IdType,
117 resolver_id: PersonId,
118 ) -> Result<usize, Error>
122 conn: &mut PgConnection,
123 report_id: Self::IdType,
124 resolver_id: PersonId,
125 ) -> Result<usize, Error>
130 pub trait DeleteableOrRemoveable {
131 fn blank_out_deleted_or_removed_info(self) -> Self;
136 fn safe_columns_tuple() -> Self::SafeColumns;
139 pub trait ToSafeSettings {
140 type SafeSettingsColumns;
141 fn safe_settings_columns_tuple() -> Self::SafeSettingsColumns;
144 pub trait ViewToVec {
146 fn from_tuple_to_vec(tuple: Vec<Self::DbTuple>) -> Vec<Self>
151 pub trait ApubActor {
152 // TODO: this should be in a trait ApubObject (and implemented for Post, Comment, PrivateMessage as well)
153 fn read_from_apub_id(conn: &mut PgConnection, object_id: &DbUrl) -> Result<Option<Self>, Error>
156 /// - actor_name is the name of the community or user to read.
157 /// - include_deleted, if true, will return communities or users that were deleted/removed
159 conn: &mut PgConnection,
161 include_deleted: bool,
162 ) -> Result<Self, Error>
165 fn read_from_name_and_domain(
166 conn: &mut PgConnection,
168 protocol_domain: &str,
169 ) -> Result<Self, Error>