added missing explicit update circle method (Not used yet)

This commit is contained in:
csoler 2021-03-03 22:37:12 +01:00
parent 1bfd49419d
commit 118ec492e6
4 changed files with 174 additions and 81 deletions

View File

@ -301,6 +301,25 @@ public:
const std::set<RsGxsId>& gxsIdMembers = std::set<RsGxsId>(),
const std::set<RsPgpId>& localMembers = std::set<RsPgpId>() ) = 0;
/**
* @brief Edit an existing circle
* @jsonapi{development}
* @param[in] circleId Optional storage to output created circle id
* @param[in] circleName String containing cirlce name
* @param[in] circleType Circle type
* @param[in] restrictedId Optional id of a pre-existent circle that see the
* created circle. Meaningful only if circleType == EXTERNAL, must be null
* in all other cases.
* @param[in] authorId Optional author of the circle.
* @param[in] gxsIdMembers GXS ids of the members of the circle.
* @param[in] localMembers PGP ids of the members if the circle.
* @return false if something failed, true otherwhise
*/
virtual bool editCircle( const RsGxsCircleId& circleId, const std::string& circleName, RsGxsCircleType circleType,
const RsGxsCircleId& restrictedId,
const RsGxsId& authorId, const std::set<RsGxsId>& gxsIdMembers,
const std::set<RsPgpId>& localMembers ) =0;
/**
* @brief Edit own existing circle
* @jsonapi{development}

View File

@ -194,6 +194,51 @@ bool p3GxsCircles::createCircle(
{
// 1 - Check consistency of the request data
if(!checkCircleParamConsistency(circleName,circleType,restrictedId,authorId,gxsIdMembers,localMembers))
{
RsErr() << __PRETTY_FUNCTION__ << " Circle name is empty" << std::endl;
return false;
}
// 2 - Create the actual request
RsGxsCircleGroup cData;
cData.mMeta.mGroupName = circleName;
cData.mMeta.mAuthorId = authorId;
cData.mMeta.mCircleType = static_cast<uint32_t>(circleType);
cData.mMeta.mGroupFlags = GXS_SERV::FLAG_PRIVACY_PUBLIC;
cData.mMeta.mCircleId = restrictedId;
cData.mMeta.mSignFlags = GXS_SERV::FLAG_GROUP_SIGN_PUBLISH_NONEREQ | GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_REQUIRED;
cData.mLocalFriends = localMembers;
cData.mInvitedMembers = gxsIdMembers;
// 3 - Send it and wait, for a sync response.
uint32_t token;
createGroup(token, cData);
if(waitToken(token) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed." << std::endl;
return false;
}
if(!RsGenExchange::getPublishedGroupMeta(token, cData.mMeta))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting created" << " group data." << std::endl;
return false;
}
circleId = static_cast<RsGxsCircleId>(cData.mMeta.mGroupId);
return true;
};
bool p3GxsCircles::checkCircleParamConsistency( const std::string& circleName, RsGxsCircleType circleType,
const RsGxsCircleId& restrictedId,
const RsGxsId& authorId, const std::set<RsGxsId>& gxsIdMembers,
const std::set<RsPgpId>& localMembers ) const
{
if(circleName.empty())
{
RsErr() << __PRETTY_FUNCTION__ << " Circle name is empty" << std::endl;
@ -251,38 +296,8 @@ bool p3GxsCircles::createCircle(
<< static_cast<uint32_t>(circleType) << std::endl;
return false;
}
// 2 - Create the actual request
RsGxsCircleGroup cData;
cData.mMeta.mGroupName = circleName;
cData.mMeta.mAuthorId = authorId;
cData.mMeta.mCircleType = static_cast<uint32_t>(circleType);
cData.mMeta.mGroupFlags = GXS_SERV::FLAG_PRIVACY_PUBLIC;
cData.mMeta.mCircleId = restrictedId;
cData.mLocalFriends = localMembers;
cData.mInvitedMembers = gxsIdMembers;
// 3 - Send it and wait, for a sync response.
uint32_t token;
createGroup(token, cData);
if(waitToken(token) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed." << std::endl;
return false;
}
if(!RsGenExchange::getPublishedGroupMeta(token, cData.mMeta))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting created" << " group data." << std::endl;
return false;
}
circleId = static_cast<RsGxsCircleId>(cData.mMeta.mGroupId);
return true;
};
}
bool p3GxsCircles::editCircle(RsGxsCircleGroup& cData)
{
@ -306,6 +321,52 @@ bool p3GxsCircles::editCircle(RsGxsCircleGroup& cData)
return true;
}
bool p3GxsCircles::editCircle(const RsGxsCircleId &circleId, const std::string& circleName, RsGxsCircleType circleType, const RsGxsCircleId& restrictedId,
const RsGxsId& authorId, const std::set<RsGxsId>& gxsIdMembers,
const std::set<RsPgpId>& localMembers )
{
// 1 - Check consistency of the request data
if(!checkCircleParamConsistency(circleName,circleType,restrictedId,authorId,gxsIdMembers,localMembers))
{
RsErr() << __PRETTY_FUNCTION__ << " Circle data is not consistent." << std::endl;
return false;
}
// 2 - Create the actual request
RsGxsCircleGroup cData;
cData.mMeta.mGroupId = RsGxsGroupId(circleId);
cData.mMeta.mGroupName = circleName;
cData.mMeta.mAuthorId = authorId;
cData.mMeta.mCircleType = static_cast<uint32_t>(circleType);
cData.mMeta.mGroupFlags = GXS_SERV::FLAG_PRIVACY_PUBLIC;
cData.mMeta.mCircleId = restrictedId;
cData.mLocalFriends = localMembers;
cData.mInvitedMembers = gxsIdMembers;
// 3 - Send it and wait, for a sync response.
uint32_t token;
updateGroup(token, cData);
if(waitToken(token) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed."
<< std::endl;
return false;
}
if(!RsGenExchange::getPublishedGroupMeta(token, cData.mMeta))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting updated"
<< " group data." << std::endl;
return false;
}
return true;
};
bool p3GxsCircles::getCirclesSummaries(std::list<RsGroupMetaData>& circles)
{
uint32_t token;

View File

@ -227,6 +227,11 @@ public:
const std::set<RsPgpId>& localMembers = std::set<RsPgpId>()
) override;
bool editCircle( const RsGxsCircleId& circleId,const std::string& circleName, RsGxsCircleType circleType,
const RsGxsCircleId& restrictedId,
const RsGxsId& authorId, const std::set<RsGxsId>& gxsIdMembers,
const std::set<RsPgpId>& localMembers ) override;
/// @see RsGxsCircles
bool editCircle(RsGxsCircleGroup& cData) override;
@ -303,6 +308,10 @@ public:
virtual void service_tick() override;
protected:
bool checkCircleParamConsistency( const std::string& circleName, RsGxsCircleType circleType,
const RsGxsCircleId& restrictedId,
const RsGxsId& authorId, const std::set<RsGxsId>& gxsIdMembers,
const std::set<RsPgpId>& localMembers ) const ;
// overloads p3Config
virtual bool saveList(bool &cleanup, std::list<RsItem *>&saveList) override;

View File

@ -1139,6 +1139,7 @@ bool p3IdService::updateIdentity( const RsGxsId& id, const std::string& name, co
goto LabelUpdateIdentityCleanup;
}
}
mKeyCache.erase(id);
if(!updateGroup(token, group))
{
@ -1154,6 +1155,9 @@ bool p3IdService::updateIdentity( const RsGxsId& id, const std::string& name, co
goto LabelUpdateIdentityCleanup;
}
// clean the Identity cache as well
cache_request_load(id);
LabelUpdateIdentityCleanup:
if(!pseudonimous && !pgpPassword.empty())
rsNotify->clearPgpPassphrase();