Releases: leafo/lapis-community
v1.44.3 - Improve Category Deletion
Added
- Added a new relation
bansto theCategoriesmodel. - Added a new relation
pending_poststo theCommunityUsersmodel.
Changed
-
The
set_childrenmethod in thecategoriesflow 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
deletemethod 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
deletemethod in thetopicsmodel has been updated to clean up more tables and use themodel.deletemethod. This includes deleting related data in the database, such as pending posts, topic participants, user topic last seens, bans, subscriptions, and bookmarks. -
The
hard_deletemethod in thepending_postsmodel 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
No schema change, no migrations necessary
Changes
PendingPostsFlow- Return post on promote,
nil, errorotherwise
- Return post on promote,
ModerationLogs- Add
Postsas an available object type
- Add
v1.44.1 - Add "before_create_callback" to enable finer control of posting permissions
luarocks install lapis-communityMigration
Minor update, no migration necessary
Changes
- Posts Flow
- Introduce
before_create_callbackoption fornew_postandbefore_edit_callbackforedit_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. Theneeds_approvalfield can be used withinbefore_create_callbackto force the post to be pending. Theapproval_notefield can be used to tag the pending post with a message in the metadata
- Introduce
- Topics Flow
- Introduce the
before_create_callbackfor thenew_topicmethod. Works the same way as the posts flow callback as described above.
- Introduce the
Full Changelog: v1.44.0...v1.44.1
v1.44.0 - Warnings for community users
Migrate:
require("community.schema").run_migrations(44)Additions
- Add
Warningsmodel for temporarily limiting posting ability on accounts
Warnings
restrictionEnum:notify: user is displayed warning but they can function normallyblock_posting: user is blocked from postingpending_posting: user's posts are pending moderation
- Methods
is_activemethod to check if the warning is still active based on its expiration date.has_startedmethod to check if the warning has started by verifying if thefirst_seen_atfield is notnil.start_warningmethod to start the warning when the user views it for the first time. The method sets thefirst_seen_atfield and calculates theexpires_atfield based on the warning duration.end_warningmethod to immediately end the warning if it's not already over. This method updates thefirst_seen_atandexpires_atfields accordingly.
Changes
- Add
riskyandignoredenum 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
PostViewersvirtual 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
CategoryViewersvirtual model class to represent category viewer with following relations:moderator,member,subscription,ban,last_seen - Added
with_usermethod to Categories class for loading the CategoryViewers object with the specified user ID. - Update
find_moderator,find_member, andfind_banmethods to search for the closest moderator/member/ban up the ancestor chain using theCategoryViewersvirtual model (previously it would select any ban/membership/etc. in the hierarchy with no specific ordering) - Update
is_subscribedmethod to useCategoryViewersvirtual model instead of memoized query on Subscriptions model - Update
topic_needs_approvalmethod to check if user has warning and needs approval - Update
allowed_to_post_topic,allowed_to_edit,allowed_to_edit_moderators, andis_membermethods all user the new ancestor hierarchy lookup and category viewers object - Remove
get_banin favor offind_banmethod find_last_seen_for_usermethod now usesCategoryViewersvirtual model- Update
has_unreadto use category viewers
Topics
- Add
TopicViewersvirtual model class to handle topic viewer with following relations:subscription,bookmark,last_seen,ban - Add
with_usermethod in Topics class for loading TopicViewers object with the specified user ID. - Update
allowed_to_view,allowed_to_edit, andallowed_to_moderatemethods in Topics class to not use memoization, instead to depend on relation caching with virtual model get_banmethod uses virtual modelwith_usermethod.has_unreadmethod uses virtual modelwith_usermethod.post_needs_approvalmethod checks for warning on user and returns it- Updat
get_bookmark,find_subscription, andis_subscribedmethods in Topics class to usewith_uservirtual model
Posts
- Add
PostViewersvirtual model class to Posts to handle post viewer with following relations:block_given,block_received,vote - Add
with_viewing_usermethod in Posts class for loading PostViewers object with the specified user ID. - Added
get_blockmethod in Posts class as unified interface to load a block given by the viewing user - Added
get_votemethod 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
Migrate:
require("community.schema").run_migrations(43)Additions
- Add
datafield to Categories model for implementing sites to store category metadata on
Full Changelog: v1.42.2...v1.43.0
v1.42.2
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.postsnew_postmethod can now take options, currently only one optionforce_pendingto always make post as PendingPostcommunity.flows.topicsnew_topicmethod can now take options, currently only one optionforce_pendingto always make topic as PendingPost
v1.42.1
This is a minor update that fixes a few bugs. No migrations necessary.
- Fix bug where
BrowsingFlow:preview_category_topicscould 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
Migrate:
require("community.schema").run_migrations(42)Additions
PendingPostsmodel now has areasonenum for marking why the post was put into pendingActivityLogsmodel now stores IP address on creation- Add object type & actions for pending posts to
ActivityLogs - Add a
PendingPostsFlowfor handling promoting and deleting a pending posts while creating relevant activity log
Changes
- Moved the method for fetching current user IP address from
VotestoCommunityUser, If you have overridden this method you must update where you place your implementation - Remove the
create_pending_topicactivity 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
publishablecolumn fromActivityLogs - 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
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
PendingPostsmodel is now ready for usetopic: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 insteadcategory: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
PendingPostscan be promoted to real posts by thepromotemethod, which will delete thePendingPostafter successfully promoting it
- Module
community.versionnow returns the correct version - Add
purge_reportsmethod toCommunityUsersto clean up any reports made by that user
Changes
posts_countonCommunityUserswill 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_countonCommunityUserswill no longer increment forpermanenttopics. (It's assumed permanent topics are not explicitly created by the user but implicitly exist for other objects eg. comments thread)purge_postsandpurge_votesmethods onCommunityUsersdeletes 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
Migrate:
require("community.schema").run_migrations(40)Additions
- Add
descriptionfield tocategory_tags
Changes
- The
datacolumn onactivity_logstable is now typejsonb - 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
descriptionandrules
- 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_childrenupdated for shapes style validations - Category flow
set_tagsupdated for shapes style validation
Misc
- TestApp removed from test suite,
in_requestused everywhere now