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 from_tuple(tuple: Self::JoinTuple) -> Self
151 pub trait ApubActor {
152 async fn read_from_apub_id(pool: &DbPool, 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
157 async fn read_from_name(
160 include_deleted: bool,
161 ) -> Result<Self, Error>
164 async fn read_from_name_and_domain(
167 protocol_domain: &str,
168 ) -> Result<Self, Error>