mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-05 07:35:12 -04:00
merged upstream/master
This commit is contained in:
commit
fa72af4d0c
259 changed files with 12221 additions and 4892 deletions
|
@ -219,7 +219,13 @@ bool DistributedChatService::checkSignature(RsChatLobbyBouncingObject *obj,const
|
|||
|
||||
// network pre-request key to allow message authentication.
|
||||
|
||||
mGixs->requestKey(obj->signature.keyId,peer_list,RsIdentityUsage(RS_SERVICE_TYPE_CHAT,RsIdentityUsage::CHAT_LOBBY_MSG_VALIDATION,RsGxsGroupId(),RsGxsMessageId(),obj->lobby_id));
|
||||
mGixs->requestKey(obj->signature.keyId,peer_list,RsIdentityUsage(RsServiceType::CHAT,
|
||||
RsIdentityUsage::CHAT_LOBBY_MSG_VALIDATION,
|
||||
RsGxsGroupId(),
|
||||
RsGxsMessageId(),
|
||||
RsGxsMessageId(),
|
||||
RsGxsMessageId(),
|
||||
obj->lobby_id));
|
||||
|
||||
uint32_t size = RsChatSerialiser(RsSerializationFlags::SIGNATURE)
|
||||
.size(dynamic_cast<RsItem*>(obj));
|
||||
|
@ -238,7 +244,13 @@ bool DistributedChatService::checkSignature(RsChatLobbyBouncingObject *obj,const
|
|||
}
|
||||
|
||||
uint32_t error_status ;
|
||||
RsIdentityUsage use_info(RS_SERVICE_TYPE_CHAT,RsIdentityUsage::CHAT_LOBBY_MSG_VALIDATION,RsGxsGroupId(),RsGxsMessageId(),obj->lobby_id) ;
|
||||
RsIdentityUsage use_info(RsServiceType::CHAT,
|
||||
RsIdentityUsage::CHAT_LOBBY_MSG_VALIDATION,
|
||||
RsGxsGroupId(),
|
||||
RsGxsMessageId(),
|
||||
RsGxsMessageId(),
|
||||
RsGxsMessageId(),
|
||||
obj->lobby_id) ;
|
||||
|
||||
if(!mGixs->validateData(memory,size,obj->signature,false,use_info,error_status))
|
||||
{
|
||||
|
|
|
@ -450,7 +450,7 @@ void p3discovery2::recvIdentityList(const RsPeerId& pid,const std::list<RsGxsId>
|
|||
std::cerr << "p3discovery2::recvIdentityList(): from peer " << pid << ": " << ids.size() << " identities" << std::endl;
|
||||
#endif
|
||||
|
||||
RsIdentityUsage use_info(RS_SERVICE_TYPE_DISC,RsIdentityUsage::IDENTITY_DATA_UPDATE);
|
||||
RsIdentityUsage use_info(RsServiceType::GOSSIP_DISCOVERY,RsIdentityUsage::IDENTITY_NEW_FROM_DISCOVERY);
|
||||
|
||||
for(auto it(ids.begin());it!=ids.end();++it)
|
||||
{
|
||||
|
|
|
@ -2108,7 +2108,7 @@ bool p3GRouter::verifySignedDataItem(const RsGRouterAbstractMsgItem *item,const
|
|||
if(!signature_serializer.serialise(const_cast<RsGRouterAbstractMsgItem*>(item),data,&data_size))
|
||||
throw std::runtime_error("Cannot serialise signed data.");
|
||||
|
||||
RsIdentityUsage use(RS_SERVICE_TYPE_GROUTER,info);
|
||||
RsIdentityUsage use(RsServiceType::GROUTER,info);
|
||||
|
||||
if(!mGixs->validateData( data, data_size, item->signature, true, use, error_status ))
|
||||
{
|
||||
|
|
|
@ -502,6 +502,9 @@ RsGxsGrpMetaData* RsDataService::locked_getGrpMeta(RetroCursor &c, int colOffset
|
|||
RsGxsGrpMetaData* grpMeta ;
|
||||
RsGxsGroupId grpId(tempId) ;
|
||||
|
||||
if(grpId.isNull()) // not in the DB!
|
||||
return nullptr;
|
||||
|
||||
if(use_cache)
|
||||
grpMeta = mGrpMetaDataCache.getOrCreateMeta(grpId);
|
||||
else
|
||||
|
@ -659,8 +662,10 @@ RsGxsMsgMetaData* RsDataService::locked_getMsgMeta(RetroCursor &c, int colOffset
|
|||
std::string temp;
|
||||
c.getString(mColMsgMeta_MsgId + colOffset, temp);
|
||||
msg_id = RsGxsMessageId(temp);
|
||||
|
||||
// without these, a msg is meaningless
|
||||
ok &= (!group_id.isNull()) && (!msg_id.isNull());
|
||||
if(group_id.isNull() || msg_id.isNull())
|
||||
return nullptr;
|
||||
|
||||
RsGxsMsgMetaData* msgMeta = nullptr;
|
||||
|
||||
|
@ -1432,7 +1437,7 @@ int RsDataService::retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp)
|
|||
RsGxsGrpMetaData *meta = mGrpMetaDataCache.getMeta(mit->first) ;
|
||||
|
||||
if(meta)
|
||||
grp[mit->first] = meta;
|
||||
mit->second = meta;
|
||||
else
|
||||
{
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_CACHE
|
||||
|
@ -1446,7 +1451,7 @@ int RsDataService::retrieveGxsGrpMetaData(RsGxsGrpMetaTemporaryMap& grp)
|
|||
RsGxsGrpMetaData* meta = locked_getGrpMeta(*c, 0,true);
|
||||
|
||||
if(meta)
|
||||
grp[mit->first] = meta;
|
||||
mit->second = meta;
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
++resultCount;
|
||||
|
|
|
@ -39,6 +39,14 @@ template<class ID, class MetaDataClass> class t_MetaDataCache
|
|||
{
|
||||
public:
|
||||
t_MetaDataCache() : mCache_ContainsAllMetas(false) {}
|
||||
virtual ~t_MetaDataCache()
|
||||
{
|
||||
for(auto it: mMetas)
|
||||
delete it.second;
|
||||
|
||||
for(auto it: mOldCachedItems)
|
||||
delete it.second;
|
||||
}
|
||||
|
||||
bool isCacheUpToDate() const { return mCache_ContainsAllMetas ; }
|
||||
void setCacheUpToDate(bool b) { mCache_ContainsAllMetas = b; }
|
||||
|
|
|
@ -512,7 +512,7 @@ int RsGenExchange::createGroupSignatures(RsTlvKeySignatureSet& signSet, RsTlvBin
|
|||
if(GxsSecurity::getSignature((char*)grpData.bin_data, grpData.bin_len, authorKey, sign))
|
||||
{
|
||||
id_ret = SIGN_SUCCESS;
|
||||
mGixs->timeStampKey(grpMeta.mAuthorId,RsIdentityUsage(mServType,RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_CREATION,grpMeta.mGroupId)) ;
|
||||
mGixs->timeStampKey(grpMeta.mAuthorId,RsIdentityUsage(RsServiceType(mServType),RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_CREATION,grpMeta.mGroupId)) ;
|
||||
signSet.keySignSet[INDEX_AUTHEN_IDENTITY] = sign;
|
||||
}
|
||||
else
|
||||
|
@ -680,7 +680,7 @@ int RsGenExchange::createMsgSignatures(RsTlvKeySignatureSet& signSet, RsTlvBinar
|
|||
if(GxsSecurity::getSignature((char*)msgData.bin_data, msgData.bin_len, authorKey, sign))
|
||||
{
|
||||
id_ret = SIGN_SUCCESS;
|
||||
mGixs->timeStampKey(msgMeta.mAuthorId,RsIdentityUsage(mServType,RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_CREATION,msgMeta.mGroupId,msgMeta.mMsgId)) ;
|
||||
mGixs->timeStampKey(msgMeta.mAuthorId,RsIdentityUsage(RsServiceType(mServType),RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_CREATION,msgMeta.mGroupId,msgMeta.mMsgId,msgMeta.mParentId,msgMeta.mThreadId)) ;
|
||||
signSet.keySignSet[INDEX_AUTHEN_IDENTITY] = sign;
|
||||
}
|
||||
else
|
||||
|
@ -905,7 +905,11 @@ int RsGenExchange::validateMsg(RsNxsMsg *msg, const uint32_t& grpFlag, const uin
|
|||
{
|
||||
RsTlvKeySignature sign = metaData.signSet.keySignSet[INDEX_AUTHEN_IDENTITY];
|
||||
idValidate &= GxsSecurity::validateNxsMsg(*msg, sign, authorKey);
|
||||
mGixs->timeStampKey(metaData.mAuthorId,RsIdentityUsage(mServType,RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_VALIDATION,metaData.mGroupId,metaData.mMsgId)) ;
|
||||
mGixs->timeStampKey(metaData.mAuthorId,RsIdentityUsage(RsServiceType(mServType),RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_VALIDATION,
|
||||
metaData.mGroupId,
|
||||
metaData.mMsgId,
|
||||
metaData.mParentId,
|
||||
metaData.mThreadId)) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -949,7 +953,12 @@ int RsGenExchange::validateMsg(RsNxsMsg *msg, const uint32_t& grpFlag, const uin
|
|||
{
|
||||
std::list<RsPeerId> peers;
|
||||
peers.push_back(msg->PeerId());
|
||||
mGixs->requestKey(metaData.mAuthorId, peers, RsIdentityUsage(serviceType(),RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_VALIDATION,metaData.mGroupId,metaData.mMsgId));
|
||||
mGixs->requestKey(metaData.mAuthorId, peers, RsIdentityUsage((RsServiceType)serviceType(),
|
||||
RsIdentityUsage::MESSAGE_AUTHOR_SIGNATURE_VALIDATION,
|
||||
metaData.mGroupId,
|
||||
metaData.mMsgId,
|
||||
metaData.mParentId,
|
||||
metaData.mThreadId));
|
||||
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << ", Key missing. Retry later." << std::endl;
|
||||
|
@ -1026,7 +1035,7 @@ int RsGenExchange::validateGrp(RsNxsGrp* grp)
|
|||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << " key ID validation result: " << idValidate << std::endl;
|
||||
#endif
|
||||
mGixs->timeStampKey(metaData.mAuthorId,RsIdentityUsage(mServType,RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_VALIDATION,metaData.mGroupId));
|
||||
mGixs->timeStampKey(metaData.mAuthorId,RsIdentityUsage(RsServiceType(mServType),RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_VALIDATION,metaData.mGroupId));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1044,7 +1053,7 @@ int RsGenExchange::validateGrp(RsNxsGrp* grp)
|
|||
#endif
|
||||
std::list<RsPeerId> peers;
|
||||
peers.push_back(grp->PeerId());
|
||||
mGixs->requestKey(metaData.mAuthorId, peers,RsIdentityUsage(mServType,RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_VALIDATION,metaData.mGroupId));
|
||||
mGixs->requestKey(metaData.mAuthorId, peers,RsIdentityUsage(RsServiceType(mServType),RsIdentityUsage::GROUP_AUTHOR_SIGNATURE_VALIDATION,metaData.mGroupId));
|
||||
return VALIDATE_FAIL_TRY_LATER;
|
||||
}
|
||||
}
|
||||
|
@ -3346,7 +3355,7 @@ bool RsGenExchange::updateValid(const RsGxsGrpMetaData& oldGrpMeta, const RsNxsG
|
|||
// also check this is the latest published group
|
||||
bool latest = newGrp.metaData->mPublishTs > oldGrpMeta.mPublishTs;
|
||||
|
||||
mGixs->timeStampKey(newGrp.metaData->mAuthorId, RsIdentityUsage(mServType,RsIdentityUsage::GROUP_ADMIN_SIGNATURE_CREATION, oldGrpMeta.mGroupId)) ;
|
||||
mGixs->timeStampKey(newGrp.metaData->mAuthorId, RsIdentityUsage(RsServiceType(mServType),RsIdentityUsage::GROUP_ADMIN_SIGNATURE_CREATION, oldGrpMeta.mGroupId)) ;
|
||||
|
||||
return GxsSecurity::validateNxsGrp(newGrp, adminSign, keyMit->second) && latest;
|
||||
}
|
||||
|
|
|
@ -1046,9 +1046,9 @@ bool RsGxsDataAccess::getMsgMetaDataList( const GxsMsgReq& msgIds, const RsTokRe
|
|||
// Now loop once over message Metas and see if they have a parent. If yes, then mark the parent to be discarded.
|
||||
|
||||
for(uint32_t i=0;i<metaV.size();++i)
|
||||
if(!metaV[i]->mParentId.isNull() && metaV[i]->mParentId != metaV[i]->mMsgId) // this one is a follow up
|
||||
if(!metaV[i]->mOrigMsgId.isNull() && metaV[i]->mOrigMsgId != metaV[i]->mMsgId) // this one is a follow up
|
||||
{
|
||||
auto it = index_in_metaV.find(metaV[i]->mParentId);
|
||||
auto it = index_in_metaV.find(metaV[i]->mOrigMsgId);
|
||||
|
||||
if(it != index_in_metaV.end())
|
||||
keep[it->second] = false;
|
||||
|
@ -1240,61 +1240,42 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
|
|||
onlyThreadMsgs = true;
|
||||
}
|
||||
|
||||
if (onlyAllVersions && onlyChildMsgs)
|
||||
{
|
||||
#ifdef DATA_DEBUG
|
||||
RsDbg() << "RsGxsDataAccess::getMsgRelatedList() ERROR Incompatible FLAGS (VERSIONS & PARENT)" << std::endl;
|
||||
#endif
|
||||
if(onlyAllVersions && onlyChildMsgs)
|
||||
{
|
||||
RS_ERR("Incompatible FLAGS (VERSIONS & PARENT)");
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
if(onlyAllVersions && onlyThreadMsgs)
|
||||
{
|
||||
RS_ERR("Incompatible FLAGS (VERSIONS & THREAD)");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (onlyAllVersions && onlyThreadMsgs)
|
||||
{
|
||||
#ifdef DATA_DEBUG
|
||||
RsDbg() << "RsGxsDataAccess::getMsgRelatedList() ERROR Incompatible FLAGS (VERSIONS & THREAD)" << std::endl;
|
||||
#endif
|
||||
if((!onlyLatestMsgs) && onlyChildMsgs)
|
||||
{
|
||||
RS_ERR("Incompatible FLAGS (!LATEST & PARENT)");
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
if((!onlyLatestMsgs) && onlyThreadMsgs)
|
||||
{
|
||||
RS_ERR("Incompatible FLAGS (!LATEST & THREAD)");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((!onlyLatestMsgs) && onlyChildMsgs)
|
||||
{
|
||||
#ifdef DATA_DEBUG
|
||||
RsDbg() << "RsGxsDataAccess::getMsgRelatedList() ERROR Incompatible FLAGS (!LATEST & PARENT)" << std::endl;
|
||||
#endif
|
||||
if(onlyChildMsgs && onlyThreadMsgs)
|
||||
{
|
||||
RS_ERR("Incompatible FLAGS (PARENT & THREAD)");
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((!onlyLatestMsgs) && onlyThreadMsgs)
|
||||
{
|
||||
#ifdef DATA_DEBUG
|
||||
RsDbg() << "RsGxsDataAccess::getMsgRelatedList() ERROR Incompatible FLAGS (!LATEST & THREAD)" << std::endl;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (onlyChildMsgs && onlyThreadMsgs)
|
||||
{
|
||||
#ifdef DATA_DEBUG
|
||||
RsDbg() << "RsGxsDataAccess::getMsgRelatedList() ERROR Incompatible FLAGS (PARENT & THREAD)" << std::endl;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* FALL BACK OPTION */
|
||||
if ((!onlyLatestMsgs) && (!onlyAllVersions) && (!onlyChildMsgs) && (!onlyThreadMsgs))
|
||||
{
|
||||
#ifdef DATA_DEBUG
|
||||
RsDbg() << "RsGxsDataAccess::getMsgRelatedList() FALLBACK -> NO FLAGS -> SIMPLY RETURN nothing" << std::endl;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
if( (!onlyLatestMsgs) && (!onlyAllVersions) && (!onlyChildMsgs) &&
|
||||
(!onlyThreadMsgs) )
|
||||
{
|
||||
RS_WARN("NO FLAGS -> SIMPLY RETURN nothing");
|
||||
return true;
|
||||
}
|
||||
|
||||
for(auto vit_msgIds(req->mMsgIds.begin()); vit_msgIds != req->mMsgIds.end(); ++vit_msgIds)
|
||||
{
|
||||
|
@ -1330,14 +1311,11 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req)
|
|||
}
|
||||
}
|
||||
|
||||
if(!origMeta)
|
||||
{
|
||||
#ifdef DATA_DEBUG
|
||||
RsDbg() << "RsGxsDataAccess::getMsgRelatedInfo(): Cannot find meta of msgId (to relate to)!"
|
||||
<< std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
if(!origMeta)
|
||||
{
|
||||
RS_ERR("Cannot find meta of msgId: ", msgId, " to relate to");
|
||||
return false;
|
||||
}
|
||||
|
||||
const RsGxsMessageId& origMsgId = origMeta->mOrigMsgId;
|
||||
std::map<RsGxsMessageId, const RsGxsMsgMetaData*>& metaMap = filterMap[grpId];
|
||||
|
|
|
@ -275,7 +275,7 @@
|
|||
NXS_NET_DEBUG_9 gxs distant search
|
||||
|
||||
***/
|
||||
#define NXS_NET_DEBUG_0 1
|
||||
//#define NXS_NET_DEBUG_0 1
|
||||
//#define NXS_NET_DEBUG_1 1
|
||||
//#define NXS_NET_DEBUG_2 1
|
||||
//#define NXS_NET_DEBUG_3 1
|
||||
|
@ -324,8 +324,8 @@ static const uint32_t RS_NXS_ITEM_ENCRYPTION_STATUS_GXS_KEY_MISSING = 0x05 ;
|
|||
|| defined(NXS_NET_DEBUG_8) || defined(NXS_NET_DEBUG_9)
|
||||
|
||||
static const RsPeerId peer_to_print = RsPeerId();//std::string("a97fef0e2dc82ddb19200fb30f9ac575")) ;
|
||||
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 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_GXSID; // 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)
|
||||
|
||||
class nullstream: public std::ostream {};
|
||||
|
@ -593,32 +593,30 @@ void RsGxsNetService::syncWithPeers()
|
|||
return;
|
||||
}
|
||||
|
||||
std::set<RsPeerId>::iterator sit = peers.begin();
|
||||
// for now just grps
|
||||
for(auto sit = peers.begin(); sit != peers.end(); ++sit)
|
||||
{
|
||||
|
||||
// for now just grps
|
||||
for(; sit != peers.end(); ++sit)
|
||||
{
|
||||
const RsPeerId peerId = *sit;
|
||||
|
||||
const RsPeerId peerId = *sit;
|
||||
ClientGrpMap::const_iterator cit = mClientGrpUpdateMap.find(peerId);
|
||||
uint32_t updateTS = 0;
|
||||
|
||||
ClientGrpMap::const_iterator cit = mClientGrpUpdateMap.find(peerId);
|
||||
uint32_t updateTS = 0;
|
||||
|
||||
if(cit != mClientGrpUpdateMap.end())
|
||||
{
|
||||
const RsGxsGrpUpdate *gui = &cit->second;
|
||||
updateTS = gui->grpUpdateTS;
|
||||
}
|
||||
RsNxsSyncGrpReqItem *grp = new RsNxsSyncGrpReqItem(mServType);
|
||||
grp->clear();
|
||||
grp->PeerId(*sit);
|
||||
grp->updateTS = updateTS;
|
||||
if(cit != mClientGrpUpdateMap.end())
|
||||
{
|
||||
const RsGxsGrpUpdate *gui = &cit->second;
|
||||
updateTS = gui->grpUpdateTS;
|
||||
}
|
||||
RsNxsSyncGrpReqItem *grp = new RsNxsSyncGrpReqItem(mServType);
|
||||
grp->clear();
|
||||
grp->PeerId(*sit);
|
||||
grp->updateTS = updateTS;
|
||||
|
||||
#ifdef NXS_NET_DEBUG_5
|
||||
GXSNETDEBUG_P_(*sit) << "Service "<< std::hex << ((mServiceInfo.mServiceType >> 8)& 0xffff) << std::dec << " sending global group TS of peer id: " << *sit << " ts=" << nice_time_stamp(time(NULL),updateTS) << " (secs ago) to himself" << std::endl;
|
||||
GXSNETDEBUG_P_(*sit) << "Service "<< std::hex << ((mServiceInfo.mServiceType >> 8)& 0xffff) << std::dec << " sending global group TS of peer id: " << *sit << " ts=" << nice_time_stamp(time(NULL),updateTS) << " (secs ago) to himself" << std::endl;
|
||||
#endif
|
||||
generic_sendItem(grp);
|
||||
}
|
||||
generic_sendItem(grp);
|
||||
}
|
||||
|
||||
if(!mAllowMsgSync)
|
||||
return ;
|
||||
|
@ -644,15 +642,13 @@ void RsGxsNetService::syncWithPeers()
|
|||
}
|
||||
}
|
||||
|
||||
sit = peers.begin();
|
||||
|
||||
// Synchronise group msg for groups which we're subscribed to
|
||||
// For each peer and each group, we send to the peer the time stamp of the most
|
||||
// recent modification the peer has sent. If the peer has more recent messages he will send them, because its latest
|
||||
// modifications will be more recent. This ensures that we always compare timestamps all taken in the same
|
||||
// computer (the peer's computer in this case)
|
||||
|
||||
for(; sit != peers.end(); ++sit)
|
||||
for(auto sit = peers.begin(); sit != peers.end(); ++sit)
|
||||
{
|
||||
const RsPeerId& peerId = *sit;
|
||||
|
||||
|
@ -3183,7 +3179,8 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
|||
{
|
||||
grpItemL.push_back(item);
|
||||
grpMetaMap[item->grpId] = NULL;
|
||||
}else
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_0
|
||||
GXSNETDEBUG_PG(tr->mTransaction->PeerId(),item->grpId) << "RsGxsNetService::genReqGrpTransaction(): item failed to caste to RsNxsSyncMsgItem* " << std::endl;
|
||||
|
@ -3226,7 +3223,7 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
|||
RsNxsSyncGrpItem*& grpSyncItem = *llit;
|
||||
const RsGxsGroupId& grpId = grpSyncItem->grpId;
|
||||
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::const_iterator metaIter = grpMetaMap.find(grpId);
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::const_iterator metaIter = grpMetaMap.find(grpId);
|
||||
bool haveItem = false;
|
||||
bool latestVersion = false;
|
||||
|
||||
|
@ -3237,19 +3234,21 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
|||
}
|
||||
// FIXTESTS global variable rsReputations not available in unittests!
|
||||
|
||||
#warning csoler 2016-12-23: Update the code below to correctly send/recv dependign on reputation
|
||||
if( !grpSyncItem->authorId.isNull() &&
|
||||
mReputations->overallReputationLevel(grpSyncItem->authorId) ==
|
||||
RsReputationLevel::LOCALLY_NEGATIVE )
|
||||
if( mReputations->overallReputationLevel(RsGxsId(grpSyncItem->grpId)) == RsReputationLevel::LOCALLY_NEGATIVE )
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_0
|
||||
GXSNETDEBUG_PG(tr->mTransaction->PeerId(),grpId) << " Identity " << grpSyncItem->authorId << " is banned. Not syncing group." << std::endl;
|
||||
GXSNETDEBUG_PG(tr->mTransaction->PeerId(),grpId) << " Identity " << grpSyncItem->grpId << " is banned. Not GXS-syncing group." << std::endl;
|
||||
#endif
|
||||
continue ;
|
||||
}
|
||||
|
||||
if( (mGrpAutoSync && !haveItem) || latestVersion)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_0
|
||||
GXSNETDEBUG_PG(tr->mTransaction->PeerId(),grpId) << " Identity " << grpId << " will be sync-ed using GXS. mGrpAutoSync:" << mGrpAutoSync << " haveItem:" << haveItem << " latest_version: " << latestVersion << std::endl;
|
||||
#endif
|
||||
addGroupItemToList(tr, grpId, transN, reqList);
|
||||
}
|
||||
}
|
||||
|
||||
if(!reqList.empty())
|
||||
|
|
|
@ -215,7 +215,8 @@ bool RsGxsIntegrityCheck::check()
|
|||
rsReputations->overallReputationLevel(
|
||||
grp->metaData->mAuthorId ) >
|
||||
RsReputationLevel::LOCALLY_NEGATIVE )
|
||||
used_gxs_ids.insert(std::make_pair(grp->metaData->mAuthorId, RsIdentityUsage(mGenExchangeClient->serviceType(), RsIdentityUsage::GROUP_AUTHOR_KEEP_ALIVE,grp->grpId)));
|
||||
used_gxs_ids.insert(std::make_pair(grp->metaData->mAuthorId, RsIdentityUsage(RsServiceType(mGenExchangeClient->serviceType()),
|
||||
RsIdentityUsage::GROUP_AUTHOR_KEEP_ALIVE,grp->grpId)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -404,7 +405,12 @@ bool RsGxsIntegrityCheck::check()
|
|||
rsReputations->overallReputationLevel(
|
||||
msg->metaData->mAuthorId ) >
|
||||
RsReputationLevel::LOCALLY_NEGATIVE )
|
||||
used_gxs_ids.insert(std::make_pair(msg->metaData->mAuthorId,RsIdentityUsage(mGenExchangeClient->serviceType(),RsIdentityUsage::MESSAGE_AUTHOR_KEEP_ALIVE,msg->metaData->mGroupId,msg->metaData->mMsgId))) ;
|
||||
used_gxs_ids.insert(std::make_pair(msg->metaData->mAuthorId,RsIdentityUsage(RsServiceType(mGenExchangeClient->serviceType()),
|
||||
RsIdentityUsage::MESSAGE_AUTHOR_KEEP_ALIVE,
|
||||
msg->metaData->mGroupId,
|
||||
msg->metaData->mMsgId,
|
||||
msg->metaData->mParentId,
|
||||
msg->metaData->mThreadId))) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -976,7 +976,7 @@ void p3GxsTunnelService::handleRecvDHPublicKey(RsGxsTunnelDHPublicKeyItem *item)
|
|||
std::cerr << "(SS) Signature was verified and it doesn't check! This is a security issue!" << std::endl;
|
||||
return ;
|
||||
}
|
||||
mGixs->timeStampKey(item->signature.keyId,RsIdentityUsage(RS_SERVICE_TYPE_GXS_TUNNEL,RsIdentityUsage::GXS_TUNNEL_DH_SIGNATURE_CHECK));
|
||||
mGixs->timeStampKey(item->signature.keyId,RsIdentityUsage(RsServiceType::GXS_TUNNEL,RsIdentityUsage::GXS_TUNNEL_DH_SIGNATURE_CHECK));
|
||||
|
||||
#ifdef DEBUG_GXS_TUNNEL
|
||||
std::cerr << " Signature checks! Sender's ID = " << senders_id << std::endl;
|
||||
|
|
|
@ -238,7 +238,7 @@ win32-x-g++ {
|
|||
}
|
||||
################################# Windows ##########################################
|
||||
|
||||
win32-g++ {
|
||||
win32-g++|win32-clang-g++ {
|
||||
QMAKE_CC = $${QMAKE_CXX}
|
||||
OBJECTS_DIR = temp/obj
|
||||
MOC_DIR = temp/moc
|
||||
|
@ -852,23 +852,41 @@ rs_jsonapi {
|
|||
no_rs_cross_compiling {
|
||||
DUMMYRESTBEDINPUT = FORCE
|
||||
CMAKE_GENERATOR_OVERRIDE=""
|
||||
win32-g++:CMAKE_GENERATOR_OVERRIDE="-G \"MSYS Makefiles\""
|
||||
win32-g++|win32-clang-g++ {
|
||||
isEmpty(QMAKE_SH) {
|
||||
CMAKE_GENERATOR_OVERRIDE="-G \"MinGW Makefiles\""
|
||||
} else {
|
||||
CMAKE_GENERATOR_OVERRIDE="-G \"MSYS Makefiles\""
|
||||
}
|
||||
}
|
||||
genrestbedlib.name = Generating librestbed.
|
||||
genrestbedlib.input = DUMMYRESTBEDINPUT
|
||||
genrestbedlib.output = $$clean_path($${RESTBED_BUILD_PATH}/librestbed.a)
|
||||
genrestbedlib.CONFIG += target_predeps combine
|
||||
genrestbedlib.variable_out = PRE_TARGETDEPS
|
||||
genrestbedlib.commands = \
|
||||
cd $${RS_SRC_PATH} && ( \
|
||||
git submodule update --init supportlibs/restbed ; \
|
||||
cd $${RESTBED_SRC_PATH} ; \
|
||||
git submodule update --init dependency/asio ; \
|
||||
git submodule update --init dependency/catch ; \
|
||||
git submodule update --init dependency/kashmir ; \
|
||||
true ) && \
|
||||
mkdir -p $${RESTBED_BUILD_PATH} && cd $${RESTBED_BUILD_PATH} && \
|
||||
win32-g++:isEmpty(QMAKE_SH) {
|
||||
genrestbedlib.commands = \
|
||||
cd $$shell_path($${RS_SRC_PATH}) && git submodule update --init supportlibs/restbed || cd . $$escape_expand(\\n\\t) \
|
||||
cd $$shell_path($${RESTBED_SRC_PATH}) && git submodule update --init dependency/asio || cd . $$escape_expand(\\n\\t) \
|
||||
cd $$shell_path($${RESTBED_SRC_PATH}) && git submodule update --init dependency/catch || cd . $$escape_expand(\\n\\t )\
|
||||
cd $$shell_path($${RESTBED_SRC_PATH}) && git submodule update --init dependency/kashmir || cd . $$escape_expand(\\n\\t) \
|
||||
$(CHK_DIR_EXISTS) $$shell_path($$UDP_DISCOVERY_BUILD_PATH) $(MKDIR) $$shell_path($${UDP_DISCOVERY_BUILD_PATH}) $$escape_expand(\\n\\t)
|
||||
} else {
|
||||
genrestbedlib.commands = \
|
||||
cd $${RS_SRC_PATH} && ( \
|
||||
git submodule update --init supportlibs/restbed ; \
|
||||
cd $${RESTBED_SRC_PATH} ; \
|
||||
git submodule update --init dependency/asio ; \
|
||||
git submodule update --init dependency/catch ; \
|
||||
git submodule update --init dependency/kashmir ; \
|
||||
true ) && \
|
||||
mkdir -p $${RESTBED_BUILD_PATH} &&
|
||||
}
|
||||
genrestbedlib.commands += \
|
||||
cd $$shell_path($${RESTBED_BUILD_PATH}) && \
|
||||
cmake \
|
||||
-DCMAKE_CXX_COMPILER=$$QMAKE_CXX \
|
||||
\"-DCMAKE_CXX_FLAGS=$${QMAKE_CXXFLAGS}\" \
|
||||
$${CMAKE_GENERATOR_OVERRIDE} -DBUILD_SSL=OFF \
|
||||
-DCMAKE_INSTALL_PREFIX=. -B. \
|
||||
-H$$shell_path($${RESTBED_SRC_PATH}) && \
|
||||
|
@ -881,7 +899,7 @@ rs_jsonapi {
|
|||
genrestbedheader.output = $${RESTBED_HEADER_FILE}
|
||||
genrestbedheader.CONFIG += target_predeps no_link
|
||||
genrestbedheader.variable_out = HEADERS
|
||||
genrestbedheader.commands = cd $${RESTBED_BUILD_PATH} && $(MAKE) install
|
||||
genrestbedheader.commands = cd $$shell_path($${RESTBED_BUILD_PATH}) && $(MAKE) install
|
||||
QMAKE_EXTRA_COMPILERS += genrestbedheader
|
||||
}
|
||||
|
||||
|
@ -897,13 +915,19 @@ rs_jsonapi {
|
|||
genjsonapi.clean = $${WRAPPERS_INCL_FILE} $${WRAPPERS_REG_FILE}
|
||||
genjsonapi.CONFIG += target_predeps combine no_link
|
||||
genjsonapi.variable_out = HEADERS
|
||||
genjsonapi.commands = \
|
||||
mkdir -p $${JSONAPI_GENERATOR_OUT} && \
|
||||
cp $${DOXIGEN_CONFIG_SRC} $${DOXIGEN_CONFIG_OUT} && \
|
||||
echo OUTPUT_DIRECTORY=$${JSONAPI_GENERATOR_OUT} >> $${DOXIGEN_CONFIG_OUT} && \
|
||||
echo INPUT=$${DOXIGEN_INPUT_DIRECTORY} >> $${DOXIGEN_CONFIG_OUT} && \
|
||||
doxygen $${DOXIGEN_CONFIG_OUT} && \
|
||||
$${JSONAPI_GENERATOR_EXE} $${JSONAPI_GENERATOR_SRC} $${JSONAPI_GENERATOR_OUT};
|
||||
win32-g++:isEmpty(QMAKE_SH) {
|
||||
genjsonapi.commands = \
|
||||
$(CHK_DIR_EXISTS) $$shell_path($$JSONAPI_GENERATOR_OUT) $(MKDIR) $$shell_path($${JSONAPI_GENERATOR_OUT}) $$escape_expand(\\n\\t)
|
||||
} else {
|
||||
genjsonapi.commands = \
|
||||
mkdir -p $${JSONAPI_GENERATOR_OUT} && \
|
||||
cp $${DOXIGEN_CONFIG_SRC} $${DOXIGEN_CONFIG_OUT} && \
|
||||
echo OUTPUT_DIRECTORY=$${JSONAPI_GENERATOR_OUT} >> $${DOXIGEN_CONFIG_OUT} && \
|
||||
echo INPUT=$${DOXIGEN_INPUT_DIRECTORY} >> $${DOXIGEN_CONFIG_OUT} && \
|
||||
doxygen $${DOXIGEN_CONFIG_OUT} &&
|
||||
}
|
||||
genjsonapi.commands += \
|
||||
$${JSONAPI_GENERATOR_EXE} $${JSONAPI_GENERATOR_SRC} $${JSONAPI_GENERATOR_OUT}
|
||||
QMAKE_EXTRA_COMPILERS += genjsonapi
|
||||
|
||||
# Force recalculation of libretroshare dependencies see https://stackoverflow.com/a/47884045
|
||||
|
@ -949,20 +973,34 @@ rs_broadcast_discovery {
|
|||
no_rs_cross_compiling {
|
||||
DUMMYQMAKECOMPILERINPUT = FORCE
|
||||
CMAKE_GENERATOR_OVERRIDE=""
|
||||
win32-g++:CMAKE_GENERATOR_OVERRIDE="-G \"MSYS Makefiles\""
|
||||
win32-g++|win32-clang-g++ {
|
||||
isEmpty(QMAKE_SH) {
|
||||
CMAKE_GENERATOR_OVERRIDE="-G \"MinGW Makefiles\""
|
||||
} else {
|
||||
CMAKE_GENERATOR_OVERRIDE="-G \"MSYS Makefiles\""
|
||||
}
|
||||
}
|
||||
udpdiscoverycpplib.name = Generating libudp-discovery.a.
|
||||
udpdiscoverycpplib.input = DUMMYQMAKECOMPILERINPUT
|
||||
udpdiscoverycpplib.output = $$clean_path($${UDP_DISCOVERY_BUILD_PATH}/libudp-discovery.a)
|
||||
udpdiscoverycpplib.CONFIG += target_predeps combine
|
||||
udpdiscoverycpplib.variable_out = PRE_TARGETDEPS
|
||||
udpdiscoverycpplib.commands = \
|
||||
cd $${RS_SRC_PATH} && ( \
|
||||
git submodule update --init supportlibs/udp-discovery-cpp || \
|
||||
true ) && \
|
||||
mkdir -p $${UDP_DISCOVERY_BUILD_PATH} && \
|
||||
cd $${UDP_DISCOVERY_BUILD_PATH} && \
|
||||
win32-g++:isEmpty(QMAKE_SH) {
|
||||
udpdiscoverycpplib.commands = \
|
||||
cd $$shell_path($${RS_SRC_PATH}) && git submodule update --init supportlibs/udp-discovery-cpp || cd . $$escape_expand(\\n\\t) \
|
||||
$(CHK_DIR_EXISTS) $$shell_path($$UDP_DISCOVERY_BUILD_PATH) $(MKDIR) $$shell_path($${UDP_DISCOVERY_BUILD_PATH}) $$escape_expand(\\n\\t)
|
||||
} else {
|
||||
udpdiscoverycpplib.commands = \
|
||||
cd $${RS_SRC_PATH} && ( \
|
||||
git submodule update --init supportlibs/udp-discovery-cpp || \
|
||||
true ) && \
|
||||
mkdir -p $${UDP_DISCOVERY_BUILD_PATH} &&
|
||||
}
|
||||
udpdiscoverycpplib.commands += \
|
||||
cd $$shell_path($${UDP_DISCOVERY_BUILD_PATH}) && \
|
||||
cmake -DCMAKE_C_COMPILER=$$fixQmakeCC($$QMAKE_CC) \
|
||||
-DCMAKE_CXX_COMPILER=$$QMAKE_CXX \
|
||||
\"-DCMAKE_CXX_FLAGS=$${QMAKE_CXXFLAGS}\" \
|
||||
$${CMAKE_GENERATOR_OVERRIDE} \
|
||||
-DBUILD_EXAMPLE=OFF -DBUILD_TOOL=OFF \
|
||||
-DCMAKE_INSTALL_PREFIX=. -B. \
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright (C) 2012-2014 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2018-2019 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* Copyright (C) 2018-2020 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* Copyright (C) 2019-2020 Asociación Civil Altermundi <info@altermundi.net> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -25,6 +26,7 @@
|
|||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <system_error>
|
||||
|
||||
#include "retroshare/rstokenservice.h"
|
||||
#include "retroshare/rsgxsifacehelper.h"
|
||||
|
@ -353,6 +355,19 @@ public:
|
|||
RsGxsGroupId& forumId = RS_DEFAULT_STORAGE_PARAM(RsGxsGroupId),
|
||||
std::string& errMsg = RS_DEFAULT_STORAGE_PARAM(std::string) ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get posts related to the given post.
|
||||
* If the set is empty, nothing is returned.
|
||||
* @jsonapi{development}
|
||||
* @param[in] forumId id of the forum of which the content is requested
|
||||
* @param[in] parentId id of the post of which child posts (aka replies)
|
||||
* are requested.
|
||||
* @param[out] childPosts storage for the child posts
|
||||
* @return false if something failed, true otherwhise
|
||||
*/
|
||||
virtual std::error_condition getChildPosts(
|
||||
const RsGxsGroupId& forumId, const RsGxsMessageId& parentId,
|
||||
std::vector<RsGxsForumMsg>& childPosts ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Create forum. Blocking API.
|
||||
|
|
|
@ -50,12 +50,13 @@ enum class TokenRequestType: uint8_t
|
|||
__NONE = 0x00, /// Used to detect uninitialized
|
||||
GROUP_DATA = 0x01,
|
||||
GROUP_META = 0x02,
|
||||
POSTS = 0x03,
|
||||
ALL_POSTS = 0x04,
|
||||
MSG_RELATED_INFO = 0x05,
|
||||
GROUP_STATISTICS = 0x06,
|
||||
SERVICE_STATISTICS = 0x07,
|
||||
NO_KILL_TYPE = 0x08,
|
||||
GROUP_IDS = 0x03,
|
||||
POSTS = 0x04,
|
||||
ALL_POSTS = 0x05,
|
||||
MSG_RELATED_INFO = 0x06,
|
||||
GROUP_STATISTICS = 0x07,
|
||||
SERVICE_STATISTICS = 0x08,
|
||||
NO_KILL_TYPE = 0x09,
|
||||
__MAX /// Used to detect out of range
|
||||
};
|
||||
|
||||
|
@ -263,6 +264,7 @@ public:
|
|||
{
|
||||
case GXS_REQUEST_TYPE_GROUP_DATA: token_request_type = TokenRequestType::GROUP_DATA; break;
|
||||
case GXS_REQUEST_TYPE_GROUP_META: token_request_type = TokenRequestType::GROUP_META; break;
|
||||
case GXS_REQUEST_TYPE_GROUP_IDS: token_request_type = TokenRequestType::GROUP_IDS; break;
|
||||
default:
|
||||
RsErr() << __PRETTY_FUNCTION__ << "(EE) Unexpected request type " << opts.mReqType << "!!" << std::endl;
|
||||
return false;
|
||||
|
@ -292,6 +294,7 @@ public:
|
|||
{
|
||||
case GXS_REQUEST_TYPE_GROUP_DATA: token_request_type = TokenRequestType::GROUP_DATA; break;
|
||||
case GXS_REQUEST_TYPE_GROUP_META: token_request_type = TokenRequestType::GROUP_META; break;
|
||||
case GXS_REQUEST_TYPE_GROUP_IDS: token_request_type = TokenRequestType::GROUP_IDS; break;
|
||||
default:
|
||||
RsErr() << __PRETTY_FUNCTION__ << "(EE) Unexpected request type " << opts.mReqType << "!!" << std::endl;
|
||||
return false;
|
||||
|
|
|
@ -234,31 +234,30 @@ struct RsIdentityUsage : RsSerializable
|
|||
GXS_TUNNEL_DH_SIGNATURE_CHECK = 0x0c,
|
||||
GXS_TUNNEL_DH_SIGNATURE_CREATION = 0x0d,
|
||||
|
||||
/// Identity received through GXS sync
|
||||
IDENTITY_NEW_FROM_GXS_SYNC = 0x0e,
|
||||
/// Group update on that identity data. Can be avatar, name, etc.
|
||||
IDENTITY_DATA_UPDATE = 0x0e,
|
||||
IDENTITY_NEW_FROM_DISCOVERY = 0x0f,
|
||||
/// Explicit request to friend
|
||||
IDENTITY_NEW_FROM_EXPLICIT_REQUEST = 0x10,
|
||||
|
||||
/// Any signature verified for that identity
|
||||
IDENTITY_GENERIC_SIGNATURE_CHECK = 0x0f,
|
||||
IDENTITY_GENERIC_SIGNATURE_CHECK = 0x11,
|
||||
|
||||
/// Any signature made by that identity
|
||||
IDENTITY_GENERIC_SIGNATURE_CREATION = 0x10,
|
||||
IDENTITY_GENERIC_SIGNATURE_CREATION = 0x12,
|
||||
|
||||
IDENTITY_GENERIC_ENCRYPTION = 0x11,
|
||||
IDENTITY_GENERIC_DECRYPTION = 0x12,
|
||||
CIRCLE_MEMBERSHIP_CHECK = 0x13
|
||||
IDENTITY_GENERIC_ENCRYPTION = 0x13,
|
||||
IDENTITY_GENERIC_DECRYPTION = 0x14,
|
||||
CIRCLE_MEMBERSHIP_CHECK = 0x15
|
||||
} ;
|
||||
|
||||
RS_DEPRECATED
|
||||
RsIdentityUsage( uint16_t service, const RsIdentityUsage::UsageCode& code,
|
||||
const RsGxsGroupId& gid = RsGxsGroupId(),
|
||||
const RsGxsMessageId& mid = RsGxsMessageId(),
|
||||
uint64_t additional_id=0,
|
||||
const std::string& comment = std::string() );
|
||||
|
||||
RsIdentityUsage( RsServiceType service,
|
||||
RsIdentityUsage::UsageCode code,
|
||||
const RsGxsGroupId& gid = RsGxsGroupId(),
|
||||
const RsGxsMessageId& mid = RsGxsMessageId(),
|
||||
const RsGxsMessageId& message_id = RsGxsMessageId(),
|
||||
const RsGxsMessageId& parent_id = RsGxsMessageId(),
|
||||
const RsGxsMessageId& thread_id = RsGxsMessageId(),
|
||||
uint64_t additional_id=0,
|
||||
const std::string& comment = std::string() );
|
||||
|
||||
|
@ -275,6 +274,12 @@ struct RsIdentityUsage : RsSerializable
|
|||
/// Message ID using the identity
|
||||
RsGxsMessageId mMsgId;
|
||||
|
||||
/// Reference message ID. Useful for votes/comments
|
||||
RsGxsMessageId mParentId;
|
||||
|
||||
/// Reference message ID. Useful for votes/comments
|
||||
RsGxsMessageId mThreadId;
|
||||
|
||||
/// Some additional ID. Can be used for e.g. chat lobbies.
|
||||
uint64_t mAdditionalId;
|
||||
|
||||
|
|
|
@ -35,11 +35,38 @@
|
|||
class RsWire;
|
||||
extern RsWire *rsWire;
|
||||
|
||||
struct RsWireGroup: RsGxsGenericGroupData
|
||||
class RsWireGroup;
|
||||
typedef std::shared_ptr<RsWireGroup> RsWireGroupSPtr;
|
||||
typedef std::shared_ptr<const RsWireGroup> RsWireGroupConstSPtr;
|
||||
|
||||
class RsWireGroup: public RsGxsGenericGroupData
|
||||
{
|
||||
public:
|
||||
std::string mDescription;
|
||||
RsGxsImage mIcon;
|
||||
RsWireGroup();
|
||||
|
||||
std::string mTagline;
|
||||
std::string mLocation;
|
||||
|
||||
// Images max size should be enforced.
|
||||
RsGxsImage mHeadshot; // max size?
|
||||
RsGxsImage mMasthead; // max size?
|
||||
|
||||
// Unserialised stuff ---------------------
|
||||
|
||||
// These are this groups top-level msgs.
|
||||
uint32_t mGroupPulses;
|
||||
uint32_t mGroupRepublishes;
|
||||
uint32_t mGroupLikes;
|
||||
uint32_t mGroupReplies;
|
||||
// how do we handle these. TODO
|
||||
// uint32_t mGroupFollowing;
|
||||
// uint32_t mGroupFollowers;
|
||||
|
||||
// These are this groups REF / RESPONSE msgs from others.
|
||||
uint32_t mRefMentions; // TODO how to handle this?
|
||||
uint32_t mRefRepublishes;
|
||||
uint32_t mRefLikes;
|
||||
uint32_t mRefReplies;
|
||||
};
|
||||
|
||||
|
||||
|
@ -60,13 +87,7 @@ struct RsWireGroup: RsGxsGenericGroupData
|
|||
*
|
||||
***********************************************************************/
|
||||
|
||||
class RsWirePlace
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* Pulse comes in three flavours.
|
||||
|
@ -82,24 +103,39 @@ class RsWirePlace
|
|||
* This info will be duplicated in two msgs - but allow data to spread easier.
|
||||
*
|
||||
* Reply Msg Pulse, will be Top-Level Msg on Publisher's Group.
|
||||
* - mPulseMode = WIRE_PULSE_TYPE_REPLY_MSG
|
||||
* - mPulseMode = WIRE_PULSE_TYPE_RESPONSE | WIRE_PULSE_TYPE_REPLY
|
||||
* - Ref fields refer to Parent (InReplyTo) Msg.
|
||||
*
|
||||
* Reply Reference, is Child Msg of Parent Msg, on Parent Publisher's Group.
|
||||
* - mPulseMode = WIRE_PULSE_TYPE_REPLY_REFERENCE
|
||||
* - mPulseMode = WIRE_PULSE_TYPE_REFERENCE | WIRE_PULSE_TYPE_REPLY
|
||||
* - Ref fields refer to Reply Msg.
|
||||
* - NB: This Msg requires Parent Msg for complete info, while other two are self-contained.
|
||||
*
|
||||
* Additionally need to sort out additional relationships.
|
||||
* - Mentions.
|
||||
* - Followers.
|
||||
* - Following.
|
||||
***********************************************************************/
|
||||
|
||||
#define WIRE_PULSE_TYPE_ORIGINAL_MSG (0x0001)
|
||||
#define WIRE_PULSE_TYPE_REPLY_MSG (0x0002)
|
||||
#define WIRE_PULSE_TYPE_REPLY_REFERENCE (0x0004)
|
||||
#define WIRE_PULSE_TYPE_ORIGINAL (0x0001)
|
||||
#define WIRE_PULSE_TYPE_RESPONSE (0x0002)
|
||||
#define WIRE_PULSE_TYPE_REFERENCE (0x0004)
|
||||
|
||||
#define WIRE_PULSE_RESPONSE_MASK (0x0f00)
|
||||
#define WIRE_PULSE_TYPE_REPLY (0x0100)
|
||||
#define WIRE_PULSE_TYPE_REPUBLISH (0x0200)
|
||||
#define WIRE_PULSE_TYPE_LIKE (0x0400)
|
||||
|
||||
#define WIRE_PULSE_SENTIMENT_NO_SENTIMENT (0x0000)
|
||||
#define WIRE_PULSE_SENTIMENT_POSITIVE (0x0001)
|
||||
#define WIRE_PULSE_SENTIMENT_NEUTRAL (0x0002)
|
||||
#define WIRE_PULSE_SENTIMENT_NEGATIVE (0x0003)
|
||||
|
||||
class RsWirePulse;
|
||||
|
||||
typedef std::shared_ptr<RsWirePulse> RsWirePulseSPtr;
|
||||
typedef std::shared_ptr<const RsWirePulse> RsWirePulseConstSPtr;
|
||||
|
||||
class RsWirePulse
|
||||
{
|
||||
public:
|
||||
|
@ -110,23 +146,50 @@ class RsWirePulse
|
|||
std::string mPulseText;
|
||||
|
||||
uint32_t mPulseType;
|
||||
uint32_t mReplySentiment; // only relevant if a reply.
|
||||
uint32_t mSentiment; // sentiment can be asserted at any point.
|
||||
|
||||
// These Ref to the related (parent or reply) if reply (MODE_REPLY_MSG set)
|
||||
// Mode REPLY_MSG only REPLY_REFERENCE
|
||||
RsGxsGroupId mRefGroupId; // PARENT_GrpId REPLY_GrpId
|
||||
std::string mRefGroupName; // PARENT_GrpName REPLY_GrpName
|
||||
RsGxsMessageId mRefOrigMsgId; // PARENT_OrigMsgId REPLY_OrigMsgId
|
||||
RsGxsId mRefAuthorId; // PARENT_AuthorId REPLY_AuthorId
|
||||
rstime_t mRefPublishTs; // PARENT_PublishTs REPLY_PublishTs
|
||||
std::string mRefPulseText; // PARENT_PulseText REPLY_PulseText
|
||||
// These Ref to the related (parent or reply) if reply (RESPONSE set)
|
||||
// Mode RESPONSE REFERENCE
|
||||
RsGxsGroupId mRefGroupId; // PARENT_GrpId REPLY_GrpId
|
||||
std::string mRefGroupName; // PARENT_GrpName REPLY_GrpName
|
||||
RsGxsMessageId mRefOrigMsgId; // PARENT_OrigMsgId REPLY_OrigMsgId
|
||||
RsGxsId mRefAuthorId; // PARENT_AuthorId REPLY_AuthorId
|
||||
rstime_t mRefPublishTs; // PARENT_PublishTs REPLY_PublishTs
|
||||
std::string mRefPulseText; // PARENT_PulseText REPLY_PulseText
|
||||
uint32_t mRefImageCount; // PARENT_#Images REPLY_#Images
|
||||
|
||||
// Open Question. Do we want these additional fields?
|
||||
// These can potentially be added at some point.
|
||||
// std::list<std::string> mMentions;
|
||||
// std::list<std::string> mHashTags;
|
||||
// std::list<std::string> mUrls;
|
||||
// RsWirePlace mPlace;
|
||||
// Additional Fields for version 2.
|
||||
// Images, need to enforce 20k limit?
|
||||
RsGxsImage mImage1;
|
||||
RsGxsImage mImage2;
|
||||
RsGxsImage mImage3;
|
||||
RsGxsImage mImage4;
|
||||
|
||||
// Below Here is not serialised.
|
||||
// They are additional fields linking pulses together or parsing elements of msg.
|
||||
|
||||
// functions.
|
||||
uint32_t ImageCount();
|
||||
|
||||
// can't have self referencial list, so need to use pointers.
|
||||
// using SharedPointers to automatically cleanup.
|
||||
|
||||
// Pointer to WireGroups
|
||||
// mRefGroupPtr is opportunistically filled in, but will often be empty.
|
||||
RsWireGroupSPtr mRefGroupPtr; // ORIG: N/A, RESP: Parent, REF: Reply Group
|
||||
RsWireGroupSPtr mGroupPtr; // ORIG: Own, RESP: Own, REF: Parent Group
|
||||
|
||||
// These are the direct children of this message
|
||||
// split into likes, replies and retweets.
|
||||
std::list<RsWirePulseSPtr> mReplies;
|
||||
std::list<RsWirePulseSPtr> mLikes;
|
||||
std::list<RsWirePulseSPtr> mRepublishes;
|
||||
|
||||
// parsed from msg.
|
||||
// do we need references..?
|
||||
std::list<std::string> mHashTags;
|
||||
std::list<std::string> mMentions;
|
||||
std::list<std::string> mUrls;
|
||||
};
|
||||
|
||||
|
||||
|
@ -158,7 +221,29 @@ virtual bool createPulse(uint32_t &token, RsWirePulse &pulse) = 0;
|
|||
// Blocking Interfaces.
|
||||
virtual bool createGroup(RsWireGroup &group) = 0;
|
||||
virtual bool updateGroup(const RsWireGroup &group) = 0;
|
||||
virtual bool getGroups(const std::list<RsGxsGroupId> grpIds, std::vector<RsWireGroup> &groups) = 0;
|
||||
virtual bool getGroups(const std::list<RsGxsGroupId> grpIds,
|
||||
std::vector<RsWireGroup> &groups) = 0;
|
||||
|
||||
// New Blocking Interfaces.
|
||||
// Plan to migrate all GUI calls to these, and remove old interfaces above.
|
||||
// These are not single requests, but return data graphs for display.
|
||||
virtual bool createOriginalPulse(const RsGxsGroupId &grpId, RsWirePulseSPtr pPulse) = 0;
|
||||
virtual bool createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId,
|
||||
RsGxsGroupId replyWith, uint32_t reply_type,
|
||||
RsWirePulseSPtr pPulse) = 0;
|
||||
|
||||
|
||||
// Provide Individual Group Details for display.
|
||||
virtual bool getWireGroup(const RsGxsGroupId &groupId, RsWireGroupSPtr &grp) = 0;
|
||||
virtual bool getWirePulse(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, RsWirePulseSPtr &pPulse) = 0;
|
||||
|
||||
// Provide list of pulses associated with groups.
|
||||
virtual bool getPulsesForGroups(const std::list<RsGxsGroupId> &groupIds,
|
||||
std::list<RsWirePulseSPtr> &pulsePtrs) = 0;
|
||||
|
||||
// Provide pulse, and associated replies / like etc.
|
||||
virtual bool getPulseFocus(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId,
|
||||
int type, RsWirePulseSPtr &pPulse) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -43,39 +43,55 @@ RsItem *RsGxsWireSerialiser::create_item(uint16_t service,uint8_t item_subtype)
|
|||
|
||||
void RsGxsWireGroupItem::clear()
|
||||
{
|
||||
group.mDescription.clear();
|
||||
group.mIcon.clear();
|
||||
group.mTagline.clear();
|
||||
group.mLocation.clear();
|
||||
group.mHeadshot.clear();
|
||||
group.mMasthead.clear();
|
||||
}
|
||||
|
||||
void RsGxsWireGroupItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DESCR,group.mDescription,"group.mDescription") ;
|
||||
group.mIcon.serial_process(j, ctx);
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DESCR,group.mTagline,"group.mTagline") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_LOCATION,group.mLocation,"group.mLocation") ;
|
||||
group.mHeadshot.serial_process(j, ctx);
|
||||
group.mMasthead.serial_process(j, ctx);
|
||||
}
|
||||
|
||||
void RsGxsWirePulseItem::clear()
|
||||
{
|
||||
pulse.mPulseText.clear();
|
||||
pulse.mPulseType = 0;
|
||||
pulse.mReplySentiment = 0;
|
||||
pulse.mSentiment = 0;
|
||||
pulse.mRefGroupId.clear();
|
||||
pulse.mRefGroupName.clear();
|
||||
pulse.mRefOrigMsgId.clear();
|
||||
pulse.mRefAuthorId.clear();
|
||||
pulse.mRefPublishTs = 0;
|
||||
pulse.mRefPulseText.clear();
|
||||
pulse.mRefImageCount = 0;
|
||||
|
||||
pulse.mImage1.clear();
|
||||
pulse.mImage2.clear();
|
||||
pulse.mImage3.clear();
|
||||
pulse.mImage4.clear();
|
||||
}
|
||||
|
||||
void RsGxsWirePulseItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_MSG,pulse.mPulseText,"pulse.mPulseText") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_UINT32_PARAM,pulse.mPulseType,"pulse.mPulseType") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_UINT32_PARAM,pulse.mReplySentiment,"pulse.mReplySentiment") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_UINT32_PARAM,pulse.mSentiment,"pulse.mSentiment") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,pulse.mRefGroupId,"pulse.mRefGroupId") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_NAME,pulse.mRefGroupName,"pulse.mRefGroupName") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,pulse.mRefOrigMsgId,"pulse.mRefOrigMsgId") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,pulse.mRefAuthorId,"pulse.mRefAuthorId") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,pulse.mRefPublishTs,"pulse.mRefPublishTs") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_MSG,pulse.mRefPulseText,"pulse.mRefPulseText") ;
|
||||
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_UINT32_PARAM,pulse.mRefImageCount,"pulse.mRefImageCount") ;
|
||||
|
||||
pulse.mImage1.serial_process(j, ctx);
|
||||
pulse.mImage2.serial_process(j, ctx);
|
||||
pulse.mImage3.serial_process(j, ctx);
|
||||
pulse.mImage4.serial_process(j, ctx);
|
||||
}
|
||||
|
||||
|
|
|
@ -1463,12 +1463,14 @@ bool p3GxsCircles::locked_processLoadingCacheEntry(RsGxsCircleCache& cache)
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_CIRCLES
|
||||
std::cerr << " (WW) cache entry for circle " << cache.mCircleId << " has empty originator. Asking info for GXS id " << pit->first << " to all connected friends." << std::endl;
|
||||
#endif
|
||||
|
||||
rsPeers->getOnlineList(peers) ;
|
||||
}
|
||||
|
||||
mIdentities->requestKey(pit->first, peers,RsIdentityUsage(serviceType(),RsIdentityUsage::CIRCLE_MEMBERSHIP_CHECK,RsGxsGroupId(cache.mCircleId)));
|
||||
mIdentities->requestKey(pit->first, peers,RsIdentityUsage(RsServiceType::GXSCIRCLE,RsIdentityUsage::CIRCLE_MEMBERSHIP_CHECK,RsGxsGroupId(cache.mCircleId)));
|
||||
|
||||
all_ids_here = false;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright (C) 2012-2014 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2018-2019 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* Copyright (C) 2018-2020 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* Copyright (C) 2019-2020 Asociación Civil Altermundi <info@altermundi.net> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -20,16 +21,20 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#include <cstdio>
|
||||
#include <memory>
|
||||
|
||||
#include "services/p3gxsforums.h"
|
||||
#include "rsitems/rsgxsforumitems.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
#include "retroshare/rsidentity.h"
|
||||
|
||||
#include "util/rsdebug.h"
|
||||
#include "rsserver/p3face.h"
|
||||
#include "retroshare/rsnotify.h"
|
||||
|
||||
#include "util/rsdebuglevel2.h"
|
||||
#include "retroshare/rsgxsflags.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
// For Dummy Msgs.
|
||||
#include "util/rsrandom.h"
|
||||
|
@ -422,46 +427,6 @@ bool p3GxsForums::getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &
|
|||
return ok;
|
||||
}
|
||||
|
||||
//Not currently used
|
||||
/*bool p3GxsForums::getRelatedMessages(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs)
|
||||
{
|
||||
GxsMsgRelatedDataMap msgData;
|
||||
bool ok = RsGenExchange::getMsgRelatedData(token, msgData);
|
||||
|
||||
if(ok)
|
||||
{
|
||||
GxsMsgRelatedDataMap::iterator mit = msgData.begin();
|
||||
|
||||
for(; mit != msgData.end(); ++mit)
|
||||
{
|
||||
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
|
||||
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
|
||||
|
||||
for(; vit != msgItems.end(); ++vit)
|
||||
{
|
||||
RsGxsForumMsgItem* item = dynamic_cast<RsGxsForumMsgItem*>(*vit);
|
||||
|
||||
if(item)
|
||||
{
|
||||
RsGxsForumMsg msg = item->mMsg;
|
||||
msg.mMeta = item->meta;
|
||||
msgs.push_back(msg);
|
||||
delete item;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Not a GxsForumMsgItem, deleting!" << std::endl;
|
||||
delete *vit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}*/
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
bool p3GxsForums::createForumV2(
|
||||
const std::string& name, const std::string& description,
|
||||
const RsGxsId& authorId, const std::set<RsGxsId>& moderatorsIds,
|
||||
|
@ -826,6 +791,51 @@ bool p3GxsForums::importForumLink(
|
|||
return true;
|
||||
}
|
||||
|
||||
std::error_condition p3GxsForums::getChildPosts(
|
||||
const RsGxsGroupId& forumId, const RsGxsMessageId& parentId,
|
||||
std::vector<RsGxsForumMsg>& childPosts )
|
||||
{
|
||||
RS_DBG3("forumId: ", forumId, " parentId: ", parentId);
|
||||
|
||||
if(forumId.isNull() || parentId.isNull())
|
||||
return std::errc::invalid_argument;
|
||||
|
||||
std::vector<RsGxsGrpMsgIdPair> msgIds;
|
||||
msgIds.push_back(RsGxsGrpMsgIdPair(forumId, parentId));
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
|
||||
opts.mOptions = RS_TOKREQOPT_MSG_PARENT | RS_TOKREQOPT_MSG_LATEST;
|
||||
|
||||
uint32_t token;
|
||||
if( !requestMsgRelatedInfo(token, opts, msgIds) ||
|
||||
waitToken(token) != RsTokenService::COMPLETE )
|
||||
return std::errc::timed_out;
|
||||
|
||||
GxsMsgRelatedDataMap msgData;
|
||||
if(!getMsgRelatedData(token, msgData))
|
||||
return std::errc::no_message_available;
|
||||
|
||||
for(auto& mit: msgData)
|
||||
{
|
||||
for(auto& vit: mit.second)
|
||||
{
|
||||
auto msgItem = dynamic_cast<RsGxsForumMsgItem*>(vit);
|
||||
if(msgItem)
|
||||
{
|
||||
RsGxsForumMsg post = msgItem->mMsg;
|
||||
post.mMeta = msgItem->meta;
|
||||
childPosts.push_back(post);
|
||||
}
|
||||
else RS_WARN("Got item of unexpected type: ", vit);
|
||||
|
||||
delete vit;
|
||||
}
|
||||
}
|
||||
|
||||
return std::error_condition();
|
||||
}
|
||||
|
||||
bool p3GxsForums::createGroup(uint32_t &token, RsGxsForumGroup &group)
|
||||
{
|
||||
std::cerr << "p3GxsForums::createGroup()" << std::endl;
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright (C) 2012-2014 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2018-2019 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* Copyright (C) 2018-2020 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* Copyright (C) 2019-2020 Asociación Civil Altermundi <info@altermundi.net> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -131,6 +132,11 @@ public:
|
|||
std::string& errMsg = RS_DEFAULT_STORAGE_PARAM(std::string)
|
||||
) override;
|
||||
|
||||
/// @see RsGxsForums
|
||||
std::error_condition getChildPosts(
|
||||
const RsGxsGroupId& forumId, const RsGxsMessageId& parentId,
|
||||
std::vector<RsGxsForumMsg>& childPosts ) override;
|
||||
|
||||
/// implementation of rsGxsGorums
|
||||
///
|
||||
bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups) override;
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
#define ID_REQUEST_REPUTATION 0x0003
|
||||
#define ID_REQUEST_OPINION 0x0004
|
||||
|
||||
#define GXSID_MAX_CACHE_SIZE 5000
|
||||
#define GXSID_MAX_CACHE_SIZE 15000
|
||||
|
||||
// unused keys are deleted according to some heuristic that should favor known keys, signed keys etc.
|
||||
|
||||
|
@ -616,11 +616,11 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
std::cerr << "p3IdService::notifyChanges() Found Group Change Notification";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
const RsGxsGroupId& gid(groupChange->mGroupId);
|
||||
#ifdef DEBUG_IDS
|
||||
std::cerr << "p3IdService::notifyChanges() Auto Subscribe to Incoming Groups: " << *git;
|
||||
std::cerr << "p3IdService::notifyChanges() Auto Subscribe to Incoming Groups: " << gid;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
const RsGxsGroupId& gid(groupChange->mGroupId);
|
||||
|
||||
if(!rsReputations->isIdentityBanned(RsGxsId(gid)))
|
||||
{
|
||||
|
@ -641,7 +641,7 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
rsEvents->postEvent(ev);
|
||||
|
||||
// also time_stamp the key that this group represents
|
||||
timeStampKey(RsGxsId(gid),RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_DATA_UPDATE)) ;
|
||||
timeStampKey(RsGxsId(gid),RsIdentityUsage(RsServiceType(serviceType()),RsIdentityUsage::IDENTITY_NEW_FROM_GXS_SYNC)) ;
|
||||
should_subscribe = true;
|
||||
}
|
||||
break;
|
||||
|
@ -654,8 +654,10 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||
rsEvents->postEvent(ev);
|
||||
|
||||
// also time_stamp the key that this group represents
|
||||
timeStampKey(RsGxsId(gid),RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_DATA_UPDATE)) ;
|
||||
timeStampKey(RsGxsId(gid),RsIdentityUsage(RsServiceType(serviceType()),RsIdentityUsage::IDENTITY_NEW_FROM_GXS_SYNC)) ;
|
||||
should_subscribe = true;
|
||||
|
||||
std::cerr << "Received new identity " << gid << " and subscribing to it" << std::endl;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1214,8 +1216,7 @@ bool p3IdService::requestIdentity(
|
|||
return false;
|
||||
}
|
||||
|
||||
RsIdentityUsage usageInfo( RsServiceType::GXSID,
|
||||
RsIdentityUsage::IDENTITY_DATA_UPDATE );
|
||||
RsIdentityUsage usageInfo( RsServiceType::GXSID, RsIdentityUsage::IDENTITY_NEW_FROM_EXPLICIT_REQUEST );
|
||||
|
||||
return requestKey(id, askPeersList, usageInfo);
|
||||
}
|
||||
|
@ -1250,8 +1251,9 @@ bool p3IdService::requestKey(const RsGxsId &id, const std::list<RsPeerId>& peers
|
|||
|
||||
if( info.mOverallReputationLevel == RsReputationLevel::LOCALLY_NEGATIVE )
|
||||
{
|
||||
RsInfo() << __PRETTY_FUNCTION__ << " not requesting Key " << id
|
||||
<< " because it has been banned." << std::endl;
|
||||
#ifdef DEBUG_IDS
|
||||
RsInfo() << __PRETTY_FUNCTION__ << " not requesting Key " << id << " because it has been banned." << std::endl;
|
||||
#endif
|
||||
|
||||
RS_STACK_MUTEX(mIdMtx);
|
||||
mIdsNotPresent.erase(id);
|
||||
|
@ -1360,7 +1362,7 @@ bool p3IdService::signData(const uint8_t *data,uint32_t data_size,const RsGxsId&
|
|||
return false ;
|
||||
}
|
||||
error_status = RS_GIXS_ERROR_NO_ERROR ;
|
||||
timeStampKey(own_gxs_id,RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_GENERIC_SIGNATURE_CREATION)) ;
|
||||
timeStampKey(own_gxs_id,RsIdentityUsage(RsServiceType(serviceType()),RsIdentityUsage::IDENTITY_GENERIC_SIGNATURE_CREATION)) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
@ -1433,7 +1435,7 @@ bool p3IdService::encryptData( const uint8_t *decrypted_data,
|
|||
return false ;
|
||||
}
|
||||
error_status = RS_GIXS_ERROR_NO_ERROR ;
|
||||
timeStampKey(encryption_key_id,RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_GENERIC_ENCRYPTION)) ;
|
||||
timeStampKey(encryption_key_id,RsIdentityUsage(RsServiceType::GXSID,RsIdentityUsage::IDENTITY_GENERIC_ENCRYPTION)) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
@ -1522,7 +1524,7 @@ bool p3IdService::encryptData( const uint8_t* decrypted_data,
|
|||
{
|
||||
timeStampKey( *it,
|
||||
RsIdentityUsage(
|
||||
serviceType(),
|
||||
RsServiceType::GXSID,
|
||||
RsIdentityUsage::IDENTITY_GENERIC_ENCRYPTION ) );
|
||||
}
|
||||
|
||||
|
@ -1563,7 +1565,7 @@ bool p3IdService::decryptData( const uint8_t *encrypted_data,
|
|||
error_status = RS_GIXS_ERROR_NO_ERROR;
|
||||
timeStampKey( key_id,
|
||||
RsIdentityUsage(
|
||||
serviceType(),
|
||||
RsServiceType::GXSID,
|
||||
RsIdentityUsage::IDENTITY_GENERIC_DECRYPTION) );
|
||||
|
||||
return true ;
|
||||
|
@ -1656,7 +1658,7 @@ bool p3IdService::decryptData( const uint8_t* encrypted_data,
|
|||
{
|
||||
timeStampKey( *it,
|
||||
RsIdentityUsage(
|
||||
serviceType(),
|
||||
RsServiceType::GXSID,
|
||||
RsIdentityUsage::IDENTITY_GENERIC_DECRYPTION ) );
|
||||
}
|
||||
|
||||
|
@ -2292,7 +2294,7 @@ bool SSGxsIdGroup::load(const std::string &input)
|
|||
char scorestr[RSGXSID_MAX_SERVICE_STRING];
|
||||
|
||||
// split into parts.
|
||||
if (3 != sscanf(input.c_str(), "v2 {P:%[^}]} {T:%[^}]} {R:%[^}]}", pgpstr, recognstr, scorestr))
|
||||
if (3 != sscanf(input.c_str(), "v2 {P:%[^}]}{T:%[^}]}{R:%[^}]}", pgpstr, recognstr, scorestr))
|
||||
{
|
||||
#ifdef DEBUG_IDS
|
||||
std::cerr << "SSGxsIdGroup::load() Failed to extract 4 Parts";
|
||||
|
@ -2954,9 +2956,21 @@ void p3IdService::requestIdsFromNet()
|
|||
for(cit = mIdsNotPresent.begin(); cit != mIdsNotPresent.end();)
|
||||
{
|
||||
#ifdef DEBUG_IDS
|
||||
Dbg2() << __PRETTY_FUNCTION__ << " Processing missing key RsGxsId: "
|
||||
<< cit->first << std::endl;
|
||||
Dbg2() << __PRETTY_FUNCTION__ << " Processing missing key RsGxsId: " << cit->first << std::endl;
|
||||
#endif
|
||||
RsGxsIdCache data;
|
||||
|
||||
if(mKeyCache.fetch(cit->first,data))
|
||||
{
|
||||
#ifdef DEBUG_IDS
|
||||
std::cerr << __PRETTY_FUNCTION__ << ". Dropping request for ID " << cit->first << " at last minute, because it was found in cache"<< std::endl;
|
||||
#endif
|
||||
auto tmp(cit);
|
||||
++tmp;
|
||||
mIdsNotPresent.erase(cit);
|
||||
cit = tmp;
|
||||
continue;
|
||||
}
|
||||
|
||||
const RsGxsId& gxsId = cit->first;
|
||||
const std::list<RsPeerId>& peers = cit->second;
|
||||
|
@ -3011,8 +3025,7 @@ void p3IdService::requestIdsFromNet()
|
|||
{
|
||||
const RsPeerId& peer = cit2->first;
|
||||
std::list<RsGxsGroupId> grpIds;
|
||||
for( std::list<RsGxsId>::const_iterator gxs_id_it = cit2->second.begin();
|
||||
gxs_id_it != cit2->second.end(); ++gxs_id_it )
|
||||
for( std::list<RsGxsId>::const_iterator gxs_id_it = cit2->second.begin(); gxs_id_it != cit2->second.end(); ++gxs_id_it )
|
||||
{
|
||||
#ifdef DEBUG_IDS
|
||||
Dbg2() << __PRETTY_FUNCTION__ << " passing RsGxsId: " << *gxs_id_it
|
||||
|
@ -3223,7 +3236,7 @@ bool p3IdService::cachetest_handlerequest(uint32_t token)
|
|||
if (!haveKey(*vit))
|
||||
{
|
||||
std::list<RsPeerId> nullpeers;
|
||||
requestKey(*vit, nullpeers,RsIdentityUsage(serviceType(),RsIdentityUsage::UNKNOWN_USAGE));
|
||||
requestKey(*vit, nullpeers,RsIdentityUsage(RsServiceType::GXSID,RsIdentityUsage::UNKNOWN_USAGE));
|
||||
|
||||
#ifdef DEBUG_IDS
|
||||
std::cerr << "p3IdService::cachetest_request() Requested Key Id: " << *vit;
|
||||
|
@ -4819,11 +4832,10 @@ void RsGxsIdGroup::serial_process(
|
|||
RS_SERIAL_PROCESS(mReputation);
|
||||
}
|
||||
|
||||
RsIdentityUsage::RsIdentityUsage(
|
||||
RsServiceType service, RsIdentityUsage::UsageCode code,
|
||||
const RsGxsGroupId& gid, const RsGxsMessageId& mid,
|
||||
RsIdentityUsage::RsIdentityUsage(RsServiceType service, RsIdentityUsage::UsageCode code,
|
||||
const RsGxsGroupId& gid, const RsGxsMessageId& mid, const RsGxsMessageId &pid, const RsGxsMessageId &tid,
|
||||
uint64_t additional_id, const std::string& comment ) :
|
||||
mServiceId(service), mUsageCode(code), mGrpId(gid), mMsgId(mid),
|
||||
mServiceId(service), mUsageCode(code), mGrpId(gid), mMsgId(mid),mParentId(pid),mThreadId(tid),
|
||||
mAdditionalId(additional_id), mComment(comment)
|
||||
{
|
||||
/* This is a hack, since it will hash also mHash, but because it is
|
||||
|
@ -4841,42 +4853,6 @@ RsIdentityUsage::RsIdentityUsage(
|
|||
mHash = hs.hash();
|
||||
}
|
||||
|
||||
RsIdentityUsage::RsIdentityUsage(
|
||||
uint16_t service, const RsIdentityUsage::UsageCode& code,
|
||||
const RsGxsGroupId& gid, const RsGxsMessageId& mid,
|
||||
uint64_t additional_id,const std::string& comment ) :
|
||||
mServiceId(static_cast<RsServiceType>(service)), mUsageCode(code),
|
||||
mGrpId(gid), mMsgId(mid), mAdditionalId(additional_id), mComment(comment)
|
||||
{
|
||||
#ifdef DEBUG_IDS
|
||||
std::cerr << "New identity usage: " << std::endl;
|
||||
std::cerr << " service=" << std::hex << service << std::endl;
|
||||
std::cerr << " code =" << std::hex << code << std::endl;
|
||||
std::cerr << " grpId =" << std::hex << gid << std::endl;
|
||||
std::cerr << " msgId =" << std::hex << mid << std::endl;
|
||||
std::cerr << " add id =" << std::hex << additional_id << std::endl;
|
||||
std::cerr << " commnt =\"" << std::hex << comment << "\"" << std::endl;
|
||||
#endif
|
||||
|
||||
/* This is a hack, since it will hash also mHash, but because it is
|
||||
* initialized to 0, and only computed in the constructor here, it should
|
||||
* be ok. */
|
||||
librs::crypto::HashStream hs(librs::crypto::HashStream::SHA1) ;
|
||||
|
||||
hs << (uint32_t)service ; // G10h4ck: Why uint32 if it's 16 bits?
|
||||
hs << (uint8_t)code ;
|
||||
hs << gid ;
|
||||
hs << mid ;
|
||||
hs << (uint64_t)additional_id ;
|
||||
hs << comment ;
|
||||
|
||||
mHash = hs.hash();
|
||||
|
||||
#ifdef DEBUG_IDS
|
||||
std::cerr << " hash =\"" << std::hex << mHash << "\"" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
RsIdentityUsage::RsIdentityUsage() :
|
||||
mServiceId(RsServiceType::NONE), mUsageCode(UNKNOWN_USAGE), mAdditionalId(0)
|
||||
{}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -61,7 +61,55 @@ public:
|
|||
virtual bool updateGroup(const RsWireGroup &group) override;
|
||||
virtual bool getGroups(const std::list<RsGxsGroupId> grpIds, std::vector<RsWireGroup> &groups) override;
|
||||
|
||||
// New Interfaces.
|
||||
// Blocking, request structures for display.
|
||||
virtual bool createOriginalPulse(const RsGxsGroupId &grpId, RsWirePulseSPtr pPulse) override;
|
||||
virtual bool createReplyPulse(RsGxsGroupId grpId, RsGxsMessageId msgId,
|
||||
RsGxsGroupId replyWith, uint32_t reply_type,
|
||||
RsWirePulseSPtr pPulse) override;
|
||||
|
||||
#if 0
|
||||
virtual bool createReplyPulse(uint32_t &token, RsWirePulse &pulse) override;
|
||||
virtual bool createRepublishPulse(uint32_t &token, RsWirePulse &pulse) override;
|
||||
virtual bool createLikePulse(uint32_t &token, RsWirePulse &pulse) override;
|
||||
#endif
|
||||
|
||||
virtual bool getWireGroup(const RsGxsGroupId &groupId, RsWireGroupSPtr &grp) override;
|
||||
virtual bool getWirePulse(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, RsWirePulseSPtr &pPulse) override;
|
||||
|
||||
virtual bool getPulsesForGroups(const std::list<RsGxsGroupId> &groupIds, std::list<RsWirePulseSPtr> &pulsePtrs) override;
|
||||
|
||||
virtual bool getPulseFocus(const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, int type, RsWirePulseSPtr &pPulse) override;
|
||||
|
||||
private:
|
||||
// Internal Service Data.
|
||||
// They should eventually all be here.
|
||||
bool getRelatedPulseData(const uint32_t &token, std::vector<RsWirePulse> &pulses);
|
||||
bool getGroupPtrData(const uint32_t &token,
|
||||
std::map<RsGxsGroupId, RsWireGroupSPtr> &groups);
|
||||
bool getPulsePtrData(const uint32_t &token, std::list<RsWirePulseSPtr> &pulses);
|
||||
|
||||
// util functions fetching data.
|
||||
bool fetchPulse(RsGxsGroupId grpId, RsGxsMessageId msgId, RsWirePulseSPtr &pPulse);
|
||||
bool updatePulse(RsWirePulseSPtr pPulse, int levels);
|
||||
bool updatePulseChildren(RsWirePulseSPtr pParent, uint32_t token);
|
||||
|
||||
// update GroupPtrs
|
||||
bool updateGroups(std::list<RsWirePulseSPtr> &pulsePtrs);
|
||||
|
||||
// sub utility functions used by updateGroups.
|
||||
bool extractGroupIds(RsWirePulseConstSPtr pPulse, std::set<RsGxsGroupId> &groupIds);
|
||||
|
||||
bool updateGroupPtrs(RsWirePulseSPtr pPulse,
|
||||
const std::map<RsGxsGroupId, RsWireGroupSPtr> &groups);
|
||||
|
||||
bool trimToAvailGroupIds(const std::set<RsGxsGroupId> &pulseGroupIds,
|
||||
std::list<RsGxsGroupId> &availGroupIds);
|
||||
|
||||
bool fetchGroupPtrs(const std::list<RsGxsGroupId> &groupIds,
|
||||
std::map<RsGxsGroupId, RsWireGroupSPtr> &groups);
|
||||
|
||||
|
||||
virtual void generateDummyData();
|
||||
std::string genRandomId();
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ rs_jsonapi {
|
|||
LIBS *= -L$$clean_path($${RESTBED_BUILD_PATH}/) -lrestbed
|
||||
} else:sLibs *= restbed
|
||||
|
||||
win32-g++:dLibs *= wsock32
|
||||
win32-g++|win32-clang-g++:dLibs *= wsock32
|
||||
}
|
||||
|
||||
linux-* {
|
||||
|
@ -55,7 +55,7 @@ linux-* {
|
|||
|
||||
rs_deep_channels_index | rs_deep_files_index {
|
||||
mLibs += xapian
|
||||
win32-g++:mLibs += rpcrt4
|
||||
win32-g++|win32-clang-g++:mLibs += rpcrt4
|
||||
}
|
||||
|
||||
rs_deep_files_index_ogg {
|
||||
|
@ -81,7 +81,7 @@ rs_broadcast_discovery {
|
|||
LIBS *= -L$$clean_path($${UDP_DISCOVERY_BUILD_PATH}) -ludp-discovery
|
||||
} else:sLibs *= udp-discovery
|
||||
|
||||
win32-g++:dLibs *= wsock32
|
||||
win32-g++|win32-clang-g++:dLibs *= wsock32
|
||||
}
|
||||
|
||||
static {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*******************************************************************************
|
||||
* *
|
||||
* libretroshare base64 encoding utilities *
|
||||
* libretroshare endiannes utilities *
|
||||
* *
|
||||
* Copyright (C) 2020 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* Copyright (C) 2020 Asociación Civil Altermundi <info@altermundi.net> *
|
||||
|
@ -26,7 +26,7 @@
|
|||
* This file provide convenient integer endiannes conversion utilities.
|
||||
* Instead of providing them with different names for each type (a la C htonl,
|
||||
* htons, ntohl, ntohs ), which make them uncomfortable to use, expose a
|
||||
* templated function `rs_endian_fix` to reorder integers representation byets
|
||||
* templated function `rs_endian_fix` to reorder integers bytes representation
|
||||
* when sending or receiving from the network. */
|
||||
|
||||
/* enforce LITTLE_ENDIAN on Windows */
|
||||
|
@ -46,7 +46,7 @@ template<typename INTTYPE> inline INTTYPE rs_endian_fix(INTTYPE val)
|
|||
swapped |= (val >> (8*(sizeof(INTTYPE)-i-1)) & 0xFF) << (8*i);
|
||||
return swapped;
|
||||
#else
|
||||
return hostI;
|
||||
return val;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue