From 5a41b3cb3762450d27dd44d9ba8a754e613ee880 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Mon, 11 Jun 2018 13:03:01 +0200 Subject: [PATCH] Index only public channels --- libretroshare/src/gxs/rsgxsutil.cc | 70 +++++++++++---------- libretroshare/src/retroshare/rsgxscircles.h | 7 +-- 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/libretroshare/src/gxs/rsgxsutil.cc b/libretroshare/src/gxs/rsgxsutil.cc index 2011ff8d9..60106b411 100644 --- a/libretroshare/src/gxs/rsgxsutil.cc +++ b/libretroshare/src/gxs/rsgxsutil.cc @@ -201,40 +201,6 @@ bool RsGxsIntegrityCheck::check() { subscribed_groups.insert(git->first); -#ifdef RS_DEEP_SEARCH - if(isGxsChannels) - { - RsGxsGrpMetaData meta; - meta.deserialise(grp->meta.bin_data, grp->meta.bin_len); - - uint32_t blz = grp->grp.bin_len; - RsItem* rIt = mSerializer.deserialise(grp->grp.bin_data, - &blz); - - if( RsGxsChannelGroupItem* cgIt = - dynamic_cast(rIt) ) - { - RsGxsChannelGroup cg; - cgIt->toChannelGroup(cg, false); - cg.mMeta = meta; - - DeepSearch::indexChannelGroup(cg); - } - else - { - std::cerr << __PRETTY_FUNCTION__ << " Group: " - << meta.mGroupId.toStdString() << " " - << meta.mGroupName - << " doesn't seems a channel, please " - << "report to developers" - << std::endl; - print_stacktrace(); - } - - delete rIt; - } -#endif - if(!grp->metaData->mAuthorId.isNull()) { #ifdef DEBUG_GXSUTIL @@ -246,6 +212,42 @@ bool RsGxsIntegrityCheck::check() } } else msgIds.erase(msgIds.find(grp->grpId)); + +#ifdef RS_DEEP_SEARCH + if( isGxsChannels + && grp->metaData->mCircleType == GXS_CIRCLE_TYPE_PUBLIC + && grp->metaData->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED ) + { + RsGxsGrpMetaData meta; + meta.deserialise(grp->meta.bin_data, grp->meta.bin_len); + + uint32_t blz = grp->grp.bin_len; + RsItem* rIt = mSerializer.deserialise(grp->grp.bin_data, + &blz); + + if( RsGxsChannelGroupItem* cgIt = + dynamic_cast(rIt) ) + { + RsGxsChannelGroup cg; + cgIt->toChannelGroup(cg, false); + cg.mMeta = meta; + + DeepSearch::indexChannelGroup(cg); + } + else + { + std::cerr << __PRETTY_FUNCTION__ << " Group: " + << meta.mGroupId.toStdString() << " " + << meta.mGroupName + << " doesn't seems a channel, please " + << "report to developers" + << std::endl; + print_stacktrace(); + } + + delete rIt; + } +#endif } else { diff --git a/libretroshare/src/retroshare/rsgxscircles.h b/libretroshare/src/retroshare/rsgxscircles.h index 8ce446200..6d93507e8 100644 --- a/libretroshare/src/retroshare/rsgxscircles.h +++ b/libretroshare/src/retroshare/rsgxscircles.h @@ -49,10 +49,9 @@ extern RsGxsCircles *rsGxsCircles; typedef RsPgpId RsPgpId; -// The meaning of the different circle types is: -// -// -static const uint32_t GXS_CIRCLE_TYPE_UNKNOWN = 0x0000 ; // not known. Is treated as public. +/// The meaning of the different circle types is: +/// TODO: convert to enum +static const uint32_t GXS_CIRCLE_TYPE_UNKNOWN = 0x0000 ; /// Used to detect uninizialized values. static const uint32_t GXS_CIRCLE_TYPE_PUBLIC = 0x0001 ; // not restricted to a circle static const uint32_t GXS_CIRCLE_TYPE_EXTERNAL = 0x0002 ; // restricted to an external circle, made of RsGxsId static const uint32_t GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY = 0x0003 ; // restricted to a subset of friend nodes of a given RS node given by a RsPgpId list