From 766da8117a31e7bbca3921d7fa7bb5835c86c341 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 10 May 2020 18:37:03 +0200 Subject: [PATCH] added missing update of membership status flags when an id is removed from the invitee list --- libretroshare/src/gxs/rsgenexchange.cc | 41 +++++++++++----------- libretroshare/src/gxs/rsgxsnetservice.cc | 2 +- libretroshare/src/services/p3gxscircles.cc | 12 +++++++ 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index bcd197abe..8debf99f4 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -61,7 +61,7 @@ static const uint32_t INDEX_AUTHEN_ADMIN = 0x00000040; // admin key #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 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) { - if(!checkGroupMetaConsistency(grpItem->meta)) - { - std::cerr << "(EE) Cannot update group. Some information was not supplied." << std::endl; - return ; - } + if(!checkGroupMetaConsistency(grpItem->meta)) + { + std::cerr << "(EE) Cannot update group. Some information was not supplied." << std::endl; + delete grpItem; + return ; + } - RS_STACK_MUTEX(mGenMtx) ; + RS_STACK_MUTEX(mGenMtx) ; token = mDataAccess->generatePublicToken(); - mGroupUpdatePublish.push_back(GroupUpdatePublish(grpItem, token)); + mGroupUpdatePublish.push_back(GroupUpdatePublish(grpItem, token)); #ifdef GEN_EXCH_DEBUG - std::cerr << "RsGenExchange::updateGroup() token: " << token; - std::cerr << std::endl; + std::cerr << "RsGenExchange::updateGroup() token: " << token; + std::cerr << std::endl; #endif } @@ -2385,15 +2386,14 @@ RsGenExchange::ServiceCreate_Return RsGenExchange::service_CreateGroup(RsGxsGrpI void RsGenExchange::processGroupUpdatePublish() { - RS_STACK_MUTEX(mGenMtx) ; + RS_STACK_MUTEX(mGenMtx) ; // get keys for group update publish // first build meta request map for groups to be updated RsGxsGrpMetaTemporaryMap grpMeta; - std::vector::iterator vit = mGroupUpdatePublish.begin(); - for(; vit != mGroupUpdatePublish.end(); ++vit) + for(auto vit = mGroupUpdatePublish.begin(); vit != mGroupUpdatePublish.end(); ++vit) { GroupUpdatePublish& gup = *vit; const RsGxsGroupId& groupId = gup.grpItem->meta.mGroupId; @@ -2406,8 +2406,7 @@ void RsGenExchange::processGroupUpdatePublish() mDataStore->retrieveGxsGrpMetaData(grpMeta); // now - vit = mGroupUpdatePublish.begin(); - for(; vit != mGroupUpdatePublish.end(); ++vit) + for(auto vit = mGroupUpdatePublish.begin(); vit != mGroupUpdatePublish.end(); ++vit) { GroupUpdatePublish& gup = *vit; const RsGxsGroupId& groupId = gup.grpItem->meta.mGroupId; @@ -2425,14 +2424,14 @@ void RsGenExchange::processGroupUpdatePublish() meta = mit->second; //gup.grpItem->meta = *meta; - GxsGrpPendingSign ggps(gup.grpItem, gup.mToken); + GxsGrpPendingSign ggps(gup.grpItem, gup.mToken); if(checkKeys(meta->keys)) { ggps.mKeys = meta->keys; - - GxsSecurity::createPublicKeysFromPrivateKeys(ggps.mKeys) ; - + + GxsSecurity::createPublicKeysFromPrivateKeys(ggps.mKeys) ; + ggps.mHaveKeys = true; ggps.mStartTS = time(NULL); ggps.mLastAttemptTS = 0; @@ -2442,8 +2441,8 @@ void RsGenExchange::processGroupUpdatePublish() } 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; mDataAccess->updatePublicRequestStatus(gup.mToken, RsTokenService::FAILED); } diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index 9937b1729..3259a060c 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -321,7 +321,7 @@ static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_GXS_KEY_MISSING = 0x05 ; || defined(NXS_NET_DEBUG_8) 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 // warning. Numbers should be SERVICE IDS (see serialiser/rsserviceids.h. E.g. 0x0215 for forums) diff --git a/libretroshare/src/services/p3gxscircles.cc b/libretroshare/src/services/p3gxscircles.cc index 89b5433b3..9c8053f74 100644 --- a/libretroshare/src/services/p3gxscircles.cc +++ b/libretroshare/src/services/p3gxscircles.cc @@ -40,6 +40,7 @@ /**** * #define DEBUG_CIRCLES 1 ****/ +#define DEBUG_CIRCLES 1 /*extern*/ RsGxsCircles* rsGxsCircles = nullptr; @@ -1107,6 +1108,17 @@ bool RsGxsCircleCache::loadBaseCircle(const RsGxsCircleGroup& circle) #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; }