add: community settings ui
TODO: add community read/write access settings TODO: add profile settings TODO: profile following in ui TODO: community joining and membership management in ui
This commit is contained in:
parent
eecf357325
commit
6413ed09fb
20 changed files with 855 additions and 46 deletions
|
@ -116,14 +116,14 @@ impl DataManager {
|
|||
|
||||
auto_method!(delete_community()@get_community_by_id:MANAGE_COMMUNITIES -> "DELETE communities pages WHERE id = $1" --cache-key-tmpl=cache_clear_community);
|
||||
auto_method!(update_community_title(String)@get_community_by_id:MANAGE_COMMUNITIES -> "UPDATE communities SET title = $1 WHERE id = $2" --cache-key-tmpl=cache_clear_community);
|
||||
auto_method!(update_community_context(CommunityContext)@get_community_by_id:MANAGE_COMMUNITIES -> "UPDATE communities SET prompt = $1 WHERE id = $2" --serde --cache-key-tmpl=cache_clear_community);
|
||||
auto_method!(update_community_context(CommunityContext)@get_community_by_id:MANAGE_COMMUNITIES -> "UPDATE communities SET context = $1 WHERE id = $2" --serde --cache-key-tmpl=cache_clear_community);
|
||||
auto_method!(update_community_read_access(CommunityReadAccess)@get_community_by_id:MANAGE_COMMUNITIES -> "UPDATE communities SET read_access = $1 WHERE id = $2" --serde --cache-key-tmpl=cache_clear_community);
|
||||
auto_method!(update_community_write_access(CommunityWriteAccess)@get_community_by_id:MANAGE_COMMUNITIES -> "UPDATE communities SET write_access = $1 WHERE id = $2" --serde --cache-key-tmpl=cache_clear_community);
|
||||
|
||||
auto_method!(incr_community_likes()@get_community_by_id -> "UPDATE communities SET likes = likes + 1 WHERE id = $1" --cache-key-tmpl=cache_clear_community --incr);
|
||||
auto_method!(incr_community_dislikes()@get_community_by_id -> "UPDATE communities SET likes = dislikes + 1 WHERE id = $1" --cache-key-tmpl=cache_clear_community --incr);
|
||||
auto_method!(incr_community_dislikes()@get_community_by_id -> "UPDATE communities SET dislikes = dislikes + 1 WHERE id = $1" --cache-key-tmpl=cache_clear_community --incr);
|
||||
auto_method!(decr_community_likes()@get_community_by_id -> "UPDATE communities SET likes = likes - 1 WHERE id = $1" --cache-key-tmpl=cache_clear_community --decr);
|
||||
auto_method!(decr_community_dislikes()@get_community_by_id -> "UPDATE communities SET likes = dislikes - 1 WHERE id = $1" --cache-key-tmpl=cache_clear_community --decr);
|
||||
auto_method!(decr_community_dislikes()@get_community_by_id -> "UPDATE communities SET dislikes = dislikes - 1 WHERE id = $1" --cache-key-tmpl=cache_clear_community --decr);
|
||||
|
||||
auto_method!(incr_community_member_count()@get_community_by_id -> "UPDATE communities SET member_count = member_count + 1 WHERE id = $1" --cache-key-tmpl=cache_clear_community --incr);
|
||||
auto_method!(decr_community_member_count()@get_community_by_id -> "UPDATE communities SET member_count = member_count - 1 WHERE id = $1" --cache-key-tmpl=cache_clear_community --decr);
|
||||
|
|
|
@ -287,9 +287,9 @@ impl DataManager {
|
|||
auto_method!(update_post_context(PostContext)@get_post_by_id:MANAGE_POSTS -> "UPDATE posts SET context = $1 WHERE id = $2" --serde --cache-key-tmpl="atto.post:{}");
|
||||
|
||||
auto_method!(incr_post_likes() -> "UPDATE posts SET likes = likes + 1 WHERE id = $1" --cache-key-tmpl="atto.post:{}" --incr);
|
||||
auto_method!(incr_post_dislikes() -> "UPDATE posts SET likes = dislikes + 1 WHERE id = $1" --cache-key-tmpl="atto.post:{}" --incr);
|
||||
auto_method!(incr_post_dislikes() -> "UPDATE posts SET dislikes = dislikes + 1 WHERE id = $1" --cache-key-tmpl="atto.post:{}" --incr);
|
||||
auto_method!(decr_post_likes() -> "UPDATE posts SET likes = likes - 1 WHERE id = $1" --cache-key-tmpl="atto.post:{}" --decr);
|
||||
auto_method!(decr_post_dislikes() -> "UPDATE posts SET likes = dislikes - 1 WHERE id = $1" --cache-key-tmpl="atto.post:{}" --decr);
|
||||
auto_method!(decr_post_dislikes() -> "UPDATE posts SET dislikes = dislikes - 1 WHERE id = $1" --cache-key-tmpl="atto.post:{}" --decr);
|
||||
|
||||
auto_method!(incr_post_comments() -> "UPDATE posts SET comment_count = comment_count + 1 WHERE id = $1" --cache-key-tmpl="atto.post:{}" --incr);
|
||||
auto_method!(decr_post_comments() -> "UPDATE posts SET comment_count = comment_count - 1 WHERE id = $1" --cache-key-tmpl="atto.post:{}" --decr);
|
||||
|
|
|
@ -86,13 +86,25 @@ impl DataManager {
|
|||
|
||||
// incr corresponding
|
||||
match data.asset_type {
|
||||
AssetType::Journal => {
|
||||
if let Err(e) = self.incr_community_likes(data.id).await {
|
||||
AssetType::Community => {
|
||||
if let Err(e) = {
|
||||
if data.is_like {
|
||||
self.incr_community_likes(data.asset).await
|
||||
} else {
|
||||
self.incr_community_dislikes(data.asset).await
|
||||
}
|
||||
} {
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
AssetType::JournalEntry => {
|
||||
if let Err(e) = self.incr_post_likes(data.id).await {
|
||||
AssetType::Post => {
|
||||
if let Err(e) = {
|
||||
if data.is_like {
|
||||
self.incr_post_likes(data.asset).await
|
||||
} else {
|
||||
self.incr_post_dislikes(data.asset).await
|
||||
}
|
||||
} {
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +114,7 @@ impl DataManager {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn delete_reaction(&self, id: usize, user: User) -> Result<()> {
|
||||
pub async fn delete_reaction(&self, id: usize, user: &User) -> Result<()> {
|
||||
let reaction = self.get_reaction_by_id(id).await?;
|
||||
|
||||
if user.id != reaction.owner {
|
||||
|
@ -130,13 +142,25 @@ impl DataManager {
|
|||
|
||||
// decr corresponding
|
||||
match reaction.asset_type {
|
||||
AssetType::Journal => {
|
||||
if let Err(e) = self.decr_community_likes(reaction.asset).await {
|
||||
AssetType::Community => {
|
||||
if let Err(e) = {
|
||||
if reaction.is_like {
|
||||
self.decr_community_likes(reaction.asset).await
|
||||
} else {
|
||||
self.decr_community_dislikes(reaction.asset).await
|
||||
}
|
||||
} {
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
AssetType::JournalEntry => {
|
||||
if let Err(e) = self.decr_post_likes(reaction.asset).await {
|
||||
AssetType::Post => {
|
||||
if let Err(e) = {
|
||||
if reaction.is_like {
|
||||
self.decr_post_likes(reaction.asset).await
|
||||
} else {
|
||||
self.decr_post_dislikes(reaction.asset).await
|
||||
}
|
||||
} {
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ use tetratto_shared::{snow::AlmostSnowflake, unix_epoch_timestamp};
|
|||
/// All of the items which support reactions.
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub enum AssetType {
|
||||
Journal,
|
||||
JournalEntry,
|
||||
Community,
|
||||
Post,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue