2 newtypes::{CommunityId, DbUrl, PersonId},
5 use diesel::result::Error;
12 async fn create(pool: &DbPool, form: &Self::InsertForm) -> Result<Self, Error>
15 async fn read(pool: &DbPool, id: Self::IdType) -> Result<Self, Error>
18 /// 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.
19 async fn update(pool: &DbPool, id: Self::IdType, form: &Self::UpdateForm) -> Result<Self, Error>
22 async fn delete(_pool: &DbPool, _id: Self::IdType) -> Result<usize, Error>
27 async { Err(Error::NotFound) }.await
32 pub trait Followable {
34 async fn follow(pool: &DbPool, form: &Self::Form) -> Result<Self, Error>
37 async fn follow_accepted(
39 community_id: CommunityId,
41 ) -> Result<Self, Error>
44 async fn unfollow(pool: &DbPool, form: &Self::Form) -> Result<usize, Error>
52 async fn join(pool: &DbPool, form: &Self::Form) -> Result<Self, Error>
55 async fn leave(pool: &DbPool, form: &Self::Form) -> Result<usize, Error>
64 async fn like(pool: &DbPool, form: &Self::Form) -> Result<Self, Error>
70 item_id: Self::IdType,
71 ) -> Result<usize, Error>
79 async fn ban(pool: &DbPool, form: &Self::Form) -> Result<Self, Error>
82 async fn unban(pool: &DbPool, form: &Self::Form) -> Result<usize, Error>
90 async fn save(pool: &DbPool, form: &Self::Form) -> Result<Self, Error>
93 async fn unsave(pool: &DbPool, form: &Self::Form) -> Result<usize, Error>
101 async fn block(pool: &DbPool, form: &Self::Form) -> Result<Self, Error>
104 async fn unblock(pool: &DbPool, form: &Self::Form) -> Result<usize, Error>
112 async fn mark_as_read(pool: &DbPool, form: &Self::Form) -> Result<Self, Error>
115 async fn mark_as_unread(pool: &DbPool, form: &Self::Form) -> Result<usize, Error>
121 pub trait Reportable {
124 async fn report(pool: &DbPool, form: &Self::Form) -> Result<Self, Error>
129 report_id: Self::IdType,
130 resolver_id: PersonId,
131 ) -> Result<usize, Error>
136 report_id: Self::IdType,
137 resolver_id: PersonId,
138 ) -> Result<usize, Error>
145 fn safe_columns_tuple() -> Self::SafeColumns;
148 pub trait ToSafeSettings {
149 type SafeSettingsColumns;
150 fn safe_settings_columns_tuple() -> Self::SafeSettingsColumns;
153 pub trait ViewToVec {
155 fn from_tuple_to_vec(tuple: Vec<Self::DbTuple>) -> Vec<Self>
161 pub trait ApubActor {
162 // TODO: this should be in a trait ApubObject (and implemented for Post, Comment, PrivateMessage as well)
163 async fn read_from_apub_id(pool: &DbPool, object_id: &DbUrl) -> Result<Option<Self>, Error>
166 /// - actor_name is the name of the community or user to read.
167 /// - include_deleted, if true, will return communities or users that were deleted/removed
168 async fn read_from_name(
171 include_deleted: bool,
172 ) -> Result<Self, Error>
175 async fn read_from_name_and_domain(
178 protocol_domain: &str,
179 ) -> Result<Self, Error>