diff --git a/libretroshare/src/services/p3gxscircles.cc b/libretroshare/src/services/p3gxscircles.cc index ca599d85b..eed23313d 100644 --- a/libretroshare/src/services/p3gxscircles.cc +++ b/libretroshare/src/services/p3gxscircles.cc @@ -2061,29 +2061,41 @@ void p3GxsCircles::handle_event(uint32_t event_type, const std::string &elabel) // | | Grp Subscribed: NO | Grp Subscribed: NO | // +-------------+------------------------------+-----------------------------+ -bool p3GxsCircles::pushCircleMembershipRequest(const RsGxsId& own_gxsid,const RsGxsCircleId& circle_id,uint32_t request_type) +bool p3GxsCircles::pushCircleMembershipRequest( + const RsGxsId& own_gxsid, const RsGxsCircleId& circle_id, + uint32_t request_type ) { -#ifdef DEBUG_CIRCLES - std::cerr << "Circle membership request: own_gxsid = " << own_gxsid << ", circle=" << circle_id << ", req type=" << request_type << std::endl; -#endif - - // check for some consistency - - if(request_type != RsGxsCircleSubscriptionRequestItem::SUBSCRIPTION_REQUEST_SUBSCRIBE && request_type != RsGxsCircleSubscriptionRequestItem::SUBSCRIPTION_REQUEST_UNSUBSCRIBE) - return false ; - - std::list own_ids ; - if(!rsIdentity->getOwnIds(own_ids)) - return false ; - - bool found = false ; - for(std::list::const_iterator it(own_ids.begin());it!=own_ids.end() && !found;++it) - found = ( (*it) == own_gxsid) ; + Dbg3() << __PRETTY_FUNCTION__ << "own_gxsid = " << own_gxsid + << ", circle=" << circle_id << ", req type=" << request_type + << std::endl; - if(!found) - return false ; - - // Create a subscribe item + if( request_type != + RsGxsCircleSubscriptionRequestItem::SUBSCRIPTION_REQUEST_SUBSCRIBE && + request_type != + RsGxsCircleSubscriptionRequestItem::SUBSCRIPTION_REQUEST_UNSUBSCRIBE ) + { + RsErr() << __PRETTY_FUNCTION__ << " Unknown request type: " + << request_type << std::endl; + return false; + } + + if(!rsIdentity->isOwnId(own_gxsid)) + { + RsErr() << __PRETTY_FUNCTION__ << " Cannot generate membership request " + << "from not-own id: " << own_gxsid << std::endl; + return false; + } + + if(!getCirclesInfo( + std::list{static_cast(circle_id)}, + RS_DEFAULT_STORAGE_PARAM(std::vector) )) + { + RsErr() << __PRETTY_FUNCTION__ << " Cannot generate membership request " + << "from unknown circle: " << circle_id << std::endl; + return false; + } + + // Create a subscribe item RsGxsCircleSubscriptionRequestItem *s = new RsGxsCircleSubscriptionRequestItem ; diff --git a/libretroshare/src/services/p3gxscircles.h b/libretroshare/src/services/p3gxscircles.h index 48129a9ba..9eb6c15bb 100644 --- a/libretroshare/src/services/p3gxscircles.h +++ b/libretroshare/src/services/p3gxscircles.h @@ -26,12 +26,11 @@ #include "retroshare/rsgxscircles.h" // External Interfaces. #include "gxs/rsgenexchange.h" // GXS service. #include "gxs/rsgixs.h" // Internal Interfaces. - #include "services/p3idservice.h" // For constructing Caches - #include "gxs/gxstokenqueue.h" #include "util/rstickevent.h" #include "util/rsmemcache.h" +#include "util/rsdebug.h" #include #include @@ -321,4 +320,6 @@ virtual RsServiceInfo getServiceInfo(); uint32_t mDummyIdToken; std::list mDummyPgpLinkedIds; std::list mDummyOwnIds; + + RS_SET_CONTEXT_DEBUG_LEVEL(2) };