mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-29 16:53:31 -05:00
Merge pull request #1647 from G10h4ck/circle_api_fixes
Fail gracefully when requesting membership on an unknown circle
This commit is contained in:
commit
2a547a034e
@ -2061,29 +2061,41 @@ void p3GxsCircles::handle_event(uint32_t event_type, const std::string &elabel)
|
|||||||
// | | Grp Subscribed: NO | Grp Subscribed: NO |
|
// | | 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
|
Dbg3() << __PRETTY_FUNCTION__ << "own_gxsid = " << own_gxsid
|
||||||
std::cerr << "Circle membership request: own_gxsid = " << own_gxsid << ", circle=" << circle_id << ", req type=" << request_type << std::endl;
|
<< ", circle=" << circle_id << ", req type=" << request_type
|
||||||
#endif
|
<< std::endl;
|
||||||
|
|
||||||
// check for some consistency
|
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(request_type != RsGxsCircleSubscriptionRequestItem::SUBSCRIPTION_REQUEST_SUBSCRIBE && request_type != RsGxsCircleSubscriptionRequestItem::SUBSCRIPTION_REQUEST_UNSUBSCRIBE)
|
if(!rsIdentity->isOwnId(own_gxsid))
|
||||||
return false ;
|
{
|
||||||
|
RsErr() << __PRETTY_FUNCTION__ << " Cannot generate membership request "
|
||||||
|
<< "from not-own id: " << own_gxsid << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::list<RsGxsId> own_ids ;
|
if(!getCirclesInfo(
|
||||||
if(!rsIdentity->getOwnIds(own_ids))
|
std::list<RsGxsGroupId>{static_cast<RsGxsGroupId>(circle_id)},
|
||||||
return false ;
|
RS_DEFAULT_STORAGE_PARAM(std::vector<RsGxsCircleGroup>) ))
|
||||||
|
{
|
||||||
|
RsErr() << __PRETTY_FUNCTION__ << " Cannot generate membership request "
|
||||||
|
<< "from unknown circle: " << circle_id << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool found = false ;
|
// Create a subscribe item
|
||||||
for(std::list<RsGxsId>::const_iterator it(own_ids.begin());it!=own_ids.end() && !found;++it)
|
|
||||||
found = ( (*it) == own_gxsid) ;
|
|
||||||
|
|
||||||
if(!found)
|
|
||||||
return false ;
|
|
||||||
|
|
||||||
// Create a subscribe item
|
|
||||||
|
|
||||||
RsGxsCircleSubscriptionRequestItem *s = new RsGxsCircleSubscriptionRequestItem ;
|
RsGxsCircleSubscriptionRequestItem *s = new RsGxsCircleSubscriptionRequestItem ;
|
||||||
|
|
||||||
|
@ -26,12 +26,11 @@
|
|||||||
#include "retroshare/rsgxscircles.h" // External Interfaces.
|
#include "retroshare/rsgxscircles.h" // External Interfaces.
|
||||||
#include "gxs/rsgenexchange.h" // GXS service.
|
#include "gxs/rsgenexchange.h" // GXS service.
|
||||||
#include "gxs/rsgixs.h" // Internal Interfaces.
|
#include "gxs/rsgixs.h" // Internal Interfaces.
|
||||||
|
|
||||||
#include "services/p3idservice.h" // For constructing Caches
|
#include "services/p3idservice.h" // For constructing Caches
|
||||||
|
|
||||||
#include "gxs/gxstokenqueue.h"
|
#include "gxs/gxstokenqueue.h"
|
||||||
#include "util/rstickevent.h"
|
#include "util/rstickevent.h"
|
||||||
#include "util/rsmemcache.h"
|
#include "util/rsmemcache.h"
|
||||||
|
#include "util/rsdebug.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -321,4 +320,6 @@ virtual RsServiceInfo getServiceInfo();
|
|||||||
uint32_t mDummyIdToken;
|
uint32_t mDummyIdToken;
|
||||||
std::list<RsGxsId> mDummyPgpLinkedIds;
|
std::list<RsGxsId> mDummyPgpLinkedIds;
|
||||||
std::list<RsGxsId> mDummyOwnIds;
|
std::list<RsGxsId> mDummyOwnIds;
|
||||||
|
|
||||||
|
RS_SET_CONTEXT_DEBUG_LEVEL(2)
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user