1 use crate::newtypes::{CommunityId, DbUrl, PersonId};
2 use diesel::{result::Error, PgConnection};
7 fn create(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
10 fn read(conn: &PgConnection, id: Self::IdType) -> Result<Self, Error>
13 fn update(conn: &PgConnection, id: Self::IdType, form: &Self::Form) -> Result<Self, Error>
16 fn delete(_conn: &PgConnection, _id: Self::IdType) -> Result<usize, Error>
24 pub trait Followable {
26 fn follow(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
31 community_id: CommunityId,
33 ) -> Result<Self, Error>
36 fn unfollow(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
39 fn has_local_followers(conn: &PgConnection, community_id: CommunityId) -> Result<bool, Error>;
44 fn join(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
47 fn leave(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
55 fn like(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
61 item_id: Self::IdType,
62 ) -> Result<usize, Error>
69 fn ban(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
72 fn unban(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
79 fn save(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
82 fn unsave(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
89 fn block(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
92 fn unblock(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
99 fn mark_as_read(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
102 fn mark_as_unread(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
107 pub trait Reportable {
110 fn report(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
115 report_id: Self::IdType,
116 resolver_id: PersonId,
117 ) -> Result<usize, Error>
122 report_id: Self::IdType,
123 resolver_id: PersonId,
124 ) -> Result<usize, Error>
129 pub trait DeleteableOrRemoveable {
130 fn blank_out_deleted_or_removed_info(self) -> Self;
135 fn safe_columns_tuple() -> Self::SafeColumns;
138 pub trait ToSafeSettings {
139 type SafeSettingsColumns;
140 fn safe_settings_columns_tuple() -> Self::SafeSettingsColumns;
143 pub trait ViewToVec {
145 fn from_tuple_to_vec(tuple: Vec<Self::DbTuple>) -> Vec<Self>
150 pub trait ApubActor {
151 // TODO: this should be in a trait ApubObject (and implemented for Post, Comment, PrivateMessage as well)
152 fn read_from_apub_id(conn: &PgConnection, object_id: &DbUrl) -> Result<Option<Self>, Error>
155 /// - actor_name is the name of the community or user to read.
156 /// - include_deleted, if true, will return communities or users that were deleted/removed
160 include_deleted: bool,
161 ) -> Result<Self, Error>
164 fn read_from_name_and_domain(
167 protocol_domain: &str,
168 ) -> Result<Self, Error>