mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-29 08:37:36 -04:00
GxsChannels optimizable API
This commit is contained in:
parent
bdf9bd5c56
commit
7113eb7bfc
3 changed files with 58 additions and 17 deletions
|
@ -197,17 +197,28 @@ public:
|
||||||
std::vector<RsGxsChannelGroup>& channelsInfo ) = 0;
|
std::vector<RsGxsChannelGroup>& channelsInfo ) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get content of specified channels. Blocking API
|
* @brief Get channel contents
|
||||||
* @jsonapi{development}
|
* @jsonapi{development}
|
||||||
* @param[in] chanIds id of the channels of which the content is requested
|
* @param[in] channelId id of the channel of which the content is requested
|
||||||
* @param[out] posts storage for the posts
|
* @param[in] contentsIds ids of requested contents
|
||||||
|
* @param[out] posts storage for posts
|
||||||
* @param[out] comments storage for the comments
|
* @param[out] comments storage for the comments
|
||||||
* @return false if something failed, true otherwhise
|
* @return false if something failed, true otherwhise
|
||||||
*/
|
*/
|
||||||
virtual bool getChannelsContent(
|
virtual bool getChannelContent( const RsGxsGroupId& channelId,
|
||||||
const std::list<RsGxsGroupId>& chanIds,
|
const std::set<RsGxsMessageId>& contentsIds,
|
||||||
std::vector<RsGxsChannelPost>& posts,
|
std::vector<RsGxsChannelPost>& posts,
|
||||||
std::vector<RsGxsComment>& comments ) = 0;
|
std::vector<RsGxsComment>& comments ) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get channel content summaries
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[in] channelId id of the channel of which the content is requested
|
||||||
|
* @param[out] summaries storage for summaries
|
||||||
|
* @return false if something failed, true otherwhise
|
||||||
|
*/
|
||||||
|
virtual bool getContentSummaries( const RsGxsGroupId& channelId,
|
||||||
|
std::vector<RsMsgMetaData>& summaries ) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Toggle post read status. Blocking API.
|
* @brief Toggle post read status. Blocking API.
|
||||||
|
|
|
@ -1016,16 +1016,42 @@ bool p3GxsChannels::getChannelsInfo(
|
||||||
return getGroupData(token, channelsInfo);
|
return getGroupData(token, channelsInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3GxsChannels::getChannelsContent(
|
bool p3GxsChannels::getContentSummaries(
|
||||||
const std::list<RsGxsGroupId>& chanIds,
|
const RsGxsGroupId& channelId, std::vector<RsMsgMetaData>& summaries )
|
||||||
std::vector<RsGxsChannelPost>& posts,
|
{
|
||||||
std::vector<RsGxsComment>& comments )
|
uint32_t token;
|
||||||
|
RsTokReqOptions opts;
|
||||||
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_META;
|
||||||
|
|
||||||
|
std::list<RsGxsGroupId> channelIds;
|
||||||
|
channelIds.push_back(channelId);
|
||||||
|
|
||||||
|
if( !requestMsgInfo(token, opts, channelIds) ||
|
||||||
|
waitToken(token, std::chrono::seconds(5)) != RsTokenService::COMPLETE )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
GxsMsgMetaMap metaMap;
|
||||||
|
bool res = RsGenExchange::getMsgMeta(token, metaMap);
|
||||||
|
summaries = metaMap[channelId];
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool p3GxsChannels::getChannelContent( const RsGxsGroupId& channelId,
|
||||||
|
const std::set<RsGxsMessageId>& contentsIds,
|
||||||
|
std::vector<RsGxsChannelPost>& posts,
|
||||||
|
std::vector<RsGxsComment>& comments )
|
||||||
{
|
{
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||||
if( !requestMsgInfo(token, opts, chanIds)
|
|
||||||
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
|
GxsMsgReq msgIds;
|
||||||
|
msgIds[channelId] = contentsIds;
|
||||||
|
|
||||||
|
if( !requestMsgInfo(token, opts, msgIds) ||
|
||||||
|
waitToken(token) != RsTokenService::COMPLETE ) return false;
|
||||||
|
|
||||||
return getPostData(token, posts, comments);
|
return getPostData(token, posts, comments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,10 +186,14 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
|
||||||
std::vector<RsGxsChannelGroup>& channelsInfo );
|
std::vector<RsGxsChannelGroup>& channelsInfo );
|
||||||
|
|
||||||
/// Implementation of @see RsGxsChannels::getChannelContent
|
/// Implementation of @see RsGxsChannels::getChannelContent
|
||||||
virtual bool getChannelsContent(
|
virtual bool getChannelContent( const RsGxsGroupId& channelId,
|
||||||
const std::list<RsGxsGroupId>& chanIds,
|
const std::set<RsGxsMessageId>& contentsIds,
|
||||||
std::vector<RsGxsChannelPost>& posts,
|
std::vector<RsGxsChannelPost>& posts,
|
||||||
std::vector<RsGxsComment>& comments );
|
std::vector<RsGxsComment>& comments );
|
||||||
|
|
||||||
|
/// Implementation of @see RsGxsChannels::getContentSummaries
|
||||||
|
virtual bool getContentSummaries( const RsGxsGroupId& channelId,
|
||||||
|
std::vector<RsMsgMetaData>& summaries );
|
||||||
|
|
||||||
/// Implementation of @see RsGxsChannels::createChannel
|
/// Implementation of @see RsGxsChannels::createChannel
|
||||||
virtual bool createChannel(RsGxsChannelGroup& channel);
|
virtual bool createChannel(RsGxsChannelGroup& channel);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue