added missing update of membership status flags when an id is removed from the invitee list

This commit is contained in:
csoler 2020-05-10 18:37:03 +02:00
parent a7d89f1fbb
commit 766da8117a
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
3 changed files with 33 additions and 22 deletions

View file

@ -61,7 +61,7 @@ static const uint32_t INDEX_AUTHEN_ADMIN = 0x00000040; // admin key
#define GXS_MASK "GXS_MASK_HACK" #define GXS_MASK "GXS_MASK_HACK"
#define GEN_EXCH_DEBUG 1 //#define GEN_EXCH_DEBUG 1
static const uint32_t MSG_CLEANUP_PERIOD = 60*59; // 59 minutes static const uint32_t MSG_CLEANUP_PERIOD = 60*59; // 59 minutes
static const uint32_t INTEGRITY_CHECK_PERIOD = 60*31; // 31 minutes static const uint32_t INTEGRITY_CHECK_PERIOD = 60*31; // 31 minutes
@ -1794,19 +1794,20 @@ void RsGenExchange::publishGroup(uint32_t& token, RsGxsGrpItem *grpItem)
void RsGenExchange::updateGroup(uint32_t& token, RsGxsGrpItem* grpItem) void RsGenExchange::updateGroup(uint32_t& token, RsGxsGrpItem* grpItem)
{ {
if(!checkGroupMetaConsistency(grpItem->meta)) if(!checkGroupMetaConsistency(grpItem->meta))
{ {
std::cerr << "(EE) Cannot update group. Some information was not supplied." << std::endl; std::cerr << "(EE) Cannot update group. Some information was not supplied." << std::endl;
return ; delete grpItem;
} return ;
}
RS_STACK_MUTEX(mGenMtx) ; RS_STACK_MUTEX(mGenMtx) ;
token = mDataAccess->generatePublicToken(); token = mDataAccess->generatePublicToken();
mGroupUpdatePublish.push_back(GroupUpdatePublish(grpItem, token)); mGroupUpdatePublish.push_back(GroupUpdatePublish(grpItem, token));
#ifdef GEN_EXCH_DEBUG #ifdef GEN_EXCH_DEBUG
std::cerr << "RsGenExchange::updateGroup() token: " << token; std::cerr << "RsGenExchange::updateGroup() token: " << token;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
} }
@ -2385,15 +2386,14 @@ RsGenExchange::ServiceCreate_Return RsGenExchange::service_CreateGroup(RsGxsGrpI
void RsGenExchange::processGroupUpdatePublish() void RsGenExchange::processGroupUpdatePublish()
{ {
RS_STACK_MUTEX(mGenMtx) ; RS_STACK_MUTEX(mGenMtx) ;
// get keys for group update publish // get keys for group update publish
// first build meta request map for groups to be updated // first build meta request map for groups to be updated
RsGxsGrpMetaTemporaryMap grpMeta; RsGxsGrpMetaTemporaryMap grpMeta;
std::vector<GroupUpdatePublish>::iterator vit = mGroupUpdatePublish.begin();
for(; vit != mGroupUpdatePublish.end(); ++vit) for(auto vit = mGroupUpdatePublish.begin(); vit != mGroupUpdatePublish.end(); ++vit)
{ {
GroupUpdatePublish& gup = *vit; GroupUpdatePublish& gup = *vit;
const RsGxsGroupId& groupId = gup.grpItem->meta.mGroupId; const RsGxsGroupId& groupId = gup.grpItem->meta.mGroupId;
@ -2406,8 +2406,7 @@ void RsGenExchange::processGroupUpdatePublish()
mDataStore->retrieveGxsGrpMetaData(grpMeta); mDataStore->retrieveGxsGrpMetaData(grpMeta);
// now // now
vit = mGroupUpdatePublish.begin(); for(auto vit = mGroupUpdatePublish.begin(); vit != mGroupUpdatePublish.end(); ++vit)
for(; vit != mGroupUpdatePublish.end(); ++vit)
{ {
GroupUpdatePublish& gup = *vit; GroupUpdatePublish& gup = *vit;
const RsGxsGroupId& groupId = gup.grpItem->meta.mGroupId; const RsGxsGroupId& groupId = gup.grpItem->meta.mGroupId;
@ -2425,13 +2424,13 @@ void RsGenExchange::processGroupUpdatePublish()
meta = mit->second; meta = mit->second;
//gup.grpItem->meta = *meta; //gup.grpItem->meta = *meta;
GxsGrpPendingSign ggps(gup.grpItem, gup.mToken); GxsGrpPendingSign ggps(gup.grpItem, gup.mToken);
if(checkKeys(meta->keys)) if(checkKeys(meta->keys))
{ {
ggps.mKeys = meta->keys; ggps.mKeys = meta->keys;
GxsSecurity::createPublicKeysFromPrivateKeys(ggps.mKeys) ; GxsSecurity::createPublicKeysFromPrivateKeys(ggps.mKeys) ;
ggps.mHaveKeys = true; ggps.mHaveKeys = true;
ggps.mStartTS = time(NULL); ggps.mStartTS = time(NULL);
@ -2442,7 +2441,7 @@ void RsGenExchange::processGroupUpdatePublish()
} }
else else
{ {
std::cerr << "(EE) publish group fails because RS cannot find the private publish and author keys" << std::endl; std::cerr << "(EE) publish group fails because RS cannot find the private publish and author keys" << std::endl;
delete gup.grpItem; delete gup.grpItem;
mDataAccess->updatePublicRequestStatus(gup.mToken, RsTokenService::FAILED); mDataAccess->updatePublicRequestStatus(gup.mToken, RsTokenService::FAILED);

View file

@ -321,7 +321,7 @@ static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_GXS_KEY_MISSING = 0x05 ;
|| defined(NXS_NET_DEBUG_8) || defined(NXS_NET_DEBUG_8)
static const RsPeerId peer_to_print = RsPeerId();//std::string("a97fef0e2dc82ddb19200fb30f9ac575")) ; static const RsPeerId peer_to_print = RsPeerId();//std::string("a97fef0e2dc82ddb19200fb30f9ac575")) ;
static const RsGxsGroupId group_id_to_print = RsGxsGroupId() ; // use this to allow to this group id only, or "" for all IDs static const RsGxsGroupId group_id_to_print = RsGxsGroupId(std::string("66052380f5d1d0c5992e2b55dc402ce6")) ; // use this to allow to this group id only, or "" for all IDs
static const uint32_t service_to_print = RS_SERVICE_GXS_TYPE_GXSCIRCLE; // use this to allow to this service id only, or 0 for all services static const uint32_t service_to_print = RS_SERVICE_GXS_TYPE_GXSCIRCLE; // use this to allow to this service id only, or 0 for all services
// warning. Numbers should be SERVICE IDS (see serialiser/rsserviceids.h. E.g. 0x0215 for forums) // warning. Numbers should be SERVICE IDS (see serialiser/rsserviceids.h. E.g. 0x0215 for forums)

View file

@ -40,6 +40,7 @@
/**** /****
* #define DEBUG_CIRCLES 1 * #define DEBUG_CIRCLES 1
****/ ****/
#define DEBUG_CIRCLES 1
/*extern*/ RsGxsCircles* rsGxsCircles = nullptr; /*extern*/ RsGxsCircles* rsGxsCircles = nullptr;
@ -1107,6 +1108,17 @@ bool RsGxsCircleCache::loadBaseCircle(const RsGxsCircleGroup& circle)
#endif // DEBUG_CIRCLES #endif // DEBUG_CIRCLES
} }
// also sweep through the list of subscribed members and remove the membership to those who are not in the invitee list anymore
for(auto& m:mMembershipStatus)
if(circle.mInvitedMembers.find(m.first) == circle.mInvitedMembers.end())
{
m.second.subscription_flags &= ~GXS_EXTERNAL_CIRCLE_FLAGS_IN_ADMIN_LIST;
#ifdef DEBUG_CIRCLES
std::cerr << " member " << m.first << " is not in invitee list. Updating flags to " << std::hex << m.second.subscription_flags << std::dec << std::endl;
#endif // DEBUG_CIRCLES
}
return true; return true;
} }