diff --git a/libretroshare/src/retroshare/rsgxschannels.h b/libretroshare/src/retroshare/rsgxschannels.h index c31eb011f..6b4f5e66a 100644 --- a/libretroshare/src/retroshare/rsgxschannels.h +++ b/libretroshare/src/retroshare/rsgxschannels.h @@ -333,6 +333,19 @@ public: std::vector& posts, std::vector& comments ) = 0; + /** + * @brief Get channel comments corresponding to the given IDs. + * If the set is empty, nothing is returned. + * @jsonapi{development} + * @param channelId id of the channel of which the content is requested + * @param contentIds ids of requested contents + * @param comments storage for the comments + * @return false if something failed, true otherwhise + */ + virtual bool getChannelComments(const RsGxsGroupId &channelId, + const std::set &contentIds, + std::vector &comments) = 0; + /** * @brief Get channel content summaries * @jsonapi{development} diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index 9e0072d5b..a813c92e8 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -1137,11 +1137,30 @@ bool p3GxsChannels::getChannelContent( const RsGxsGroupId& channelId, msgIds[channelId] = contentIds; if( !requestMsgInfo(token, opts, msgIds) || waitToken(token) != RsTokenService::COMPLETE ) - return false; + return false; return getPostData(token, posts, comments); } +bool p3GxsChannels::getChannelComments(const RsGxsGroupId &channelId, + const std::set &contentIds, + std::vector &comments) +{ + std::vector msgIds; + for (auto& msg:contentIds) + msgIds.push_back(RsGxsGrpMsgIdPair(channelId,msg)); + + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA; + opts.mOptions = RS_TOKREQOPT_MSG_THREAD | RS_TOKREQOPT_MSG_LATEST; + + uint32_t token; + if( !requestMsgRelatedInfo(token, opts, msgIds) || waitToken(token) != RsTokenService::COMPLETE ) + return false; + + return getRelatedComments(token,comments); +} + bool p3GxsChannels::createChannelV2( const std::string& name, const std::string& description, const RsGxsImage& thumbnail, const RsGxsId& authorId, diff --git a/libretroshare/src/services/p3gxschannels.h b/libretroshare/src/services/p3gxschannels.h index 843023fb8..d85372e65 100644 --- a/libretroshare/src/services/p3gxschannels.h +++ b/libretroshare/src/services/p3gxschannels.h @@ -196,6 +196,11 @@ virtual bool ExtraFileRemove(const RsFileHash &hash); std::vector& posts, std::vector& comments ) override; + /// Implementation of @see RsGxsChannels::getChannelComments + virtual bool getChannelComments(const RsGxsGroupId &channelId, + const std::set &contentIds, + std::vector &comments) override; + /// Implementation of @see RsGxsChannels::getContentSummaries bool getContentSummaries( const RsGxsGroupId& channelId, diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index 5678cb018..b2a1d54c2 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -385,13 +385,13 @@ void GxsChannelPostItem::loadComment() std::vector posts; std::vector comments; - if(! rsGxsChannels->getChannelContent( groupId(),msgIds,posts,comments)) + if(! rsGxsChannels->getChannelComments( groupId(),msgIds,comments)) { RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl; return; } - int comNb = comments.size(); + int comNb = comments.size(); RsQThreadUtils::postToObject( [comNb,this]() {