mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-23 05:05:30 -04:00
finished implementing the backend part for the subscription system
This commit is contained in:
parent
89472d6502
commit
722609a3e6
10 changed files with 344 additions and 414 deletions
|
@ -213,9 +213,11 @@ class RsGcxs
|
|||
|
||||
virtual int canSend(const RsGxsCircleId &circleId, const RsPgpId &id,bool& should_encrypt) = 0;
|
||||
virtual int canReceive(const RsGxsCircleId &circleId, const RsPgpId &id) = 0;
|
||||
|
||||
virtual bool recipients(const RsGxsCircleId &circleId, std::list<RsPgpId>& friendlist) = 0;
|
||||
virtual bool recipients(const RsGxsCircleId &circleId, std::list<RsGxsId>& idlist) = 0;
|
||||
virtual bool isRecipient(const RsGxsCircleId &circleId, const RsGxsId& id) = 0;
|
||||
virtual bool recipients(const RsGxsCircleId &circleId, const RsGxsGroupId& destination_group, std::list<RsGxsId>& idlist) = 0;
|
||||
|
||||
virtual bool isRecipient(const RsGxsCircleId &circleId, const RsGxsGroupId& destination_group, const RsGxsId& id) = 0;
|
||||
|
||||
virtual bool getLocalCircleServerUpdateTS(const RsGxsCircleId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) =0;
|
||||
};
|
||||
|
|
|
@ -761,8 +761,7 @@ void RsGxsNetService::syncWithPeers()
|
|||
RsNxsItem *encrypted_item = NULL ;
|
||||
uint32_t status ;
|
||||
|
||||
#warning pass on the group id here so as to know which list to encrypt to (admin/members)
|
||||
if(encryptSingleNxsItem(msg, encrypt_to_this_circle_id, encrypted_item, status))
|
||||
if(encryptSingleNxsItem(msg, encrypt_to_this_circle_id, grpId, encrypted_item, status))
|
||||
sendItem(encrypted_item) ;
|
||||
else
|
||||
std::cerr << "(WW) could not encrypt for circle ID " << encrypt_to_this_circle_id << ". Not yet in cache?" << std::endl;
|
||||
|
@ -1271,8 +1270,7 @@ bool RsGxsNetService::locked_createTransactionFromPending(GrpCircleIdRequestVett
|
|||
RsNxsItem *encrypted_item = NULL ;
|
||||
uint32_t status = RS_NXS_ITEM_ENCRYPTION_STATUS_UNKNOWN ;
|
||||
|
||||
#warning pass on the group id here so as to know which list to encrypt to (admin/members)
|
||||
if(encryptSingleNxsItem(gItem, entry.mCircleId, encrypted_item,status))
|
||||
if(encryptSingleNxsItem(gItem, entry.mCircleId, entry.mGroupId,encrypted_item,status))
|
||||
{
|
||||
itemL.push_back(encrypted_item) ;
|
||||
delete gItem ;
|
||||
|
@ -1323,8 +1321,7 @@ bool RsGxsNetService::locked_createTransactionFromPending(MsgCircleIdsRequestVet
|
|||
RsNxsItem *encrypted_item = NULL ;
|
||||
uint32_t status = RS_NXS_ITEM_ENCRYPTION_STATUS_UNKNOWN ;
|
||||
|
||||
#warning pass on the group id here so as to know which list to encrypt to (admin/members)
|
||||
if(encryptSingleNxsItem(mItem,msgPend->mCircleId,encrypted_item,status))
|
||||
if(encryptSingleNxsItem(mItem,msgPend->mCircleId,msgPend->mGrpId,encrypted_item,status))
|
||||
{
|
||||
itemL.push_back(encrypted_item) ;
|
||||
delete mItem ;
|
||||
|
@ -3668,7 +3665,7 @@ bool RsGxsNetService::locked_addTransaction(NxsTransaction* tr)
|
|||
// Returns false when the keys are not loaded. Question to solve: what do we do if we miss some keys??
|
||||
// We should probably send anyway.
|
||||
|
||||
bool RsGxsNetService::encryptSingleNxsItem(RsNxsItem *item, const RsGxsCircleId& destination_circle, RsNxsItem *&encrypted_item, uint32_t& status)
|
||||
bool RsGxsNetService::encryptSingleNxsItem(RsNxsItem *item, const RsGxsCircleId& destination_circle, const RsGxsGroupId& destination_group, RsNxsItem *&encrypted_item, uint32_t& status)
|
||||
{
|
||||
encrypted_item = NULL ;
|
||||
status = RS_NXS_ITEM_ENCRYPTION_STATUS_UNKNOWN ;
|
||||
|
@ -3681,8 +3678,7 @@ bool RsGxsNetService::encryptSingleNxsItem(RsNxsItem *item, const RsGxsCircleId&
|
|||
|
||||
std::list<RsGxsId> recipients ;
|
||||
|
||||
#warning recipients should take the destination group ID as parameter and use it to know if is will use the admin list or the members list.
|
||||
if(!mCircles->recipients(destination_circle,recipients))
|
||||
if(!mCircles->recipients(destination_circle,destination_group,recipients))
|
||||
{
|
||||
std::cerr << " (EE) Cannot encrypt transaction: recipients list not available. Should re-try later." << std::endl;
|
||||
status = RS_NXS_ITEM_ENCRYPTION_STATUS_CIRCLE_ERROR ;
|
||||
|
@ -4051,8 +4047,8 @@ void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrpReqItem *item)
|
|||
#endif
|
||||
RsNxsItem *encrypted_item = NULL ;
|
||||
uint32_t status = RS_NXS_ITEM_ENCRYPTION_STATUS_UNKNOWN ;
|
||||
#warning pass on the group id here so as to know which list to encrypt to (admin/members)
|
||||
if(encryptSingleNxsItem(gItem, grpMeta->mCircleId, encrypted_item,status))
|
||||
|
||||
if(encryptSingleNxsItem(gItem, grpMeta->mCircleId,mit->first, encrypted_item,status))
|
||||
{
|
||||
itemL.push_back(encrypted_item) ;
|
||||
delete gItem ;
|
||||
|
@ -4475,8 +4471,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item,bool item_
|
|||
RsNxsItem *encrypted_item = NULL ;
|
||||
uint32_t status = RS_NXS_ITEM_ENCRYPTION_STATUS_UNKNOWN ;
|
||||
|
||||
#warning pass on the group id here so as to know which list to encrypt to (admin/members)
|
||||
if(encryptSingleNxsItem(mItem, grpMeta->mCircleId, encrypted_item,status))
|
||||
if(encryptSingleNxsItem(mItem, grpMeta->mCircleId,m->mGroupId, encrypted_item,status))
|
||||
{
|
||||
itemL.push_back(encrypted_item) ;
|
||||
delete mItem ;
|
||||
|
@ -4624,7 +4619,7 @@ bool RsGxsNetService::canSendMsgIds(std::vector<RsGxsMsgMetaData*>& msgMetas, co
|
|||
++i ;
|
||||
else
|
||||
{
|
||||
if(mCircles->isLoaded(circleId) && mCircles->isRecipient(circleId, msgMetas[i]->mAuthorId))
|
||||
if(mCircles->isLoaded(circleId) && mCircles->isRecipient(circleId, grpMeta.mGroupId, msgMetas[i]->mAuthorId))
|
||||
{
|
||||
++i ;
|
||||
continue ;
|
||||
|
|
|
@ -454,7 +454,7 @@ private:
|
|||
/*!
|
||||
* encrypts/decrypts the transaction for the destination circle id.
|
||||
*/
|
||||
bool encryptSingleNxsItem(RsNxsItem *item, const RsGxsCircleId& destination_circle, RsNxsItem *& encrypted_item, uint32_t &status) ;
|
||||
bool encryptSingleNxsItem(RsNxsItem *item, const RsGxsCircleId& destination_circle, const RsGxsGroupId &destination_group, RsNxsItem *& encrypted_item, uint32_t &status) ;
|
||||
bool decryptSingleNxsItem(const RsNxsEncryptedDataItem *encrypted_item, RsNxsItem *&nxsitem, std::vector<RsTlvSecurityKey> *private_keys=NULL);
|
||||
bool processTransactionForDecryption(NxsTransaction *tr); // return false when the keys are not loaded => need retry later
|
||||
|
||||
|
|
|
@ -291,7 +291,7 @@ bool MsgCircleIdsRequestVetting::cleared()
|
|||
}
|
||||
|
||||
for(uint32_t i=0;i<mMsgs.size();)
|
||||
if(!mCircles->isRecipient(mCircleId,mMsgs[i].mAuthorId))
|
||||
if(!mCircles->isRecipient(mCircleId,mGrpId,mMsgs[i].mAuthorId))
|
||||
{
|
||||
std::cerr << "(WW) MsgCircleIdsRequestVetting::cleared() filtering out message " << mMsgs[i].mMsgId << " because it's signed by author " << mMsgs[i].mAuthorId << " which is not in circle " << mCircleId << std::endl;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue