Complete channel API with comment and vote creation

This commit is contained in:
Gioacchino Mazzurco 2018-11-16 17:50:34 +01:00
parent ba58eba34e
commit e311b28870
No known key found for this signature in database
GPG Key ID: A1FBCA3872E87051
3 changed files with 76 additions and 0 deletions

View File

@ -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}

View File

@ -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;

View File

@ -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 );