-
Notifications
You must be signed in to change notification settings - Fork 2
Add post archive/unarchive support (archived flag, tools, API + client) #253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ers for the global process object, modified 5 files total
katherinee-li
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not passing npm, not enough data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds post archiving functionality to NodeBB, allowing moderators to archive and unarchive posts without deletion. The implementation includes backend storage, API endpoints, and client-side integration.
- Adds an
archivedinteger field to post objects for persistent storage - Implements backend tools and API endpoints for archive/unarchive operations
- Integrates archive/unarchive actions into the post tools menu and client handlers
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/posts/data.js | Adds archived to integer fields for post data parsing |
| src/posts/tools.js | Implements archive/unarchive methods with permission checks |
| src/api/posts.js | Adds API endpoints and shared helper for archive operations |
| src/socket.io/posts/tools.js | Includes archive field in post data and adds menu tools |
| public/src/client/topic/postTools.js | Adds client-side handlers for archive/unarchive actions |
| src/utils.js | Refactors profile/timing utilities from process to utils module |
| test/utils.js | Updates test to use new utils.profile method |
| src/user/search.js | Updates to use utils.elapsedTimeSince |
| src/search.js | Updates to use utils.elapsedTimeSince |
| src/categories/search.js | Updates to use utils.elapsedTimeSince |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| postContainer.on('click', '[component="post/archive"]', function () { | ||
| const pid = getData($(this), 'data-pid'); | ||
| postAction('archive', pid); | ||
| }); | ||
|
|
||
| postContainer.on('click', '[component="post/unarchive"]', function () { | ||
| const pid = getData($(this), 'data-pid'); | ||
| postAction('unarchive', pid); | ||
| }); | ||
| } |
Copilot
AI
Oct 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Event handlers are being attached inside an existing event handler callback, which can lead to duplicate event handlers being registered. These handlers should be moved outside the existing click handler for edit functionality.
| postContainer.on('click', '[component="post/archive"]', function () { | |
| const pid = getData($(this), 'data-pid'); | |
| postAction('archive', pid); | |
| }); | |
| postContainer.on('click', '[component="post/unarchive"]', function () { | |
| const pid = getData($(this), 'data-pid'); | |
| postAction('unarchive', pid); | |
| }); | |
| } | |
| } | |
| }); | |
| postContainer.on('click', '[component="post/archive"]', function () { | |
| const pid = getData($(this), 'data-pid'); | |
| postAction('archive', pid); | |
| }); | |
| postContainer.on('click', '[component="post/unarchive"]', function () { | |
| const pid = getData($(this), 'data-pid'); | |
| postAction('unarchive', pid); |
| return c1.order - c2.order; | ||
| }); | ||
| searchResult.timing = (process.elapsedTimeSince(startTime) / 1000).toFixed(2); | ||
| searchResult.timing = (utils.elapsedTimeSince(startTime) / 1000).toFixed(2); |
Copilot
AI
Oct 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation - this line should maintain the same indentation as the surrounding code (appears to be missing a tab).
| searchResult.timing = (utils.elapsedTimeSince(startTime) / 1000).toFixed(2); | |
| searchResult.timing = (utils.elapsedTimeSince(startTime) / 1000).toFixed(2); |
|
|
||
|
|
Copilot
AI
Oct 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary blank lines should be removed to maintain clean code formatting.
Description
This change introduces a lightweight post archiving feature so posts can be archived and unarchived without being deleted or purged.
What I changed
Added a persistent archived integer field to post objects so archives are stored on posts:
Backend helpers to archive/unarchive posts:
API endpoints for archive/unarchive:
Socket/menu support for post tools:
Client integration:
Why
API
Websocket events
Notes, assumptions, and rationale
Files changed (high-level)
How to test (manual)
Quick curl example (RPC/HTTP mapping may vary depending on server config but the API layer supports these calls):
Follow-ups / TODO
Changelog entry (one-liner) Add post archive/unarchive support (archived flag, posts.tools, API + client)