diff --git a/libretroshare/src/retroshare/rsgxschannels.h b/libretroshare/src/retroshare/rsgxschannels.h index 6aa4a6081..aa89b9341 100644 --- a/libretroshare/src/retroshare/rsgxschannels.h +++ b/libretroshare/src/retroshare/rsgxschannels.h @@ -107,6 +107,14 @@ public: */ virtual bool createChannel(RsGxsChannelGroup& channel) = 0; + /** + * @brief Add a comment on a post or on another comment + * @jsonapi{development} + * @param[inout] comment + * @return false on error, true otherwise + */ + virtual bool createComment(RsGxsComment& comment) = 0; + /** * @brief Create channel post. Blocking API. * @jsonapi{development} @@ -115,6 +123,14 @@ public: */ virtual bool createPost(RsGxsChannelPost& post) = 0; + /** + * @brief createVote + * @jsonapi{development} + * @param[inout] vote + * @return false on error, true otherwise + */ + virtual bool createVote(RsGxsVote& vote) = 0; + /** * @brief Edit channel details. * @jsonapi{development} diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index 380f1d378..84610b107 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -1059,6 +1059,60 @@ bool p3GxsChannels::createChannel(RsGxsChannelGroup& channel) return true; } +bool p3GxsChannels::createComment(RsGxsComment& comment) +{ + uint32_t token; + if(!createComment(token, comment)) + { + std::cerr << __PRETTY_FUNCTION__ << "Error! Failed creating comment." + << std::endl; + return false; + } + + if(waitToken(token) != RsTokenService::COMPLETE) + { + std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed." + << std::endl; + return false; + } + + if(!RsGenExchange::getPublishedMsgMeta(token, comment.mMeta)) + { + std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting generated " + << " comment data." << std::endl; + return false; + } + + return true; +} + +bool p3GxsChannels::createVote(RsGxsVote& vote) +{ + uint32_t token; + if(!createVote(token, vote)) + { + std::cerr << __PRETTY_FUNCTION__ << "Error! Failed creating vote." + << std::endl; + return false; + } + + if(waitToken(token) != RsTokenService::COMPLETE) + { + std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed." + << std::endl; + return false; + } + + if(!RsGenExchange::getPublishedMsgMeta(token, vote.mMeta)) + { + std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting generated " + << " vote data." << std::endl; + return false; + } + + return true; +} + bool p3GxsChannels::editChannel(RsGxsChannelGroup& channel) { uint32_t token; diff --git a/libretroshare/src/services/p3gxschannels.h b/libretroshare/src/services/p3gxschannels.h index 3caf31c59..e5d49772b 100644 --- a/libretroshare/src/services/p3gxschannels.h +++ b/libretroshare/src/services/p3gxschannels.h @@ -189,12 +189,18 @@ virtual bool ExtraFileRemove(const RsFileHash &hash); /// Implementation of @see RsGxsChannels::createChannel virtual bool createChannel(RsGxsChannelGroup& channel); + /// Implementation of @see RsGxsChannels::createComment + virtual bool createComment(RsGxsComment& comment); + /// Implementation of @see RsGxsChannels::editChannel virtual bool editChannel(RsGxsChannelGroup& channel); /// Implementation of @see RsGxsChannels::createPost virtual bool createPost(RsGxsChannelPost& post); + /// Implementation of @see RsGxsChannels::createVote + virtual bool createVote(RsGxsVote& vote); + /// Implementation of @see RsGxsChannels::subscribeToChannel virtual bool subscribeToChannel( const RsGxsGroupId &groupId, bool subscribe );