add: post comments
add: user follow api, user block api
This commit is contained in:
parent
559ce19932
commit
8580e34be2
18 changed files with 296 additions and 49 deletions
|
@ -62,10 +62,8 @@ impl Default for JournalReadAccess {
|
|||
/// Who can write to a [`Journal`].
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum JournalWriteAccess {
|
||||
/// Everybody (authenticated + anonymous users).
|
||||
/// Everybody (authenticated users only still).
|
||||
Everybody,
|
||||
/// Authenticated users only.
|
||||
Authenticated,
|
||||
/// Only people who joined the journal page can write to it.
|
||||
///
|
||||
/// Memberships can be managed by the owner of the journal page.
|
||||
|
@ -76,7 +74,7 @@ pub enum JournalWriteAccess {
|
|||
|
||||
impl Default for JournalWriteAccess {
|
||||
fn default() -> Self {
|
||||
Self::Authenticated
|
||||
Self::Joined
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,13 +126,16 @@ pub struct JournalPost {
|
|||
pub journal: usize,
|
||||
/// Extra information about the journal entry.
|
||||
pub context: JournalPostContext,
|
||||
/// The ID of the post this post is a comment on.
|
||||
pub replying_to: Option<usize>,
|
||||
pub likes: isize,
|
||||
pub dislikes: isize,
|
||||
pub comment_count: usize,
|
||||
}
|
||||
|
||||
impl JournalPost {
|
||||
/// Create a new [`JournalEntry`].
|
||||
pub fn new(content: String, journal: usize, owner: usize) -> Self {
|
||||
pub fn new(content: String, journal: usize, replying_to: Option<usize>, owner: usize) -> Self {
|
||||
Self {
|
||||
id: AlmostSnowflake::new(1234567890)
|
||||
.to_string()
|
||||
|
@ -145,8 +146,10 @@ impl JournalPost {
|
|||
owner,
|
||||
journal,
|
||||
context: JournalPostContext::default(),
|
||||
replying_to,
|
||||
likes: 0,
|
||||
dislikes: 0,
|
||||
comment_count: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ bitflags! {
|
|||
const DEFAULT = 1 << 0;
|
||||
const ADMINISTRATOR = 1 << 1;
|
||||
const MEMBER = 1 << 2;
|
||||
const MANAGE_POSTS = 1 << 3;
|
||||
const MANAGE_ROLES = 1 << 4;
|
||||
|
||||
const _ = !0;
|
||||
}
|
||||
|
@ -93,9 +95,14 @@ impl JournalPermission {
|
|||
}
|
||||
|
||||
/// Check if the given [`JournalPermission`] qualifies as "Member" status.
|
||||
pub fn check_helper(self) -> bool {
|
||||
pub fn check_member(self) -> bool {
|
||||
self.check(JournalPermission::MEMBER)
|
||||
}
|
||||
|
||||
/// Check if the given [`JournalPermission`] qualifies as "Moderator" status.
|
||||
pub fn check_moderator(self) -> bool {
|
||||
self.check(JournalPermission::MANAGE_POSTS)
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for JournalPermission {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue