1 use crate::newtypes::{CommunityId, PersonId};
2 use diesel::{result::Error, PgConnection};
8 fn create(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
11 fn read(conn: &PgConnection, id: Self::IdType) -> Result<Self, Error>
14 fn update(conn: &PgConnection, id: Self::IdType, form: &Self::Form) -> Result<Self, Error>
17 fn delete(_conn: &PgConnection, _id: Self::IdType) -> Result<usize, Error>
25 pub trait Followable {
27 fn follow(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
32 community_id: CommunityId,
34 ) -> Result<Self, Error>
37 fn unfollow(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
40 fn has_local_followers(conn: &PgConnection, community_id: CommunityId) -> Result<bool, Error>;
45 fn join(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
48 fn leave(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
56 fn like(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
62 item_id: Self::IdType,
63 ) -> Result<usize, Error>
70 fn ban(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
73 fn unban(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
80 fn save(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
83 fn unsave(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
90 fn block(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
93 fn unblock(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
100 fn mark_as_read(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
103 fn mark_as_unread(conn: &PgConnection, form: &Self::Form) -> Result<usize, Error>
108 pub trait Reportable {
111 fn report(conn: &PgConnection, form: &Self::Form) -> Result<Self, Error>
116 report_id: Self::IdType,
117 resolver_id: PersonId,
118 ) -> Result<usize, Error>
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;
134 pub trait MaybeOptional<T> {
135 fn get_optional(self) -> Option<T>;
138 impl<T> MaybeOptional<T> for T {
139 fn get_optional(self) -> Option<T> {
144 impl<T> MaybeOptional<T> for Option<T> {
145 fn get_optional(self) -> Option<T> {
152 fn safe_columns_tuple() -> Self::SafeColumns;
155 pub trait ToSafeSettings {
156 type SafeSettingsColumns;
157 fn safe_settings_columns_tuple() -> Self::SafeSettingsColumns;
160 pub trait ViewToVec {
162 fn from_tuple_to_vec(tuple: Vec<Self::DbTuple>) -> Vec<Self>
167 pub trait ApubActor {
168 // TODO: this should be in a trait ApubObject (and implemented for Post, Comment, PrivateMessage as well)
169 fn read_from_apub_id(conn: &PgConnection, object_id: Url) -> Result<Option<Self>, Error>
172 fn read_from_name(conn: &PgConnection, actor_name: &str) -> Result<Self, Error>
175 fn read_from_name_and_domain(
178 protocol_domain: &str,
179 ) -> Result<Self, Error>