]> Untitled Git - lemmy.git/commitdiff
Merge pull request 'Order outbox by published, not id' (#171) from outbox-order-publi...
authordessalines <dessalines@noreply.yerbamate.ml>
Mon, 22 Feb 2021 20:37:06 +0000 (20:37 +0000)
committerdessalines <dessalines@noreply.yerbamate.ml>
Mon, 22 Feb 2021 20:37:06 +0000 (20:37 +0000)
Reviewed-on: https://yerbamate.ml/LemmyNet/lemmy/pulls/171

20 files changed:
RELEASES.md
ansible/VERSION
crates/api/src/comment.rs
crates/api/src/community.rs
crates/api/src/lib.rs
crates/api/src/post.rs
crates/api/src/site.rs
crates/api/src/user.rs
crates/apub/src/objects/post.rs
crates/utils/src/lib.rs
crates/utils/src/rate_limit/rate_limiter.rs
crates/utils/src/utils.rs
crates/utils/src/version.rs
crates/websocket/src/chat_server.rs
crates/websocket/src/messages.rs
crates/websocket/src/routes.rs
docker/dev/docker-compose.yml
docker/federation/docker-compose.yml
docker/prod/deploy.sh
docker/prod/docker-compose.yml

index 87068881071731ab0112562b8ee53318de82b3ce..e64c7e92a8f73a029fd0bc2243eba3873b66234c 100644 (file)
@@ -1,3 +1,23 @@
+# Lemmy v0.9.9 Release (2021-02-19)
+
+## Changes
+
+### Lemmy backend
+- Added an federated activity query sorting order.
+- Explicitly marking posts and comments as public.
+- Added a `NewComment` / forum sort for posts.
+- Fixed an issue with not setting correct published time for fetched posts.
+- Fixed an issue with an open docker port on lemmy-ui.
+- Using lemmy post link for RSS link.
+- Fixed reason and display name lengths to use char counts instead.
+
+### Lemmy-ui
+
+- Updated translations.
+- Made websocket host configurable.
+- Added some accessibility features.
+- Always showing password reset link.
+
 # Lemmy v0.9.7 Release (2021-02-08)
 
 ## Changes
index c81aa44afbfcb4d1955b55e5276991aae023f039..7e310bae19960a3c44b9f9095f1f95b1e4c49ad9 100644 (file)
@@ -1 +1 @@
-0.9.7
+0.9.9
index b77e4151a6a0a6ec9ffa1e736f8cd75f2b7b1509..02acc7f85ce7b92048c1126091689c71f6d60efd 100644 (file)
@@ -27,7 +27,7 @@ use lemmy_db_views::{
 use lemmy_structs::{blocking, comment::*, send_local_notifs};
 use lemmy_utils::{
   utils::{remove_slurs, scrape_text_for_mentions},
-  APIError,
+  ApiError,
   ConnectionId,
   LemmyError,
 };
@@ -60,7 +60,7 @@ impl Perform for CreateComment {
 
     // Check if post is locked, no new comments
     if post.locked {
-      return Err(APIError::err("locked").into());
+      return Err(ApiError::err("locked").into());
     }
 
     // If there's a parent_id, check to make sure that comment is in that post
@@ -69,10 +69,10 @@ impl Perform for CreateComment {
       let parent =
         match blocking(context.pool(), move |conn| Comment::read(&conn, parent_id)).await? {
           Ok(comment) => comment,
-          Err(_e) => return Err(APIError::err("couldnt_create_comment").into()),
+          Err(_e) => return Err(ApiError::err("couldnt_create_comment").into()),
         };
       if parent.post_id != post_id {
-        return Err(APIError::err("couldnt_create_comment").into());
+        return Err(ApiError::err("couldnt_create_comment").into());
       }
     }
 
@@ -98,7 +98,7 @@ impl Perform for CreateComment {
     .await?
     {
       Ok(comment) => comment,
-      Err(_e) => return Err(APIError::err("couldnt_create_comment").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_create_comment").into()),
     };
 
     // Necessary to update the ap_id
@@ -112,7 +112,7 @@ impl Perform for CreateComment {
       .await?
       {
         Ok(comment) => comment,
-        Err(_e) => return Err(APIError::err("couldnt_create_comment").into()),
+        Err(_e) => return Err(ApiError::err("couldnt_create_comment").into()),
       };
 
     updated_comment.send_create(&user, context).await?;
@@ -140,7 +140,7 @@ impl Perform for CreateComment {
 
     let like = move |conn: &'_ _| CommentLike::like(&conn, &like_form);
     if blocking(context.pool(), like).await?.is_err() {
-      return Err(APIError::err("couldnt_like_comment").into());
+      return Err(ApiError::err("couldnt_like_comment").into());
     }
 
     updated_comment.send_like(&user, context).await?;
@@ -160,7 +160,7 @@ impl Perform for CreateComment {
       .await?
       {
         Ok(comment) => comment,
-        Err(_e) => return Err(APIError::err("couldnt_update_comment").into()),
+        Err(_e) => return Err(ApiError::err("couldnt_update_comment").into()),
       };
       comment_view.comment.read = true;
     }
@@ -205,7 +205,7 @@ impl Perform for EditComment {
 
     // Verify that only the creator can edit
     if user.id != orig_comment.creator.id {
-      return Err(APIError::err("no_comment_edit_allowed").into());
+      return Err(ApiError::err("no_comment_edit_allowed").into());
     }
 
     // Do the update
@@ -217,7 +217,7 @@ impl Perform for EditComment {
     .await?
     {
       Ok(comment) => comment,
-      Err(_e) => return Err(APIError::err("couldnt_update_comment").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_update_comment").into()),
     };
 
     // Send the apub update
@@ -281,7 +281,7 @@ impl Perform for DeleteComment {
 
     // Verify that only the creator can delete
     if user.id != orig_comment.creator.id {
-      return Err(APIError::err("no_comment_edit_allowed").into());
+      return Err(ApiError::err("no_comment_edit_allowed").into());
     }
 
     // Do the delete
@@ -292,7 +292,7 @@ impl Perform for DeleteComment {
     .await?
     {
       Ok(comment) => comment,
-      Err(_e) => return Err(APIError::err("couldnt_update_comment").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_update_comment").into()),
     };
 
     // Send the apub message
@@ -370,7 +370,7 @@ impl Perform for RemoveComment {
     .await?
     {
       Ok(comment) => comment,
-      Err(_e) => return Err(APIError::err("couldnt_update_comment").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_update_comment").into()),
     };
 
     // Mod tables
@@ -452,7 +452,7 @@ impl Perform for MarkCommentAsRead {
 
     // Verify that only the recipient can mark as read
     if user.id != orig_comment.get_recipient_id() {
-      return Err(APIError::err("no_comment_edit_allowed").into());
+      return Err(ApiError::err("no_comment_edit_allowed").into());
     }
 
     // Do the mark as read
@@ -463,7 +463,7 @@ impl Perform for MarkCommentAsRead {
     .await?
     {
       Ok(comment) => comment,
-      Err(_e) => return Err(APIError::err("couldnt_update_comment").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_update_comment").into()),
     };
 
     // Refetch it
@@ -504,12 +504,12 @@ impl Perform for SaveComment {
     if data.save {
       let save_comment = move |conn: &'_ _| CommentSaved::save(conn, &comment_saved_form);
       if blocking(context.pool(), save_comment).await?.is_err() {
-        return Err(APIError::err("couldnt_save_comment").into());
+        return Err(ApiError::err("couldnt_save_comment").into());
       }
     } else {
       let unsave_comment = move |conn: &'_ _| CommentSaved::unsave(conn, &comment_saved_form);
       if blocking(context.pool(), unsave_comment).await?.is_err() {
-        return Err(APIError::err("couldnt_save_comment").into());
+        return Err(ApiError::err("couldnt_save_comment").into());
       }
     }
 
@@ -577,7 +577,7 @@ impl Perform for CreateCommentLike {
       let like_form2 = like_form.clone();
       let like = move |conn: &'_ _| CommentLike::like(conn, &like_form2);
       if blocking(context.pool(), like).await?.is_err() {
-        return Err(APIError::err("couldnt_like_comment").into());
+        return Err(ApiError::err("couldnt_like_comment").into());
       }
 
       if like_form.score == 1 {
@@ -647,7 +647,7 @@ impl Perform for GetComments {
     .await?;
     let comments = match comments {
       Ok(comments) => comments,
-      Err(_) => return Err(APIError::err("couldnt_get_comments").into()),
+      Err(_) => return Err(ApiError::err("couldnt_get_comments").into()),
     };
 
     Ok(GetCommentsResponse { comments })
@@ -670,10 +670,10 @@ impl Perform for CreateCommentReport {
     // check size of report and check for whitespace
     let reason = data.reason.trim();
     if reason.is_empty() {
-      return Err(APIError::err("report_reason_required").into());
+      return Err(ApiError::err("report_reason_required").into());
     }
     if reason.chars().count() > 1000 {
-      return Err(APIError::err("report_too_long").into());
+      return Err(ApiError::err("report_too_long").into());
     }
 
     let user_id = user.id;
@@ -698,7 +698,7 @@ impl Perform for CreateCommentReport {
     .await?
     {
       Ok(report) => report,
-      Err(_e) => return Err(APIError::err("couldnt_create_report").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_create_report").into()),
     };
 
     let res = CreateCommentReportResponse { success: true };
@@ -753,7 +753,7 @@ impl Perform for ResolveCommentReport {
     };
 
     if blocking(context.pool(), resolve_fun).await?.is_err() {
-      return Err(APIError::err("couldnt_resolve_report").into());
+      return Err(ApiError::err("couldnt_resolve_report").into());
     };
 
     let report_id = data.report_id;
index 1c47ef8e240333d10aa7f9b389155b1dbbb7f96a..fcfe7913331743b0575c134309f0b5d8f3e550b2 100644 (file)
@@ -48,7 +48,7 @@ use lemmy_utils::{
   apub::generate_actor_keypair,
   location_info,
   utils::{check_slurs, check_slurs_opt, is_valid_community_name, naive_from_unix},
-  APIError,
+  ApiError,
   ConnectionId,
   LemmyError,
 };
@@ -82,7 +82,7 @@ impl Perform for GetCommunity {
         .await?
         {
           Ok(community) => community,
-          Err(_e) => return Err(APIError::err("couldnt_find_community").into()),
+          Err(_e) => return Err(ApiError::err("couldnt_find_community").into()),
         }
         .id
       }
@@ -94,7 +94,7 @@ impl Perform for GetCommunity {
     .await?
     {
       Ok(community) => community,
-      Err(_e) => return Err(APIError::err("couldnt_find_community").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_find_community").into()),
     };
 
     let moderators: Vec<CommunityModeratorView> = match blocking(context.pool(), move |conn| {
@@ -103,7 +103,7 @@ impl Perform for GetCommunity {
     .await?
     {
       Ok(moderators) => moderators,
-      Err(_e) => return Err(APIError::err("couldnt_find_community").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_find_community").into()),
     };
 
     let online = context
@@ -140,7 +140,7 @@ impl Perform for CreateCommunity {
     check_slurs_opt(&data.description)?;
 
     if !is_valid_community_name(&data.name) {
-      return Err(APIError::err("invalid_community_name").into());
+      return Err(ApiError::err("invalid_community_name").into());
     }
 
     // Double check for duplicate community actor_ids
@@ -151,7 +151,7 @@ impl Perform for CreateCommunity {
     })
     .await?;
     if community_dupe.is_ok() {
-      return Err(APIError::err("community_already_exists").into());
+      return Err(ApiError::err("community_already_exists").into());
     }
 
     // Check to make sure the icon and banners are urls
@@ -193,7 +193,7 @@ impl Perform for CreateCommunity {
     .await?
     {
       Ok(community) => community,
-      Err(_e) => return Err(APIError::err("community_already_exists").into()),
+      Err(_e) => return Err(ApiError::err("community_already_exists").into()),
     };
 
     // The community creator becomes a moderator
@@ -204,7 +204,7 @@ impl Perform for CreateCommunity {
 
     let join = move |conn: &'_ _| CommunityModerator::join(conn, &community_moderator_form);
     if blocking(context.pool(), join).await?.is_err() {
-      return Err(APIError::err("community_moderator_already_exists").into());
+      return Err(ApiError::err("community_moderator_already_exists").into());
     }
 
     // Follow your own community
@@ -216,7 +216,7 @@ impl Perform for CreateCommunity {
 
     let follow = move |conn: &'_ _| CommunityFollower::follow(conn, &community_follower_form);
     if blocking(context.pool(), follow).await?.is_err() {
-      return Err(APIError::err("community_follower_already_exists").into());
+      return Err(ApiError::err("community_follower_already_exists").into());
     }
 
     let user_id = user.id;
@@ -252,7 +252,7 @@ impl Perform for EditCommunity {
     })
     .await??;
     if !mods.contains(&user.id) {
-      return Err(APIError::err("not_a_moderator").into());
+      return Err(ApiError::err("not_a_moderator").into());
     }
 
     let community_id = data.community_id;
@@ -297,7 +297,7 @@ impl Perform for EditCommunity {
     .await?
     {
       Ok(community) => community,
-      Err(_e) => return Err(APIError::err("couldnt_update_community").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_update_community").into()),
     };
 
     // TODO there needs to be some kind of an apub update
@@ -337,7 +337,7 @@ impl Perform for DeleteCommunity {
     })
     .await??;
     if read_community.creator_id != user.id {
-      return Err(APIError::err("no_community_edit_allowed").into());
+      return Err(ApiError::err("no_community_edit_allowed").into());
     }
 
     // Do the delete
@@ -349,7 +349,7 @@ impl Perform for DeleteCommunity {
     .await?
     {
       Ok(community) => community,
-      Err(_e) => return Err(APIError::err("couldnt_update_community").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_update_community").into()),
     };
 
     // Send apub messages
@@ -398,7 +398,7 @@ impl Perform for RemoveCommunity {
     .await?
     {
       Ok(community) => community,
-      Err(_e) => return Err(APIError::err("couldnt_update_community").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_update_community").into()),
     };
 
     // Mod tables
@@ -513,13 +513,13 @@ impl Perform for FollowCommunity {
 
         let follow = move |conn: &'_ _| CommunityFollower::follow(conn, &community_follower_form);
         if blocking(context.pool(), follow).await?.is_err() {
-          return Err(APIError::err("community_follower_already_exists").into());
+          return Err(ApiError::err("community_follower_already_exists").into());
         }
       } else {
         let unfollow =
           move |conn: &'_ _| CommunityFollower::unfollow(conn, &community_follower_form);
         if blocking(context.pool(), unfollow).await?.is_err() {
-          return Err(APIError::err("community_follower_already_exists").into());
+          return Err(ApiError::err("community_follower_already_exists").into());
         }
       }
     } else if data.follow {
@@ -530,7 +530,7 @@ impl Perform for FollowCommunity {
       user.send_unfollow(&community.actor_id(), context).await?;
       let unfollow = move |conn: &'_ _| CommunityFollower::unfollow(conn, &community_follower_form);
       if blocking(context.pool(), unfollow).await?.is_err() {
-        return Err(APIError::err("community_follower_already_exists").into());
+        return Err(ApiError::err("community_follower_already_exists").into());
       }
     }
 
@@ -571,7 +571,7 @@ impl Perform for GetFollowedCommunities {
     .await?
     {
       Ok(communities) => communities,
-      _ => return Err(APIError::err("system_err_login").into()),
+      _ => return Err(ApiError::err("system_err_login").into()),
     };
 
     // Return the jwt
@@ -605,7 +605,7 @@ impl Perform for BanFromCommunity {
     if data.ban {
       let ban = move |conn: &'_ _| CommunityUserBan::ban(conn, &community_user_ban_form);
       if blocking(context.pool(), ban).await?.is_err() {
-        return Err(APIError::err("community_user_already_banned").into());
+        return Err(ApiError::err("community_user_already_banned").into());
       }
 
       // Also unsubscribe them from the community, if they are subscribed
@@ -622,7 +622,7 @@ impl Perform for BanFromCommunity {
     } else {
       let unban = move |conn: &'_ _| CommunityUserBan::unban(conn, &community_user_ban_form);
       if blocking(context.pool(), unban).await?.is_err() {
-        return Err(APIError::err("community_user_already_banned").into());
+        return Err(ApiError::err("community_user_already_banned").into());
       }
     }
 
@@ -721,12 +721,12 @@ impl Perform for AddModToCommunity {
     if data.added {
       let join = move |conn: &'_ _| CommunityModerator::join(conn, &community_moderator_form);
       if blocking(context.pool(), join).await?.is_err() {
-        return Err(APIError::err("community_moderator_already_exists").into());
+        return Err(ApiError::err("community_moderator_already_exists").into());
       }
     } else {
       let leave = move |conn: &'_ _| CommunityModerator::leave(conn, &community_moderator_form);
       if blocking(context.pool(), leave).await?.is_err() {
-        return Err(APIError::err("community_moderator_already_exists").into());
+        return Err(ApiError::err("community_moderator_already_exists").into());
       }
     }
 
@@ -798,14 +798,14 @@ impl Perform for TransferCommunity {
     if user.id != read_community.creator_id
       && !admins.iter().map(|a| a.user.id).any(|x| x == user.id)
     {
-      return Err(APIError::err("not_an_admin").into());
+      return Err(ApiError::err("not_an_admin").into());
     }
 
     let community_id = data.community_id;
     let new_creator = data.user_id;
     let update = move |conn: &'_ _| Community::update_creator(conn, community_id, new_creator);
     if blocking(context.pool(), update).await?.is_err() {
-      return Err(APIError::err("couldnt_update_community").into());
+      return Err(ApiError::err("couldnt_update_community").into());
     };
 
     // You also have to re-do the community_moderator table, reordering it.
@@ -836,7 +836,7 @@ impl Perform for TransferCommunity {
 
       let join = move |conn: &'_ _| CommunityModerator::join(conn, &community_moderator_form);
       if blocking(context.pool(), join).await?.is_err() {
-        return Err(APIError::err("community_moderator_already_exists").into());
+        return Err(ApiError::err("community_moderator_already_exists").into());
       }
     }
 
@@ -860,7 +860,7 @@ impl Perform for TransferCommunity {
     .await?
     {
       Ok(community) => community,
-      Err(_e) => return Err(APIError::err("couldnt_find_community").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_find_community").into()),
     };
 
     let community_id = data.community_id;
@@ -870,7 +870,7 @@ impl Perform for TransferCommunity {
     .await?
     {
       Ok(moderators) => moderators,
-      Err(_e) => return Err(APIError::err("couldnt_find_community").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_find_community").into()),
     };
 
     // Return the jwt
index 5e9e1c1624628cc78f8b329d1d51ddbd9aa57d1f..7f6fcb02973d303caf5011db62c898efa3f28a45 100644 (file)
@@ -19,7 +19,7 @@ use lemmy_db_views_actor::{
   community_view::CommunityView,
 };
 use lemmy_structs::{blocking, comment::*, community::*, post::*, site::*, user::*, websocket::*};
-use lemmy_utils::{claims::Claims, settings::Settings, APIError, ConnectionId, LemmyError};
+use lemmy_utils::{claims::Claims, settings::Settings, ApiError, ConnectionId, LemmyError};
 use lemmy_websocket::{serialize_websocket_message, LemmyContext, UserOperation};
 use serde::Deserialize;
 use std::process::Command;
@@ -54,14 +54,14 @@ pub(crate) async fn is_mod_or_admin(
   })
   .await?;
   if !is_mod_or_admin {
-    return Err(APIError::err("not_a_mod_or_admin").into());
+    return Err(ApiError::err("not_a_mod_or_admin").into());
   }
   Ok(())
 }
 pub async fn is_admin(pool: &DbPool, user_id: i32) -> Result<(), LemmyError> {
   let user = blocking(pool, move |conn| User_::read(conn, user_id)).await??;
   if !user.admin {
-    return Err(APIError::err("not_an_admin").into());
+    return Err(ApiError::err("not_an_admin").into());
   }
   Ok(())
 }
@@ -69,20 +69,20 @@ pub async fn is_admin(pool: &DbPool, user_id: i32) -> Result<(), LemmyError> {
 pub(crate) async fn get_post(post_id: i32, pool: &DbPool) -> Result<Post, LemmyError> {
   match blocking(pool, move |conn| Post::read(conn, post_id)).await? {
     Ok(post) => Ok(post),
-    Err(_e) => Err(APIError::err("couldnt_find_post").into()),
+    Err(_e) => Err(ApiError::err("couldnt_find_post").into()),
   }
 }
 
 pub(crate) async fn get_user_from_jwt(jwt: &str, pool: &DbPool) -> Result<User_, LemmyError> {
   let claims = match Claims::decode(&jwt) {
     Ok(claims) => claims.claims,
-    Err(_e) => return Err(APIError::err("not_logged_in").into()),
+    Err(_e) => return Err(ApiError::err("not_logged_in").into()),
   };
   let user_id = claims.id;
   let user = blocking(pool, move |conn| User_::read(conn, user_id)).await??;
   // Check for a site ban
   if user.banned {
-    return Err(APIError::err("site_ban").into());
+    return Err(ApiError::err("site_ban").into());
   }
   Ok(user)
 }
@@ -103,13 +103,13 @@ pub(crate) async fn get_user_safe_settings_from_jwt(
 ) -> Result<UserSafeSettings, LemmyError> {
   let claims = match Claims::decode(&jwt) {
     Ok(claims) => claims.claims,
-    Err(_e) => return Err(APIError::err("not_logged_in").into()),
+    Err(_e) => return Err(ApiError::err("not_logged_in").into()),
   };
   let user_id = claims.id;
   let user = blocking(pool, move |conn| UserSafeSettings::read(conn, user_id)).await??;
   // Check for a site ban
   if user.banned {
-    return Err(APIError::err("site_ban").into());
+    return Err(ApiError::err("site_ban").into());
   }
   Ok(user)
 }
@@ -131,7 +131,7 @@ pub(crate) async fn check_community_ban(
 ) -> Result<(), LemmyError> {
   let is_banned = move |conn: &'_ _| CommunityUserBanView::get(conn, user_id, community_id).is_ok();
   if blocking(pool, is_banned).await? {
-    Err(APIError::err("community_ban").into())
+    Err(ApiError::err("community_ban").into())
   } else {
     Ok(())
   }
@@ -141,7 +141,7 @@ pub(crate) async fn check_downvotes_enabled(score: i16, pool: &DbPool) -> Result
   if score == -1 {
     let site = blocking(pool, move |conn| Site::read_simple(conn)).await??;
     if !site.enable_downvotes {
-      return Err(APIError::err("downvotes_disabled").into());
+      return Err(ApiError::err("downvotes_disabled").into());
     }
   }
   Ok(())
@@ -175,7 +175,7 @@ pub(crate) async fn collect_moderated_communities(
 pub(crate) fn check_optional_url(item: &Option<Option<String>>) -> Result<(), LemmyError> {
   if let Some(Some(item)) = &item {
     if Url::parse(item).is_err() {
-      return Err(APIError::err("invalid_url").into());
+      return Err(ApiError::err("invalid_url").into());
     }
   }
   Ok(())
index 7c7afe604446c3b9a3867f5f9e2eb5d43ac6a810..4ef07ae560e26c394edd31e71a124a11fd208de7 100644 (file)
@@ -40,7 +40,7 @@ use lemmy_structs::{blocking, post::*};
 use lemmy_utils::{
   request::fetch_iframely_and_pictrs_data,
   utils::{check_slurs, check_slurs_opt, is_valid_post_title},
-  APIError,
+  ApiError,
   ConnectionId,
   LemmyError,
 };
@@ -67,7 +67,7 @@ impl Perform for CreatePost {
     check_slurs_opt(&data.body)?;
 
     if !is_valid_post_title(&data.name) {
-      return Err(APIError::err("invalid_post_title").into());
+      return Err(ApiError::err("invalid_post_title").into());
     }
 
     check_community_ban(user.id, data.community_id, context.pool()).await?;
@@ -109,7 +109,7 @@ impl Perform for CreatePost {
             "couldnt_create_post"
           };
 
-          return Err(APIError::err(err_type).into());
+          return Err(ApiError::err(err_type).into());
         }
       };
 
@@ -121,7 +121,7 @@ impl Perform for CreatePost {
     .await?
     {
       Ok(post) => post,
-      Err(_e) => return Err(APIError::err("couldnt_create_post").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_create_post").into()),
     };
 
     updated_post.send_create(&user, context).await?;
@@ -135,7 +135,7 @@ impl Perform for CreatePost {
 
     let like = move |conn: &'_ _| PostLike::like(conn, &like_form);
     if blocking(context.pool(), like).await?.is_err() {
-      return Err(APIError::err("couldnt_like_post").into());
+      return Err(ApiError::err("couldnt_like_post").into());
     }
 
     updated_post.send_like(&user, context).await?;
@@ -148,7 +148,7 @@ impl Perform for CreatePost {
     .await?
     {
       Ok(post) => post,
-      Err(_e) => return Err(APIError::err("couldnt_find_post").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_find_post").into()),
     };
 
     let res = PostResponse { post_view };
@@ -183,7 +183,7 @@ impl Perform for GetPost {
     .await?
     {
       Ok(post) => post,
-      Err(_e) => return Err(APIError::err("couldnt_find_post").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_find_post").into()),
     };
 
     let id = data.id;
@@ -209,7 +209,7 @@ impl Perform for GetPost {
     .await?
     {
       Ok(community) => community,
-      Err(_e) => return Err(APIError::err("couldnt_find_community").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_find_community").into()),
     };
 
     let online = context
@@ -273,7 +273,7 @@ impl Perform for GetPosts {
     .await?
     {
       Ok(posts) => posts,
-      Err(_e) => return Err(APIError::err("couldnt_get_posts").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_get_posts").into()),
     };
 
     Ok(GetPostsResponse { posts })
@@ -320,7 +320,7 @@ impl Perform for CreatePostLike {
       let like_form2 = like_form.clone();
       let like = move |conn: &'_ _| PostLike::like(conn, &like_form2);
       if blocking(context.pool(), like).await?.is_err() {
-        return Err(APIError::err("couldnt_like_post").into());
+        return Err(ApiError::err("couldnt_like_post").into());
       }
 
       if like_form.score == 1 {
@@ -340,7 +340,7 @@ impl Perform for CreatePostLike {
     .await?
     {
       Ok(post) => post,
-      Err(_e) => return Err(APIError::err("couldnt_find_post").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_find_post").into()),
     };
 
     let res = PostResponse { post_view };
@@ -371,7 +371,7 @@ impl Perform for EditPost {
     check_slurs_opt(&data.body)?;
 
     if !is_valid_post_title(&data.name) {
-      return Err(APIError::err("invalid_post_title").into());
+      return Err(ApiError::err("invalid_post_title").into());
     }
 
     let post_id = data.post_id;
@@ -381,7 +381,7 @@ impl Perform for EditPost {
 
     // Verify that only the creator can edit
     if !Post::is_post_creator(user.id, orig_post.creator_id) {
-      return Err(APIError::err("no_post_edit_allowed").into());
+      return Err(ApiError::err("no_post_edit_allowed").into());
     }
 
     // Fetch Iframely and Pictrs cached image
@@ -423,7 +423,7 @@ impl Perform for EditPost {
           "couldnt_update_post"
         };
 
-        return Err(APIError::err(err_type).into());
+        return Err(ApiError::err(err_type).into());
       }
     };
 
@@ -467,7 +467,7 @@ impl Perform for DeletePost {
 
     // Verify that only the creator can delete
     if !Post::is_post_creator(user.id, orig_post.creator_id) {
-      return Err(APIError::err("no_post_edit_allowed").into());
+      return Err(ApiError::err("no_post_edit_allowed").into());
     }
 
     // Update the post
@@ -711,12 +711,12 @@ impl Perform for SavePost {
     if data.save {
       let save = move |conn: &'_ _| PostSaved::save(conn, &post_saved_form);
       if blocking(context.pool(), save).await?.is_err() {
-        return Err(APIError::err("couldnt_save_post").into());
+        return Err(ApiError::err("couldnt_save_post").into());
       }
     } else {
       let unsave = move |conn: &'_ _| PostSaved::unsave(conn, &post_saved_form);
       if blocking(context.pool(), unsave).await?.is_err() {
-        return Err(APIError::err("couldnt_save_post").into());
+        return Err(ApiError::err("couldnt_save_post").into());
       }
     }
 
@@ -747,10 +747,10 @@ impl Perform for CreatePostReport {
     // check size of report and check for whitespace
     let reason = data.reason.trim();
     if reason.is_empty() {
-      return Err(APIError::err("report_reason_required").into());
+      return Err(ApiError::err("report_reason_required").into());
     }
     if reason.chars().count() > 1000 {
-      return Err(APIError::err("report_too_long").into());
+      return Err(ApiError::err("report_too_long").into());
     }
 
     let user_id = user.id;
@@ -777,7 +777,7 @@ impl Perform for CreatePostReport {
     .await?
     {
       Ok(report) => report,
-      Err(_e) => return Err(APIError::err("couldnt_create_report").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_create_report").into()),
     };
 
     let res = CreatePostReportResponse { success: true };
@@ -837,7 +837,7 @@ impl Perform for ResolvePostReport {
     };
 
     if blocking(context.pool(), resolve_fun).await?.is_err() {
-      return Err(APIError::err("couldnt_resolve_report").into());
+      return Err(ApiError::err("couldnt_resolve_report").into());
     };
 
     context.chat_server().do_send(SendModRoomMessage {
index 1bdce91abd2ce7c5c77d0c171b7163a0683f9f8d..d9ed835eada32aa3b0ad7983fe8f165a737210b1 100644 (file)
@@ -51,7 +51,7 @@ use lemmy_utils::{
   settings::Settings,
   utils::{check_slurs, check_slurs_opt},
   version,
-  APIError,
+  ApiError,
   ConnectionId,
   LemmyError,
 };
@@ -168,7 +168,7 @@ impl Perform for CreateSite {
 
     let read_site = move |conn: &'_ _| Site::read_simple(conn);
     if blocking(context.pool(), read_site).await?.is_ok() {
-      return Err(APIError::err("site_already_exists").into());
+      return Err(ApiError::err("site_already_exists").into());
     };
 
     let user = get_user_from_jwt(&data.auth, context.pool()).await?;
@@ -193,7 +193,7 @@ impl Perform for CreateSite {
 
     let create_site = move |conn: &'_ _| Site::create(conn, &site_form);
     if blocking(context.pool(), create_site).await?.is_err() {
-      return Err(APIError::err("site_already_exists").into());
+      return Err(ApiError::err("site_already_exists").into());
     }
 
     let site_view = blocking(context.pool(), move |conn| SiteView::read(conn)).await??;
@@ -238,7 +238,7 @@ impl Perform for EditSite {
 
     let update_site = move |conn: &'_ _| Site::update(conn, 1, &site_form);
     if blocking(context.pool(), update_site).await?.is_err() {
-      return Err(APIError::err("couldnt_update_site").into());
+      return Err(ApiError::err("couldnt_update_site").into());
     }
 
     let site_view = blocking(context.pool(), move |conn| SiteView::read(conn)).await??;
@@ -525,13 +525,13 @@ impl Perform for TransferSite {
 
     // Make sure user is the creator
     if read_site.creator_id != user.id {
-      return Err(APIError::err("not_an_admin").into());
+      return Err(ApiError::err("not_an_admin").into());
     }
 
     let new_creator_id = data.user_id;
     let transfer_site = move |conn: &'_ _| Site::transfer(conn, new_creator_id);
     if blocking(context.pool(), transfer_site).await?.is_err() {
-      return Err(APIError::err("couldnt_update_site").into());
+      return Err(ApiError::err("couldnt_update_site").into());
     };
 
     // Mod tables
@@ -608,7 +608,7 @@ impl Perform for SaveSiteConfig {
     // Make sure docker doesn't have :ro at the end of the volume, so its not a read-only filesystem
     let config_hjson = match Settings::save_config_file(&data.config_hjson) {
       Ok(config_hjson) => config_hjson,
-      Err(_e) => return Err(APIError::err("couldnt_update_site").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_update_site").into()),
     };
 
     Ok(GetSiteConfigResponse { config_hjson })
index 93d40bdafc9527c9bbdd37a938c608e553448030..dfe527db3ab71d33150e21379c6436001e0be6f6 100644 (file)
@@ -80,7 +80,7 @@ use lemmy_utils::{
     naive_from_unix,
     remove_slurs,
   },
-  APIError,
+  ApiError,
   ConnectionId,
   LemmyError,
 };
@@ -110,13 +110,13 @@ impl Perform for Login {
     .await?
     {
       Ok(user) => user,
-      Err(_e) => return Err(APIError::err("couldnt_find_that_username_or_email").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_find_that_username_or_email").into()),
     };
 
     // Verify the password
     let valid: bool = verify(&data.password, &user.password_encrypted).unwrap_or(false);
     if !valid {
-      return Err(APIError::err("password_incorrect").into());
+      return Err(ApiError::err("password_incorrect").into());
     }
 
     // Return the jwt
@@ -140,18 +140,18 @@ impl Perform for Register {
     // Make sure site has open registration
     if let Ok(site) = blocking(context.pool(), move |conn| Site::read_simple(conn)).await? {
       if !site.open_registration {
-        return Err(APIError::err("registration_closed").into());
+        return Err(ApiError::err("registration_closed").into());
       }
     }
 
     // Password length check
     if data.password.len() > 60 {
-      return Err(APIError::err("invalid_password").into());
+      return Err(ApiError::err("invalid_password").into());
     }
 
     // Make sure passwords match
     if data.password != data.password_verify {
-      return Err(APIError::err("passwords_dont_match").into());
+      return Err(ApiError::err("passwords_dont_match").into());
     }
 
     // Check if there are admins. False if admins exist
@@ -176,7 +176,7 @@ impl Perform for Register {
         })
         .await?;
       if !check {
-        return Err(APIError::err("captcha_incorrect").into());
+        return Err(ApiError::err("captcha_incorrect").into());
       }
     }
 
@@ -184,7 +184,7 @@ impl Perform for Register {
 
     let user_keypair = generate_actor_keypair()?;
     if !is_valid_username(&data.username) {
-      return Err(APIError::err("invalid_username").into());
+      return Err(ApiError::err("invalid_username").into());
     }
     let user_actor_id = generate_apub_endpoint(EndpointType::User, &data.username)?;
 
@@ -234,7 +234,7 @@ impl Perform for Register {
           "user_already_exists"
         };
 
-        return Err(APIError::err(err_type).into());
+        return Err(ApiError::err(err_type).into());
       }
     };
 
@@ -285,7 +285,7 @@ impl Perform for Register {
 
     let follow = move |conn: &'_ _| CommunityFollower::follow(conn, &community_follower_form);
     if blocking(context.pool(), follow).await?.is_err() {
-      return Err(APIError::err("community_follower_already_exists").into());
+      return Err(ApiError::err("community_follower_already_exists").into());
     };
 
     // If its an admin, add them as a mod and follower to main
@@ -297,7 +297,7 @@ impl Perform for Register {
 
       let join = move |conn: &'_ _| CommunityModerator::join(conn, &community_moderator_form);
       if blocking(context.pool(), join).await?.is_err() {
-        return Err(APIError::err("community_moderator_already_exists").into());
+        return Err(ApiError::err("community_moderator_already_exists").into());
       }
     }
 
@@ -380,13 +380,13 @@ impl Perform for SaveUserSettings {
 
     if let Some(Some(bio)) = &bio {
       if bio.chars().count() > 300 {
-        return Err(APIError::err("bio_length_overflow").into());
+        return Err(ApiError::err("bio_length_overflow").into());
       }
     }
 
     if let Some(Some(preferred_username)) = &preferred_username {
       if !is_valid_preferred_username(preferred_username.trim()) {
-        return Err(APIError::err("invalid_username").into());
+        return Err(ApiError::err("invalid_username").into());
       }
     }
 
@@ -397,7 +397,7 @@ impl Perform for SaveUserSettings {
           Some(new_password_verify) => {
             // Make sure passwords match
             if new_password != new_password_verify {
-              return Err(APIError::err("passwords_dont_match").into());
+              return Err(ApiError::err("passwords_dont_match").into());
             }
 
             // Check the old password
@@ -405,7 +405,7 @@ impl Perform for SaveUserSettings {
               Some(old_password) => {
                 let valid: bool = verify(old_password, &user.password_encrypted).unwrap_or(false);
                 if !valid {
-                  return Err(APIError::err("password_incorrect").into());
+                  return Err(ApiError::err("password_incorrect").into());
                 }
                 let new_password = new_password.to_owned();
                 let user = blocking(context.pool(), move |conn| {
@@ -414,10 +414,10 @@ impl Perform for SaveUserSettings {
                 .await??;
                 user.password_encrypted
               }
-              None => return Err(APIError::err("password_incorrect").into()),
+              None => return Err(ApiError::err("password_incorrect").into()),
             }
           }
-          None => return Err(APIError::err("passwords_dont_match").into()),
+          None => return Err(ApiError::err("passwords_dont_match").into()),
         }
       }
       None => user.password_encrypted,
@@ -470,7 +470,7 @@ impl Perform for SaveUserSettings {
           "user_already_exists"
         };
 
-        return Err(APIError::err(err_type).into());
+        return Err(ApiError::err(err_type).into());
       }
     };
 
@@ -513,7 +513,7 @@ impl Perform for GetUserDetails {
         .await?;
         match user {
           Ok(user) => user.id,
-          Err(_e) => return Err(APIError::err("couldnt_find_that_username_or_email").into()),
+          Err(_e) => return Err(ApiError::err("couldnt_find_that_username_or_email").into()),
         }
       }
     };
@@ -607,7 +607,7 @@ impl Perform for AddAdmin {
     let added_user_id = data.user_id;
     let add_admin = move |conn: &'_ _| User_::add_admin(conn, added_user_id, added);
     if blocking(context.pool(), add_admin).await?.is_err() {
-      return Err(APIError::err("couldnt_update_user").into());
+      return Err(ApiError::err("couldnt_update_user").into());
     }
 
     // Mod tables
@@ -663,7 +663,7 @@ impl Perform for BanUser {
     let banned_user_id = data.user_id;
     let ban_user = move |conn: &'_ _| User_::ban_user(conn, banned_user_id, ban);
     if blocking(context.pool(), ban_user).await?.is_err() {
-      return Err(APIError::err("couldnt_update_user").into());
+      return Err(ApiError::err("couldnt_update_user").into());
     }
 
     // Remove their data if that's desired
@@ -811,14 +811,14 @@ impl Perform for MarkUserMentionAsRead {
     .await??;
 
     if user.id != read_user_mention.recipient_id {
-      return Err(APIError::err("couldnt_update_comment").into());
+      return Err(ApiError::err("couldnt_update_comment").into());
     }
 
     let user_mention_id = read_user_mention.id;
     let read = data.read;
     let update_mention = move |conn: &'_ _| UserMention::update_read(conn, user_mention_id, read);
     if blocking(context.pool(), update_mention).await?.is_err() {
-      return Err(APIError::err("couldnt_update_comment").into());
+      return Err(ApiError::err("couldnt_update_comment").into());
     };
 
     let user_mention_id = read_user_mention.id;
@@ -863,7 +863,7 @@ impl Perform for MarkAllAsRead {
       let reply_id = comment_view.comment.id;
       let mark_as_read = move |conn: &'_ _| Comment::update_read(conn, reply_id, true);
       if blocking(context.pool(), mark_as_read).await?.is_err() {
-        return Err(APIError::err("couldnt_update_comment").into());
+        return Err(ApiError::err("couldnt_update_comment").into());
       }
     }
 
@@ -873,13 +873,13 @@ impl Perform for MarkAllAsRead {
       .await?
       .is_err()
     {
-      return Err(APIError::err("couldnt_update_comment").into());
+      return Err(ApiError::err("couldnt_update_comment").into());
     }
 
     // Mark all private_messages as read
     let update_pm = move |conn: &'_ _| PrivateMessage::mark_all_as_read(conn, user_id);
     if blocking(context.pool(), update_pm).await?.is_err() {
-      return Err(APIError::err("couldnt_update_private_message").into());
+      return Err(ApiError::err("couldnt_update_private_message").into());
     }
 
     Ok(GetRepliesResponse { replies: vec![] })
@@ -901,20 +901,20 @@ impl Perform for DeleteAccount {
     // Verify the password
     let valid: bool = verify(&data.password, &user.password_encrypted).unwrap_or(false);
     if !valid {
-      return Err(APIError::err("password_incorrect").into());
+      return Err(ApiError::err("password_incorrect").into());
     }
 
     // Comments
     let user_id = user.id;
     let permadelete = move |conn: &'_ _| Comment::permadelete_for_creator(conn, user_id);
     if blocking(context.pool(), permadelete).await?.is_err() {
-      return Err(APIError::err("couldnt_update_comment").into());
+      return Err(ApiError::err("couldnt_update_comment").into());
     }
 
     // Posts
     let permadelete = move |conn: &'_ _| Post::permadelete_for_creator(conn, user_id);
     if blocking(context.pool(), permadelete).await?.is_err() {
-      return Err(APIError::err("couldnt_update_post").into());
+      return Err(ApiError::err("couldnt_update_post").into());
     }
 
     blocking(context.pool(), move |conn| {
@@ -947,7 +947,7 @@ impl Perform for PasswordReset {
     .await?
     {
       Ok(user) => user,
-      Err(_e) => return Err(APIError::err("couldnt_find_that_username_or_email").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_find_that_username_or_email").into()),
     };
 
     // Generate a random token
@@ -969,7 +969,7 @@ impl Perform for PasswordReset {
     let html = &format!("<h1>Password Reset Request for {}</h1><br><a href={}/password_change/{}>Click here to reset your password</a>", user.name, hostname, &token);
     match send_email(subject, user_email, &user.name, html) {
       Ok(_o) => _o,
-      Err(_e) => return Err(APIError::err(&_e).into()),
+      Err(_e) => return Err(ApiError::err(&_e).into()),
     };
 
     Ok(PasswordResetResponse {})
@@ -996,7 +996,7 @@ impl Perform for PasswordChange {
 
     // Make sure passwords match
     if data.password != data.password_verify {
-      return Err(APIError::err("passwords_dont_match").into());
+      return Err(ApiError::err("passwords_dont_match").into());
     }
 
     // Update the user with the new password
@@ -1007,7 +1007,7 @@ impl Perform for PasswordChange {
     .await?
     {
       Ok(user) => user,
-      Err(_e) => return Err(APIError::err("couldnt_update_user").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_update_user").into()),
     };
 
     // Return the jwt
@@ -1050,7 +1050,7 @@ impl Perform for CreatePrivateMessage {
     {
       Ok(private_message) => private_message,
       Err(_e) => {
-        return Err(APIError::err("couldnt_create_private_message").into());
+        return Err(ApiError::err("couldnt_create_private_message").into());
       }
     };
 
@@ -1072,7 +1072,7 @@ impl Perform for CreatePrivateMessage {
     .await?
     {
       Ok(private_message) => private_message,
-      Err(_e) => return Err(APIError::err("couldnt_create_private_message").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_create_private_message").into()),
     };
 
     updated_private_message.send_create(&user, context).await?;
@@ -1129,7 +1129,7 @@ impl Perform for EditPrivateMessage {
     })
     .await??;
     if user.id != orig_private_message.creator_id {
-      return Err(APIError::err("no_private_message_edit_allowed").into());
+      return Err(ApiError::err("no_private_message_edit_allowed").into());
     }
 
     // Doing the update
@@ -1141,7 +1141,7 @@ impl Perform for EditPrivateMessage {
     .await?
     {
       Ok(private_message) => private_message,
-      Err(_e) => return Err(APIError::err("couldnt_update_private_message").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_update_private_message").into()),
     };
 
     // Send the apub update
@@ -1188,7 +1188,7 @@ impl Perform for DeletePrivateMessage {
     })
     .await??;
     if user.id != orig_private_message.creator_id {
-      return Err(APIError::err("no_private_message_edit_allowed").into());
+      return Err(ApiError::err("no_private_message_edit_allowed").into());
     }
 
     // Doing the update
@@ -1200,7 +1200,7 @@ impl Perform for DeletePrivateMessage {
     .await?
     {
       Ok(private_message) => private_message,
-      Err(_e) => return Err(APIError::err("couldnt_update_private_message").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_update_private_message").into()),
     };
 
     // Send the apub update
@@ -1253,7 +1253,7 @@ impl Perform for MarkPrivateMessageAsRead {
     })
     .await??;
     if user.id != orig_private_message.recipient_id {
-      return Err(APIError::err("couldnt_update_private_message").into());
+      return Err(ApiError::err("couldnt_update_private_message").into());
     }
 
     // Doing the update
@@ -1265,7 +1265,7 @@ impl Perform for MarkPrivateMessageAsRead {
     .await?
     {
       Ok(private_message) => private_message,
-      Err(_e) => return Err(APIError::err("couldnt_update_private_message").into()),
+      Err(_e) => return Err(ApiError::err("couldnt_update_private_message").into()),
     };
 
     // No need to send an apub update
index 097480cf4a2bd19048389412c8ff1b135defee8e..d3d9dfb8bf7d34544fb411eae2516af4e1d13be7 100644 (file)
@@ -58,8 +58,9 @@ impl ToApub for Post {
       // https://git.asonix.dog/Aardwolf/activitystreams/issues/5
       .set_many_contexts(lemmy_context()?)
       .set_id(self.ap_id.to_owned().into_inner())
-      // Use summary field to be consistent with mastodon content warning.
-      // https://mastodon.xyz/@Louisa/103987265222901387.json
+      .set_name(self.name.to_owned())
+      // `summary` field for compatibility with lemmy v0.9.9 and older,
+      // TODO: remove this after some time
       .set_summary(self.name.to_owned())
       .set_published(convert_datetime(self.published))
       .set_many_tos(vec![community.actor_id.into_inner(), public()])
@@ -174,8 +175,11 @@ impl FromApubToForm<PageExt> for PostForm {
 
     let name = page
       .inner
-      .summary()
-      .as_ref()
+      .name()
+      .map(|s| s.map(|s2| s2.to_owned()))
+      // The following is for compatibility with lemmy v0.9.9 and older
+      // TODO: remove it after some time (along with the map above)
+      .or_else(|| page.inner.summary().map(|s| s.to_owned()))
       .context(location_info!())?
       .as_single_xsd_string()
       .context(location_info!())?
index 6d8265aa3fbb95a026077102f3356a359014f320..e64271568118e5399f858f3d1d7417a77ed4c989 100644 (file)
@@ -23,7 +23,7 @@ pub type ConnectionId = usize;
 pub type PostId = i32;
 pub type CommunityId = i32;
 pub type UserId = i32;
-pub type IPAddr = String;
+pub type IpAddr = String;
 
 #[macro_export]
 macro_rules! location_info {
@@ -39,13 +39,13 @@ macro_rules! location_info {
 
 #[derive(Debug, Error)]
 #[error("{{\"error\":\"{message}\"}}")]
-pub struct APIError {
+pub struct ApiError {
   pub message: String,
 }
 
-impl APIError {
+impl ApiError {
   pub fn err(msg: &str) -> Self {
-    APIError {
+    ApiError {
       message: msg.to_string(),
     }
   }
index 5bb02f596996fc54d0fed01c35546ee8cb0fbaf3..701d608bfb49b7d5e441c7da90afe34d0a52c327 100644 (file)
@@ -1,4 +1,4 @@
-use crate::{APIError, IPAddr, LemmyError};
+use crate::{ApiError, IpAddr, LemmyError};
 use log::debug;
 use std::{collections::HashMap, time::SystemTime};
 use strum::IntoEnumIterator;
@@ -20,13 +20,13 @@ pub(crate) enum RateLimitType {
 /// Rate limiting based on rate type and IP addr
 #[derive(Debug, Clone)]
 pub struct RateLimiter {
-  buckets: HashMap<RateLimitType, HashMap<IPAddr, RateLimitBucket>>,
+  buckets: HashMap<RateLimitType, HashMap<IpAddr, RateLimitBucket>>,
 }
 
 impl Default for RateLimiter {
   fn default() -> Self {
     Self {
-      buckets: HashMap::<RateLimitType, HashMap<IPAddr, RateLimitBucket>>::new(),
+      buckets: HashMap::<RateLimitType, HashMap<IpAddr, RateLimitBucket>>::new(),
     }
   }
 }
@@ -87,7 +87,7 @@ impl RateLimiter {
             rate_limit.allowance
           );
           Err(
-            APIError {
+            ApiError {
               message: format!(
                 "Too many requests. type: {}, IP: {}, {} per {} seconds",
                 type_.as_ref(),
index 6297435689e1633b0a51d16ad3f8fa5cfbacb81b..e0bbb88e784f7ef4c2d28e4cd6674ff946bca87a 100644 (file)
@@ -1,4 +1,4 @@
-use crate::{settings::Settings, APIError};
+use crate::{settings::Settings, ApiError};
 use actix_web::dev::ConnectionInfo;
 use chrono::{DateTime, FixedOffset, NaiveDateTime};
 use itertools::Itertools;
@@ -43,15 +43,15 @@ pub(crate) fn slur_check(test: &str) -> Result<(), Vec<&str>> {
   }
 }
 
-pub fn check_slurs(text: &str) -> Result<(), APIError> {
+pub fn check_slurs(text: &str) -> Result<(), ApiError> {
   if let Err(slurs) = slur_check(text) {
-    Err(APIError::err(&slurs_vec_to_str(slurs)))
+    Err(ApiError::err(&slurs_vec_to_str(slurs)))
   } else {
     Ok(())
   }
 }
 
-pub fn check_slurs_opt(text: &Option<String>) -> Result<(), APIError> {
+pub fn check_slurs_opt(text: &Option<String>) -> Result<(), ApiError> {
   match text {
     Some(t) => check_slurs(t),
     None => Ok(()),
index a2db1882dcfb7fb2950c570c48f1a3629ce98455..a3074cb92db6912b1ad4300e982573073ba91163 100644 (file)
@@ -1 +1 @@
-pub const VERSION: &str = "0.9.7";
+pub const VERSION: &str = "0.9.9";
index 7d1975cd73ff5ea4adfb725bf2c2824bf3ee89da..fa1d90185c344c2a22dbeff2eecede702a029563 100644 (file)
@@ -10,10 +10,10 @@ use lemmy_structs::{comment::*, post::*};
 use lemmy_utils::{
   location_info,
   rate_limit::RateLimit,
-  APIError,
+  ApiError,
   CommunityId,
   ConnectionId,
-  IPAddr,
+  IpAddr,
   LemmyError,
   PostId,
   UserId,
@@ -73,8 +73,8 @@ pub struct ChatServer {
 }
 
 pub struct SessionInfo {
-  pub addr: Recipient<WSMessage>,
-  pub ip: IPAddr,
+  pub addr: Recipient<WsMessage>,
+  pub ip: IpAddr,
 }
 
 /// `ChatServer` is an actor. It maintains list of connection client session.
@@ -395,7 +395,7 @@ impl ChatServer {
 
   fn sendit(&self, message: &str, id: ConnectionId) {
     if let Some(info) = self.sessions.get(&id) {
-      let _ = info.addr.do_send(WSMessage(message.to_owned()));
+      let _ = info.addr.do_send(WsMessage(message.to_owned()));
     }
   }
 
@@ -406,7 +406,7 @@ impl ChatServer {
   ) -> impl Future<Output = Result<String, LemmyError>> {
     let rate_limiter = self.rate_limiter.clone();
 
-    let ip: IPAddr = match self.sessions.get(&msg.id) {
+    let ip: IpAddr = match self.sessions.get(&msg.id) {
       Some(info) => info.ip.to_owned(),
       None => "blank_ip".to_string(),
     };
@@ -421,7 +421,7 @@ impl ChatServer {
     async move {
       let json: Value = serde_json::from_str(&msg.msg)?;
       let data = &json["data"].to_string();
-      let op = &json["op"].as_str().ok_or(APIError {
+      let op = &json["op"].as_str().ok_or(ApiError {
         message: "Unknown op type".to_string(),
       })?;
 
index c678a96ef202d0899497e64ea4104d4c57bf63bd..4349b01b6e30eae96fa7bf421d29ecae648491e5 100644 (file)
@@ -1,13 +1,13 @@
 use crate::UserOperation;
 use actix::{prelude::*, Recipient};
 use lemmy_structs::{comment::CommentResponse, post::PostResponse};
-use lemmy_utils::{CommunityId, ConnectionId, IPAddr, PostId, UserId};
+use lemmy_utils::{CommunityId, ConnectionId, IpAddr, PostId, UserId};
 use serde::{Deserialize, Serialize};
 
 /// Chat server sends this messages to session
 #[derive(Message)]
 #[rtype(result = "()")]
-pub struct WSMessage(pub String);
+pub struct WsMessage(pub String);
 
 /// Message for chat server communications
 
@@ -15,8 +15,8 @@ pub struct WSMessage(pub String);
 #[derive(Message)]
 #[rtype(usize)]
 pub struct Connect {
-  pub addr: Recipient<WSMessage>,
-  pub ip: IPAddr,
+  pub addr: Recipient<WsMessage>,
+  pub ip: IpAddr,
 }
 
 /// Session is disconnected
@@ -24,7 +24,7 @@ pub struct Connect {
 #[rtype(result = "()")]
 pub struct Disconnect {
   pub id: ConnectionId,
-  pub ip: IPAddr,
+  pub ip: IpAddr,
 }
 
 /// The messages sent to websocket clients
index 890b7be53599c0b07db5926137d2ed79c89d21cb..71ff36b1942bb240038757765b86b20a4ac0bf19 100644 (file)
@@ -1,6 +1,6 @@
 use crate::{
   chat_server::ChatServer,
-  messages::{Connect, Disconnect, StandardMessage, WSMessage},
+  messages::{Connect, Disconnect, StandardMessage, WsMessage},
   LemmyContext,
 };
 use actix::prelude::*;
@@ -22,7 +22,7 @@ pub async fn chat_route(
   context: web::Data<LemmyContext>,
 ) -> Result<HttpResponse, Error> {
   ws::start(
-    WSSession {
+    WsSession {
       cs_addr: context.chat_server().to_owned(),
       id: 0,
       hb: Instant::now(),
@@ -33,7 +33,7 @@ pub async fn chat_route(
   )
 }
 
-struct WSSession {
+struct WsSession {
   cs_addr: Addr<ChatServer>,
   /// unique session id
   id: usize,
@@ -43,7 +43,7 @@ struct WSSession {
   hb: Instant,
 }
 
-impl Actor for WSSession {
+impl Actor for WsSession {
   type Context = ws::WebsocketContext<Self>;
 
   /// Method is called on actor start.
@@ -87,16 +87,16 @@ impl Actor for WSSession {
 
 /// Handle messages from chat server, we simply send it to peer websocket
 /// These are room messages, IE sent to others in the room
-impl Handler<WSMessage> for WSSession {
+impl Handler<WsMessage> for WsSession {
   type Result = ();
 
-  fn handle(&mut self, msg: WSMessage, ctx: &mut Self::Context) {
+  fn handle(&mut self, msg: WsMessage, ctx: &mut Self::Context) {
     ctx.text(msg.0);
   }
 }
 
 /// WebSocket message handler
-impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for WSSession {
+impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for WsSession {
   fn handle(&mut self, result: Result<ws::Message, ws::ProtocolError>, ctx: &mut Self::Context) {
     let message = match result {
       Ok(m) => m,
@@ -143,7 +143,7 @@ impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for WSSession {
   }
 }
 
-impl WSSession {
+impl WsSession {
   /// helper method that sends ping to client every second.
   ///
   /// also this method checks heartbeats from client
index 806bca76bdff8c7664ed2d9e0dd63aeea06bedd7..da6eef5331ea7315a4bb252931ffaa4205c7c843 100644 (file)
@@ -17,7 +17,7 @@ services:
       - iframely
 
   lemmy-ui:
-    image: dessalines/lemmy-ui:0.9.7
+    image: dessalines/lemmy-ui:0.9.9
     ports:
       - "1235:1234"
     restart: always
index 72e6c5cec5172f0b875cbe88726712321024a86f..b2b5ef7ea0f4c3909e626e13ee3ad5ee35e09991 100644 (file)
@@ -29,7 +29,7 @@ services:
       - ./volumes/pictrs_alpha:/mnt
 
   lemmy-alpha-ui:
-    image: dessalines/lemmy-ui:0.9.7
+    image: dessalines/lemmy-ui:0.9.9
     environment:
       - LEMMY_INTERNAL_HOST=lemmy-alpha:8541
       - LEMMY_EXTERNAL_HOST=localhost:8541
@@ -69,7 +69,7 @@ services:
       - ./volumes/postgres_alpha:/var/lib/postgresql/data
 
   lemmy-beta-ui:
-    image: dessalines/lemmy-ui:0.9.7
+    image: dessalines/lemmy-ui:0.9.9
     environment:
       - LEMMY_INTERNAL_HOST=lemmy-beta:8551
       - LEMMY_EXTERNAL_HOST=localhost:8551
@@ -109,7 +109,7 @@ services:
       - ./volumes/postgres_beta:/var/lib/postgresql/data
 
   lemmy-gamma-ui:
-    image: dessalines/lemmy-ui:0.9.7
+    image: dessalines/lemmy-ui:0.9.9
     environment:
       - LEMMY_INTERNAL_HOST=lemmy-gamma:8561
       - LEMMY_EXTERNAL_HOST=localhost:8561
@@ -150,7 +150,7 @@ services:
 
   # An instance with only an allowlist for beta
   lemmy-delta-ui:
-    image: dessalines/lemmy-ui:0.9.7
+    image: dessalines/lemmy-ui:0.9.9
     environment:
       - LEMMY_INTERNAL_HOST=lemmy-delta:8571
       - LEMMY_EXTERNAL_HOST=localhost:8571
@@ -191,7 +191,7 @@ services:
 
   # An instance who has a blocklist, with lemmy-alpha blocked
   lemmy-epsilon-ui:
-    image: dessalines/lemmy-ui:0.9.7
+    image: dessalines/lemmy-ui:0.9.9
     environment:
       - LEMMY_INTERNAL_HOST=lemmy-epsilon:8581
       - LEMMY_EXTERNAL_HOST=localhost:8581
index c4f9c2c8a31ed10996086b5440351012d0e63109..c54e4ac6bd1c4b6829434492dd621eb33f10e417 100755 (executable)
@@ -9,8 +9,8 @@ new_tag="$1"
 # Setting the version on the front end
 cd ../../
 # Setting the version on the backend
-echo "pub const VERSION: &str = \"$new_tag\";" > "crates/api/src/version.rs"
-git add "crates/api/src/version.rs"
+echo "pub const VERSION: &str = \"$new_tag\";" > "crates/utils/src/version.rs"
+git add "crates/utils/src/version.rs"
 # Setting the version for Ansible
 echo $new_tag > "ansible/VERSION"
 git add "ansible/VERSION"
index 6b0519d0a101377420b50c481cfd9496286db6a1..5cbdc8d2904fde2711c5f9ff908bb0a8cd55e4cf 100644 (file)
@@ -12,7 +12,7 @@ services:
     restart: always
 
   lemmy:
-    image: dessalines/lemmy:0.9.7
+    image: dessalines/lemmy:0.9.9
     ports:
       - "127.0.0.1:8536:8536"
     restart: always
@@ -26,7 +26,7 @@ services:
       - iframely
 
   lemmy-ui:
-    image: dessalines/lemmy-ui:0.9.7
+    image: dessalines/lemmy-ui:0.9.9
     ports:
       - "127.0.0.1:1235:1234"
     restart: always