mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-04 09:05:34 -05:00
Increase waitToken interval for channel creation
Creating GXS groups imply a bunch of crypto operations that require lot of time expecially on embedded device, channel creation was reported as failed while it was still pending. Reduce too long lines. Print API error messages also on std::cerr.
This commit is contained in:
parent
81f73aaf44
commit
4d703b9df9
@ -185,9 +185,10 @@ class NetInterface;
|
||||
**/
|
||||
class PQInterface: public RateInterface
|
||||
{
|
||||
public:
|
||||
explicit PQInterface(const RsPeerId &id) :traf_in(0), traf_out(0),peerId(id) { return; }
|
||||
virtual ~PQInterface() { return; }
|
||||
public:
|
||||
explicit PQInterface(const RsPeerId &id) :
|
||||
traf_in(0), traf_out(0), peerId(id) {}
|
||||
virtual ~PQInterface() {}
|
||||
|
||||
/*!
|
||||
* allows user to send RsItems to a particular facility (file, network)
|
||||
|
@ -104,58 +104,80 @@ public:
|
||||
/**
|
||||
* @brief Create channel. Blocking API.
|
||||
* @jsonapi{development}
|
||||
* @param[in] name Name of the channel
|
||||
* @param[in] description Description of the channel
|
||||
* @param[in] thumbnail Optional image to show as channel thumbnail.
|
||||
* @param[in] authorId Optional id of the author. Leave empty for an anonymous channel.
|
||||
* @param[in] circleType Optional visibility rule, default public.
|
||||
* @param[in] circleId If the channel is not public specify the id of the circle who can see the channel. Depending on the value you pass for
|
||||
* circleType this should be be an external circle if EXTERNAL is passed, a
|
||||
* local friend group id if NODES_GROUP is passed, empty otherwise.
|
||||
* @param[out] channelId Optional storage for the id of the created channel, meaningful only if creations succeeds.
|
||||
* @param[out] errorMessage Optional storage for error messsage, meaningful only if creation fail.
|
||||
* @param[in] name Name of the channel
|
||||
* @param[in] description Description of the channel
|
||||
* @param[in] thumbnail Optional image to show as channel thumbnail.
|
||||
* @param[in] authorId Optional id of the author. Leave empty for an
|
||||
* anonymous channel.
|
||||
* @param[in] circleType Optional visibility rule, default public.
|
||||
* @param[in] circleId If the channel is not public specify the id of
|
||||
* the circle who can see the channel. Depending on
|
||||
* the value you pass for
|
||||
* circleType this should be be an external circle
|
||||
* if EXTERNAL is passed, a local friend group id
|
||||
* if NODES_GROUP is passed, empty otherwise.
|
||||
* @param[out] channelId Optional storage for the id of the created
|
||||
* channel, meaningful only if creations succeeds.
|
||||
* @param[out] errorMessage Optional storage for error messsage, meaningful
|
||||
* only if creation fail.
|
||||
* @return False on error, true otherwise.
|
||||
*/
|
||||
virtual bool createChannelV2(const std::string& name,
|
||||
const std::string& description,
|
||||
const RsGxsImage& thumbnail = RsGxsImage(),
|
||||
const RsGxsId& authorId = RsGxsId(),
|
||||
RsGxsCircleType circleType = RsGxsCircleType::PUBLIC,
|
||||
const RsGxsCircleId& circleId = RsGxsCircleId(),
|
||||
RsGxsGroupId& channelGroupId = RS_DEFAULT_STORAGE_PARAM(RsGxsGroupId),
|
||||
std::string& errorMessage = RS_DEFAULT_STORAGE_PARAM(std::string) ) = 0;
|
||||
virtual bool createChannelV2(
|
||||
const std::string& name,
|
||||
const std::string& description,
|
||||
const RsGxsImage& thumbnail = RsGxsImage(),
|
||||
const RsGxsId& authorId = RsGxsId(),
|
||||
RsGxsCircleType circleType = RsGxsCircleType::PUBLIC,
|
||||
const RsGxsCircleId& circleId = RsGxsCircleId(),
|
||||
RsGxsGroupId& channelGroupId = RS_DEFAULT_STORAGE_PARAM(RsGxsGroupId),
|
||||
std::string& errorMessage = RS_DEFAULT_STORAGE_PARAM(std::string)
|
||||
) = 0;
|
||||
|
||||
/**
|
||||
* @brief Add a comment on a post or on another comment. Blocking API.
|
||||
* @jsonapi{development}
|
||||
* @param[in] channelId Id of the channel in which the comment is to be posted
|
||||
* @param[in] threadId Id of the post (that is a thread) in the channel where the comment is placed
|
||||
* @param[in] parentId Id of the parent of the comment that is either a channel post Id or the Id of another comment.
|
||||
* @param[in] channelId Id of the channel in which the comment is to be
|
||||
* posted
|
||||
* @param[in] threadId Id of the post (that is a thread) in the channel
|
||||
* where the comment is placed
|
||||
* @param[in] parentId Id of the parent of the comment that is either a
|
||||
* channel post Id or the Id of another comment.
|
||||
* @param[in] authorId Id of the author of the comment
|
||||
* @param[in] comment UTF-8 string containing the comment itself
|
||||
* @param[out] commentMessageId Optional storage for the id of the comment that was created, meaningful only on success.
|
||||
* @param[out] errorMessage Optional storage for error message, meaningful only on failure.
|
||||
* @param[in] comment UTF-8 string containing the comment itself
|
||||
* @param[out] commentMessageId Optional storage for the id of the comment
|
||||
* that was created, meaningful only on success.
|
||||
* @param[out] errorMessage Optional storage for error message, meaningful
|
||||
* only on failure.
|
||||
* @return false on error, true otherwise
|
||||
*/
|
||||
virtual bool createCommentV2(const RsGxsGroupId& channelId,
|
||||
const RsGxsMessageId& threadId,
|
||||
const RsGxsMessageId& parentId,
|
||||
const RsGxsId& authorId,
|
||||
const std::string& comment,
|
||||
RsGxsMessageId& commentMessageId = RS_DEFAULT_STORAGE_PARAM(RsGxsMessageId),
|
||||
std::string& errorMessage = RS_DEFAULT_STORAGE_PARAM(std::string) )=0;
|
||||
virtual bool createCommentV2(
|
||||
const RsGxsGroupId& channelId,
|
||||
const RsGxsMessageId& threadId,
|
||||
const RsGxsMessageId& parentId,
|
||||
const RsGxsId& authorId,
|
||||
const std::string& comment,
|
||||
RsGxsMessageId& commentMessageId = RS_DEFAULT_STORAGE_PARAM(RsGxsMessageId),
|
||||
std::string& errorMessage = RS_DEFAULT_STORAGE_PARAM(std::string)
|
||||
) = 0;
|
||||
|
||||
/**
|
||||
* @brief Create channel post. Blocking API.
|
||||
* @jsonapi{development}
|
||||
* @param[in] channelId Id of the channel where to put the post. Beware you need publish rights on that channel to post.
|
||||
* @param[in] channelId Id of the channel where to put the post. Beware
|
||||
* you need publish rights on that channel to post.
|
||||
* @param[in] title Title of the post
|
||||
* @param[in] mBody Text content of the post
|
||||
* @param[in] files Optional list of attached files. These are supposed to be already shared, @see ExtraFileHash() below otherwise.
|
||||
* @param[in] files Optional list of attached files. These are
|
||||
* supposed to be already shared,
|
||||
* @see ExtraFileHash() below otherwise.
|
||||
* @param[in] thumbnail Optional thumbnail image for the post.
|
||||
* @param[in] origPostId If this is supposed to replace an already existent post, the id of the old post. If left blank a new post will be created.
|
||||
* @param[out] postId Optional storage for the id of the created post, meaningful only on success.
|
||||
* @param[out] errorMessage Optional storage for the error message, meaningful only on failure.
|
||||
* @param[in] origPostId If this is supposed to replace an already
|
||||
* existent post, the id of the old post. If left
|
||||
* blank a new post will be created.
|
||||
* @param[out] postId Optional storage for the id of the created post,
|
||||
* meaningful only on success.
|
||||
* @param[out] errorMessage Optional storage for the error message,
|
||||
* meaningful only on failure.
|
||||
* @return false on error, true otherwise
|
||||
*/
|
||||
virtual bool createPostV2(
|
||||
@ -171,13 +193,17 @@ public:
|
||||
* @brief Create a vote
|
||||
* @jsonapi{development}
|
||||
* @param[in] channelId Id of the channel where to vote
|
||||
* @param[in] postId Id of the channel post of which a comment is voted
|
||||
* @param[in] postId Id of the channel post of which a comment is
|
||||
* voted.
|
||||
* @param[in] commentId Id of the comment that is voted
|
||||
* @param[in] authorId Id of the author. Needs to be of an owned identity.
|
||||
* @param[in] vote Vote value, either RsGxsVoteType::DOWN or RsGxsVoteType::UP
|
||||
* @param[out] voteId Optional storage for the id of the created vote, meaningful only on success.
|
||||
* @param[in] authorId Id of the author. Needs to be of an owned
|
||||
* identity.
|
||||
* @param[in] vote Vote value, either RsGxsVoteType::DOWN or
|
||||
* RsGxsVoteType::UP
|
||||
* @param[out] voteId Optional storage for the id of the created vote,
|
||||
* meaningful only on success.
|
||||
* @param[out] errorMessage Optional storage for error message, meaningful
|
||||
* only on failure.
|
||||
* only on failure.
|
||||
* @return false on error, true otherwise
|
||||
*/
|
||||
virtual bool createVoteV2(
|
||||
|
@ -1147,7 +1147,9 @@ bool p3GxsChannels::createChannelV2(
|
||||
}
|
||||
|
||||
// wait for the group creation to complete.
|
||||
RsTokenService::GxsRequestStatus wSt = waitToken(token);
|
||||
RsTokenService::GxsRequestStatus wSt =
|
||||
waitToken( token, std::chrono::milliseconds(5000),
|
||||
std::chrono::milliseconds(20) );
|
||||
if(wSt != RsTokenService::COMPLETE)
|
||||
{
|
||||
errorMessage = "GXS operation waitToken failed with: "
|
||||
@ -1450,63 +1452,89 @@ bool p3GxsChannels::createCommentV2(const RsGxsGroupId& channelId,
|
||||
std::vector<RsGxsChannelPost> posts;
|
||||
std::vector<RsGxsComment> comments;
|
||||
|
||||
if(!getChannelContent( channelId,std::set<RsGxsMessageId>({threadId}),posts,comments )) // does the post thread exist?
|
||||
if(!getChannelContent( // does the post thread exist?
|
||||
channelId,std::set<RsGxsMessageId>({threadId}), posts, comments ))
|
||||
{
|
||||
errorMessage = "You cannot comment post " + threadId.toStdString() + " of channel with Id " + channelId.toStdString() + ": this post does not exists locally!";
|
||||
errorMessage = "You cannot comment post " + threadId.toStdString() +
|
||||
" of channel with Id " + channelId.toStdString() +
|
||||
": this post does not exists locally!";
|
||||
std::cerr << __PRETTY_FUNCTION__ << " Error: " << errorMessage
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(posts.size() != 1 || !posts[0].mMeta.mParentId.isNull()) // check that the post thread Id is actually that of a post thread
|
||||
// check that the post thread Id is actually that of a post thread
|
||||
if(posts.size() != 1 || !posts[0].mMeta.mParentId.isNull())
|
||||
{
|
||||
errorMessage = std::string("You cannot comment post " + threadId.toStdString() + " of channel with Id " + channelId.toStdString() + ": supplied threadId is not a thread, or parentMsgId is not a comment!");
|
||||
errorMessage = "You cannot comment post " + threadId.toStdString() +
|
||||
" of channel with Id " + channelId.toStdString() +
|
||||
": supplied threadId is not a thread, or parentMsgId is not a" +
|
||||
" comment!";
|
||||
std::cerr << __PRETTY_FUNCTION__ << " Error: " << errorMessage
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!parentId.isNull())
|
||||
if(!getChannelContent( channelId,std::set<RsGxsMessageId>({parentId}),posts,comments )) // does the post thread exist?
|
||||
if(!getChannelContent( // does the post thread exist?
|
||||
channelId,std::set<RsGxsMessageId>({parentId}),posts,comments ))
|
||||
{
|
||||
errorMessage = std::string("You cannot comment post " + parentId.toStdString() + ": supplied parent comment Id is not a comment!");
|
||||
errorMessage = "You cannot comment post " + parentId.toStdString() +
|
||||
": supplied parent comment Id is not a comment!";
|
||||
std::cerr << __PRETTY_FUNCTION__ << " Error: " << errorMessage
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
else if(comments.size() != 1 || comments[0].mMeta.mParentId.isNull()) // is the comment parent actually a comment?
|
||||
{
|
||||
errorMessage = std::string("You cannot comment post " + parentId.toStdString() + " of channel with Id " + channelId.toStdString() + ": supplied mParentMsgId is not a comment Id!");
|
||||
else if(comments.size() != 1 || comments[0].mMeta.mParentId.isNull())
|
||||
{ // is the comment parent actually a comment?
|
||||
errorMessage = "You cannot comment post " + parentId.toStdString()
|
||||
+ " of channel with Id " + channelId.toStdString() +
|
||||
": supplied mParentMsgId is not a comment Id!";
|
||||
std::cerr << __PRETTY_FUNCTION__ << " Error: " << errorMessage
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!rsIdentity->isOwnId(authorId)) // is the voter ID actually ours?
|
||||
{
|
||||
errorMessage = std::string("You cannot comment to channel with Id " + channelId.toStdString() + " with identity " + authorId.toStdString() + " because it is not yours.");
|
||||
errorMessage = "You cannot comment to channel with Id " +
|
||||
channelId.toStdString() + " with identity " +
|
||||
authorId.toStdString() + " because it is not yours.";
|
||||
std::cerr << __PRETTY_FUNCTION__ << " Error: " << errorMessage
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now create the comment
|
||||
|
||||
RsGxsComment cmt;
|
||||
|
||||
cmt.mMeta.mGroupId = channelId;
|
||||
cmt.mMeta.mThreadId = threadId;
|
||||
cmt.mMeta.mParentId = parentId;
|
||||
cmt.mMeta.mAuthorId = authorId;
|
||||
|
||||
cmt.mComment = comment;
|
||||
|
||||
uint32_t token;
|
||||
if(!createNewComment(token, cmt))
|
||||
{
|
||||
errorMessage = "Failed creating comment.";
|
||||
std::cerr << __PRETTY_FUNCTION__ << " Error: " << errorMessage
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(waitToken(token) != RsTokenService::COMPLETE)
|
||||
{
|
||||
errorMessage = "GXS operation failed.";
|
||||
std::cerr << __PRETTY_FUNCTION__ << " Error: " << errorMessage
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!RsGenExchange::getPublishedMsgMeta(token, cmt.mMeta))
|
||||
{
|
||||
errorMessage = "Failure getting generated comment data.";
|
||||
errorMessage = "Failure getting created comment data.";
|
||||
std::cerr << __PRETTY_FUNCTION__ << " Error: " << errorMessage
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -212,13 +212,13 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
|
||||
virtual bool createComment(RsGxsComment& comment) override;
|
||||
|
||||
/// Implementation of @see RsGxsChannels::createComment
|
||||
virtual bool createCommentV2(const RsGxsGroupId& channelId,
|
||||
const RsGxsMessageId& threadId,
|
||||
const RsGxsMessageId& parentId,
|
||||
const RsGxsId& authorId,
|
||||
const std::string& comment,
|
||||
RsGxsMessageId& commentMessageId = RS_DEFAULT_STORAGE_PARAM(RsGxsMessageId),
|
||||
std::string& errorMessage = RS_DEFAULT_STORAGE_PARAM(std::string)) override;
|
||||
virtual bool createCommentV2(
|
||||
const RsGxsGroupId& channelId, const RsGxsMessageId& threadId,
|
||||
const RsGxsMessageId& parentId, const RsGxsId& authorId,
|
||||
const std::string& comment,
|
||||
RsGxsMessageId& commentMessageId = RS_DEFAULT_STORAGE_PARAM(RsGxsMessageId),
|
||||
std::string& errorMessage = RS_DEFAULT_STORAGE_PARAM(std::string)
|
||||
) override;
|
||||
|
||||
/// Implementation of @see RsGxsChannels::editChannel
|
||||
virtual bool editChannel(RsGxsChannelGroup& channel) override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user