2 newtypes::{CommunityId, DbUrl, PersonId},
5 use diesel::result::Error;
12 async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error>
15 async fn read(pool: &mut 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.
20 pool: &mut DbPool<'_>,
22 form: &Self::UpdateForm,
23 ) -> Result<Self, Error>
26 async fn delete(_pool: &mut DbPool<'_>, _id: Self::IdType) -> Result<usize, Error>
31 async { Err(Error::NotFound) }.await
36 pub trait Followable {
38 async fn follow(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<Self, Error>
41 async fn follow_accepted(
42 pool: &mut DbPool<'_>,
43 community_id: CommunityId,
45 ) -> Result<Self, Error>
48 async fn unfollow(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<usize, Error>
56 async fn join(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<Self, Error>
59 async fn leave(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<usize, Error>
68 async fn like(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<Self, Error>
72 pool: &mut DbPool<'_>,
74 item_id: Self::IdType,
75 ) -> Result<usize, Error>
83 async fn ban(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<Self, Error>
86 async fn unban(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<usize, Error>
94 async fn save(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<Self, Error>
97 async fn unsave(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<usize, Error>
103 pub trait Blockable {
105 async fn block(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<Self, Error>
108 async fn unblock(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<usize, Error>
116 async fn mark_as_read(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<Self, Error>
119 async fn mark_as_unread(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<usize, Error>
125 pub trait Reportable {
128 async fn report(pool: &mut DbPool<'_>, form: &Self::Form) -> Result<Self, Error>
132 pool: &mut DbPool<'_>,
133 report_id: Self::IdType,
134 resolver_id: PersonId,
135 ) -> Result<usize, Error>
139 pool: &mut DbPool<'_>,
140 report_id: Self::IdType,
141 resolver_id: PersonId,
142 ) -> Result<usize, Error>
149 fn from_tuple(tuple: Self::JoinTuple) -> Self
155 pub trait ApubActor {
156 async fn read_from_apub_id(
157 pool: &mut DbPool<'_>,
159 ) -> 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
164 async fn read_from_name(
165 pool: &mut DbPool<'_>,
167 include_deleted: bool,
168 ) -> Result<Self, Error>
171 async fn read_from_name_and_domain(
172 pool: &mut DbPool<'_>,
174 protocol_domain: &str,
175 ) -> Result<Self, Error>