Conversation
* Add wiki moderator management and validation * Add implementation prompt for Wiki modernization This document provides implementation guidance for modernizing the Wiki in the libretroshare submodule, focusing on a forums-style moderator system. It includes context, requirements, files to modify, testing requirements, and an implementation checklist. * Add wiki moderator management and validation (#1) * Add wiki moderator management and validation * Initial plan * Address PR review comments: improve error messages and verify token completion Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Address review feedback: enhance error messages and verify token completion Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Delete _codeql_detected_source_root * Delete Libretroshare_promp.md --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Update for Todo 3 * Create Prompt.md * Add content fetching APIs for Wiki edit merging (Todo 3) (#5) * Initial plan * Wiki: Add content fetching APIs for edit merging (Todo 3) Implement getSnapshotContent() and getSnapshotsContent() methods to enable full content merging functionality in Wiki edit dialog. Changes: - Added content fetching methods to RsWiki interface (rswiki.h) - Implemented in p3Wiki class (p3wiki.h/cc) - Uses GXS token-based requests with waitToken for synchronous fetching - Returns page content mapped by snapshot message ID These APIs enable the GUI to fetch actual page content from selected edits for diff-based merging, completing Todo 3 implementation. Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Address code review feedback for content fetching APIs - Return true for empty input in getSnapshotsContent() for consistency - Use find() instead of count() for better performance - Return true even when no snapshots found (successful zero-result operation) Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Final update: Implementation complete and verified All tasks completed: - Interface methods added to rswiki.h - Implementation in p3wiki.h/cc - Code review feedback addressed - Security checks passed Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Address code review: Update docs and clarify API limitations - Fix documentation for getSnapshotsContent() return value - Add explanatory comments about GXS API limitation requiring full fetch - Clarify that fetching all messages is necessary when GroupId is unknown Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Delete _codeql_detected_source_root * Delete Prompt.md * Fix GXS API usage in snapshot content retrieval methods (#7) * Initial plan * Fix review comments: add <set> include, populate grpIds, clear contents map Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Use consistent token-based getGroupList in getSnapshotsContent Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Document intentional behavior difference between methods Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Fix GXS API usage in snapshot content retrieval methods Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Delete _codeql_detected_source_root --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Address PR review comments: documentation and code optimizations (#9) * Initial plan * Address PR review comments: add docs, optimize addModerator, remove redundant check Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Final update: all actionable review comments addressed Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Remove unnecessary unique() call in addModerator Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Delete _codeql_detected_source_root * Fix compilation errors: disambiguate getGroupList and replace private member access * Initial plan * Fix compilation errors: disambiguate getGroupList and fix private member access Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Complete fix verification and code review Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Update src/services/p3wiki.cc Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> Co-authored-by: Akinniranye Samuel Tomiwa <benneu40@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix p3wiki.cc compilation errors: use retrieveNxsGrps and fix const-correctness * Initial plan * Fix compilation errors in p3wiki.cc Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Improve error handling in getCollectionData to match rsgenexchange.cc pattern Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Delete _codeql_detected_source_root * Add public getter for RsGenExchange::mDataStore (#19) * Initial plan * Add public getter for mDataStore and update p3wiki.cc to use it Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Complete: Fixed private member access violations Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Delete _codeql_detected_source_root --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> Co-authored-by: Akinniranye Samuel Tomiwa <benneu40@gmail.com> * Add specific Wiki event codes and classification logic * Initial plan * Add 4 new specific Wiki event codes and update notifyChanges logic - Add NEW_SNAPSHOT (0x03), NEW_COLLECTION (0x04), SUBSCRIBE_STATUS_CHANGED (0x05), NEW_COMMENT (0x06) to RsWikiEventCode enum - Update p3Wiki::notifyChanges() to distinguish NEW vs UPDATED events based on notification type - Add mKnownWikis tracking to distinguish new collections from updates - Detect comment vs snapshot messages based on RsGxsWikiCommentItem type - Handle subscribe status changes with TYPE_PROCESSED notification Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Fix nullptr check for mNewMsgItem before dynamic_cast Follow the pattern used in p3gxschannels to check for nullptr before dynamic_cast on mNewMsgItem Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Complete implementation of specific Wiki event codes Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Remove CodeQL build artifacts and update .gitignore Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Add build/ to .gitignore * Fix RsMutex constructor call - add required name parameter Initialize mKnownWikisMutex in p3Wiki constructor's initializer list with descriptive name, following the pattern used in p3GxsChannels Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Delete _codeql_detected_source_root * Initialize wiki event code for delete notifications * Initial plan * Add Wiki notification support with blocking helper methods - Add protected blocking helper methods to RsGxsIfaceHelper: * getServiceStatisticsBlocking() - synchronous service statistics retrieval * getGroupStatisticBlocking() - synchronous group statistics retrieval - Add public getWikiStatistics() method to RsWiki interface - Implement getWikiStatistics() in p3Wiki service using blocking helper Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Increase default timeout to 10 seconds for blocking helpers Address code review feedback: increase default timeout from 5 to 10 seconds to be more robust in high-load scenarios, matching similar patterns in the codebase. Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Complete Wiki notification support implementation All changes have been successfully implemented and reviewed: - Added protected blocking helper methods to RsGxsIfaceHelper - Added public getWikiStatistics() to RsWiki interface - Implemented in p3Wiki service - Addressed code review feedback (10s timeout) - Security scan passed (no vulnerabilities) Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> * Remove CodeQL temporary symlink --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: samuel-asleep <210051637+samuel-asleep@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@csoler can you please take a look at my pr |
csoler
left a comment
There was a problem hiding this comment.
Good code. Make sure to check all the comments.
| return st; | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
These two methods already exist (in the same form but slightly different names) in several GXS services that all derive from RsGxsIFaceHelper. It's fine to move them here indeed (since they do the same for all services) but they should be removed from the services (so you can keep the names without the "Blocking" suffix and therefore compilation compatibility).
See for instance p3GxsChannels -> RsGxsChannels -> RsGxsIFaceHelper and the method is p3GxsChannels::getChannelStatistics()
There was a problem hiding this comment.
Updated the helper methods to drop the ‘Blocking’ suffix (getServiceStatistics / getGroupStatistics) and kept the wiki call site aligned. Service-specific wrappers are still present where they’re part of public interfaces, but they can now delegate to the helper without new naming churn
| { | ||
| UPDATED_SNAPSHOT = 0x01, | ||
| UPDATED_COLLECTION = 0x02 | ||
| UPDATED_SNAPSHOT = 0x01, // Existing page modified |
There was a problem hiding this comment.
you can add "UNKNOWN = 0x00," so that we can initialize this type with some value that "means" something.
There was a problem hiding this comment.
Added UNKNOWN = 0x00 to RsWikiEventCode to allow meaningful default initialization
src/rsitems/rswikiitems.cc
Outdated
| for (const auto& entry : collection.mModeratorTerminationDates) | ||
| { | ||
| if (entry.second == 0) | ||
| activeModerators.push_back(entry.first); |
There was a problem hiding this comment.
I cannot check from here, but if that activeModerators list is not used anymore (since you can directly look into mModeratorTerminationDates in O(log(n))) you should also suppress it from this item type, which will simplify the serialization code quite a lot.
| if (it == collection.mModeratorTerminationDates.end()) | ||
| return false; | ||
|
|
||
| if (it->second == 0) |
There was a problem hiding this comment.
Has 0 a special meaning (0 means forever? If so, add a small comment about this), or is this test only for backward compatibility?
There was a problem hiding this comment.
Added comments clarifying that a termination timestamp of 0 means ‘active with no expiry,’ both when setting and when checking moderator status
src/services/p3wiki.cc
Outdated
| return false; | ||
|
|
||
| RsWikiCollection& collection = collections.front(); | ||
| collection.mModeratorTerminationDates[moderatorId] = time(nullptr); |
There was a problem hiding this comment.
What if the moderatorId is not already in the list? This command will add it. It's not a problem, but there's no need to add it either.
There was a problem hiding this comment.
removeModerator now checks for the ID and returns false if it doesn’t exist, so it won’t insert a new entry just to remove it
| moderators.clear(); | ||
| for (const auto& entry : collections.front().mModeratorTerminationDates) | ||
| { | ||
| if (entry.second == 0) |
There was a problem hiding this comment.
i really don't get what 0 means. Aren't you supposed to return all entries for which time(null) < entry.second ?
There was a problem hiding this comment.
Clarified with inline comments that 0 means ‘active without expiry,’ and kept the behavior consistent in getModerators and isActiveModerator. Removals set a real timestamp, so only 0 denotes active status
|
Hi think the changes in rsgenechange.h and git ignore not needed |
|
@defnax I've restored the changes made to gitignore , also rsgenexchange.h is showing in the git diff because I previously edited it when I was accessing datastore |
Summary
This PR refines wiki moderator management and snapshot retrieval by removing duplicated state, eliminating inefficient scans, and ensuring snapshot content always resolves to the latest edit in an edit hierarchy.
All actionable review feedback from #250 has been addressed.
Changes
Wiki moderator management
RsWikiCollectionnow usesmModeratorTerminationDatesas the single source of truth.0termination timestamp, eliminating redundant data structures and linear scans.Snapshot content retrieval
grpId, avoiding all-group message scans.getSnapshotContentandgetSnapshotsContentfetch only the requested message IDs (meta + data).mOrigMsgIdand returns the most recent edit by publish timestamp.Why
Review feedback addressed (from #250)
p3wiki.grpIdto snapshot APIs to scope message access correctly.mOrigMsgIdand returned the latest edit.Note:
The concern about direct
getDataStore()usage inp3wikiis acknowledged and partially addressed. Fully removing this dependency would require a broader refactor to token-based request APIs and is intentionally left out to keep this PR focused and reviewable.How tested
Notes
grpId.