Skip to content

Releases: leafo/lapis-community

v1.44.3 - Improve Category Deletion

08 Jul 19:34

Choose a tag to compare

Added

  • Added a new relation bans to the Categories model.
  • Added a new relation pending_posts to the CommunityUsers model.

Changed

  • The set_children method in the categories flow has been updated to handle preserving nested non-empty categories within empty categories. This change ensures that when a parent category is empty but contains a non-empty child category, the child category is preserved, archived, and hidden, while the parent category is deleted.

  • The delete method for categories has been updated to properly delete categories. This includes deleting all related data in the database, such as topics, subscriptions, bans, moderators, activity logs, category tags, category post logs, and category group categories.

  • The delete method in the topics model has been updated to clean up more tables and use the model.delete method. This includes deleting related data in the database, such as pending posts, topic participants, user topic last seens, bans, subscriptions, and bookmarks.

  • The hard_delete method in the pending_posts model has been updated to also delete related activity logs when a pending post is hard deleted.

Misc

  • Updated test suite to more carefully verify queries when performing deletion operations

v1.44.2 - Minor update

23 Jun 18:09

Choose a tag to compare

No schema change, no migrations necessary

Changes

  • PendingPostsFlow
    • Return post on promote, nil, error otherwise
  • ModerationLogs
    • Add Posts as an available object type

v1.44.1 - Add "before_create_callback" to enable finer control of posting permissions

12 Apr 00:16

Choose a tag to compare

luarocks install lapis-community

Migration

Minor update, no migration necessary

Changes

  • Posts Flow
    • Introduce before_create_callback option for new_post and before_edit_callback for edit_post. Both of these callbacks, when provided as part of the options argument, are functions that take a single argument of the object that is about to be created or edited. The object can be mutated to modify the post before it is saved into the database. The needs_approval field can be used within before_create_callback to force the post to be pending. The approval_note field can be used to tag the pending post with a message in the metadata
  • Topics Flow
    • Introduce the before_create_callback for the new_topic method. Works the same way as the posts flow callback as described above.

Full Changelog: v1.44.0...v1.44.1

v1.44.0 - Warnings for community users

16 Mar 03:08

Choose a tag to compare

Migrate:

require("community.schema").run_migrations(44)

Additions

  • Add Warnings model for temporarily limiting posting ability on accounts

Warnings

  • restriction Enum:
    • notify: user is displayed warning but they can function normally
    • block_posting: user is blocked from posting
    • pending_posting: user's posts are pending moderation
  • Methods
    • is_active method to check if the warning is still active based on its expiration date.
    • has_started method to check if the warning has started by verifying if the first_seen_at field is not nil.
    • start_warning method to start the warning when the user views it for the first time. The method sets the first_seen_at field and calculates the expires_at field based on the warning duration.
    • end_warning method to immediately end the warning if it's not already over. This method updates the first_seen_at and expires_at fields accordingly.

Changes

  • Add risky and ignored enum values for pending post state
  • A blocked user can no longer reply to the posts of a user who has blocked them
  • Implement VirtualModel interface for handling parameterized relations. Example: A PostViewers virtual model represents a post combined with a user, which contains a set of relations for the user's status with that post, like their votes, likes, bans, etc. A virtual model instance only exists in memory for the sake of preloading and caching loaded data via the relations defined on the virtual model.
  • Appropriate models will use the new virtual model interfaces where possible to avoid triggering additional queries. See the model-specific notes below.

Categories

  • Add CategoryViewers virtual model class to represent category viewer with following relations: moderator, member, subscription, ban, last_seen
  • Added with_user method to Categories class for loading the CategoryViewers object with the specified user ID.
  • Update find_moderator, find_member, and find_ban methods to search for the closest moderator/member/ban up the ancestor chain using the CategoryViewers virtual model (previously it would select any ban/membership/etc. in the hierarchy with no specific ordering)
  • Update is_subscribed method to use CategoryViewers virtual model instead of memoized query on Subscriptions model
  • Update topic_needs_approval method to check if user has warning and needs approval
  • Update allowed_to_post_topic, allowed_to_edit, allowed_to_edit_moderators, and is_member methods all user the new ancestor hierarchy lookup and category viewers object
  • Remove get_ban in favor of find_ban method
  • find_last_seen_for_user method now uses CategoryViewers virtual model
  • Update has_unread to use category viewers

Topics

  • Add TopicViewers virtual model class to handle topic viewer with following relations: subscription, bookmark, last_seen, ban
  • Add with_user method in Topics class for loading TopicViewers object with the specified user ID.
  • Update allowed_to_view, allowed_to_edit, and allowed_to_moderate methods in Topics class to not use memoization, instead to depend on relation caching with virtual model
  • get_ban method uses virtual model with_user method.
  • has_unread method uses virtual model with_user method.
  • post_needs_approval method checks for warning on user and returns it
  • Updat get_bookmark, find_subscription, and is_subscribed methods in Topics class to use with_user virtual model

Posts

  • Add PostViewers virtual model class to Posts to handle post viewer with following relations: block_given, block_received, vote
  • Add with_viewing_user method in Posts class for loading PostViewers object with the specified user ID.
  • Added get_block method in Posts class as unified interface to load a block given by the viewing user
  • Added get_vote method in Posts class as unified interface to load vote given by the user to the post

Full Changelog: v1.43.0...v1.44.0

v1.43.0

08 Feb 21:24

Choose a tag to compare

Migrate:

require("community.schema").run_migrations(43)

Additions

  • Add data field to Categories model for implementing sites to store category metadata on

Full Changelog: v1.42.2...v1.43.0

v1.42.2

14 Jan 06:56

Choose a tag to compare

This is a minor version increment, no migrations necessary.

  • Minimum Lapis version is now 1.12
  • Rewrite parameter validation to use Lapis 1.12 style
  • Remove many utility functions that are no longer necessary with modern Lapis API
  • community.flows.posts new_post method can now take options, currently only one option force_pending to always make post as PendingPost
  • community.flows.topics new_topic method can now take options, currently only one option force_pending to always make topic as PendingPost

v1.42.1

29 Nov 22:45

Choose a tag to compare

This is a minor update that fixes a few bugs. No migrations necessary.

  • Fix bug where BrowsingFlow:preview_category_topics could sometimes not return latest topics due in incorrect sort direction in sub-query
  • Fix typo in error message regarding post:has_replies
  • Fix issue where specs would fail on latest version of busted

Full Changelog: v1.42.0...v1.42.1

v1.42.0

19 Jan 00:31

Choose a tag to compare

Migrate:

require("community.schema").run_migrations(42)

Additions

  • PendingPosts model now has a reason enum for marking why the post was put into pending
  • ActivityLogs model now stores IP address on creation
  • Add object type & actions for pending posts to ActivityLogs
  • Add a PendingPostsFlow for handling promoting and deleting a pending posts while creating relevant activity log

Changes

  • Moved the method for fetching current user IP address from Votes to CommunityUser, If you have overridden this method you must update where you place your implementation
  • Remove the create_pending_topic activity log action from category object type. Note: This version's migration will erase all activity logs that were created with this action.
  • Remove the unused publishable column from ActivityLogs
  • Remove invalid unused relation for category on ActivityLogs

Misc

  • Update test suite to no longer use unecessary use_test_env
  • Posting specs check for activity logs when creating pending posts

v1.41.0

10 Jan 01:17

Choose a tag to compare

Migrate:

require("community.schema").run_migrations(41)

Due to the changes in how topics_count and posts_count is calculated it is recommend to recount all the community users: (Note this query may be expensive depending on your database, review the query in the code and plan accordingly)

require("community.models").CommunityUsers:recount()

Additions

  • PendingPosts model is now ready for use
    • topic:post_needs_approval(user, post_data) method is called before creating a post in a topic to see if it should be created as a pending post instead
    • category:topic_needs_approval(user, post_data) method is called before creating topic in category to see if it should be created as pending post instead
    • instances of PendingPosts can be promoted to real posts by the promote method, which will delete the PendingPost after successfully promoting it
  • Module community.version now returns the correct version
  • Add purge_reports method to CommunityUsers to clean up any reports made by that user

Changes

  • posts_count on CommunityUsers will now plainly count all posts created by that user that aren't soft-deleted or moderation events. Previously posts that were considered a topic post would not be counted.
  • topics_count on CommunityUsers will no longer increment for permanent topics. (It's assumed permanent topics are not explicitly created by the user but implicitly exist for other objects eg. comments thread)
  • purge_posts and purge_votes methods on CommunityUsers deletes objects in batches and returned the total number of items removed
  • Fix error thrown where slug could not be generated for category tag name (such as emoji name)

v1.40.0

14 Jun 20:58

Choose a tag to compare

Migrate:

require("community.schema").run_migrations(40)

Additions

  • Add description field to category_tags

Changes

  • The data column on activity_logs table is now type jsonb
  • Category flow validation for editing & creating categories has been rewritten
    • All fields are assumed to be required by default, flow methods now take a field list of fields you wish to process when doing update or create
    • Empty or missing values will now null out fields, including enums like voting_type, membership_type, etc.
    • Validations now use the shapes validations, correctly handling trimming and length requirements, trailing empty html is stripped on description and rules
  • The activity log for editing a category will now include the names of the fields that were updated
    • Activity log correctly checks for both changes to tags and fields on the category model
  • Category flow set_children updated for shapes style validations
  • Category flow set_tags updated for shapes style validation

Misc

  • TestApp removed from test suite, in_request used everywhere now