mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-03 03:36:58 -04:00
Added update capability to forums ui
Added timestamp check for group update in nxs decided to add control variable to allow meta changes in updates rather than none git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs_finale@6803 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
2a841d7ab3
commit
9470e5562a
12 changed files with 208 additions and 22 deletions
|
@ -1370,11 +1370,11 @@ void RsGenExchange::publishGroup(uint32_t& token, RsGxsGrpItem *grpItem)
|
|||
}
|
||||
|
||||
|
||||
void RsGenExchange::updateGroup(uint32_t& token, RsGxsGrpItem* grpItem)
|
||||
void RsGenExchange::updateGroup(uint32_t& token, RsGxsGroupUpdateMeta& updateMeta, RsGxsGrpItem* grpItem)
|
||||
{
|
||||
RsStackMutex stack(mGenMtx);
|
||||
token = mDataAccess->generatePublicToken();
|
||||
mGroupUpdatePublish.push_back(GroupUpdatePublish(grpItem, token));
|
||||
mGroupUpdatePublish.push_back(GroupUpdatePublish(grpItem, updateMeta, token));
|
||||
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << "RsGenExchange::updateGroup() token: " << token;
|
||||
|
@ -1828,7 +1828,9 @@ void RsGenExchange::processGroupUpdatePublish()
|
|||
const RsGxsGroupId& groupId = gup.grpItem->meta.mGroupId;
|
||||
RsGxsGrpMetaData* meta = grpMeta[groupId];
|
||||
|
||||
GxsGrpPendingSign ggps(ggps.mItem, ggps.mToken);
|
||||
gup.grpItem->meta = *meta;
|
||||
assignMetaUpdates(gup.grpItem->meta, gup.mUpdateMeta);
|
||||
GxsGrpPendingSign ggps(gup.grpItem, ggps.mToken);
|
||||
|
||||
bool split = splitKeys(meta->keys, ggps.mPrivateKeys, ggps.mPublicKeys);
|
||||
|
||||
|
@ -1849,6 +1851,27 @@ void RsGenExchange::processGroupUpdatePublish()
|
|||
mGroupUpdatePublish.clear();
|
||||
}
|
||||
|
||||
void RsGenExchange::assignMetaUpdates(RsGroupMetaData& meta, const RsGxsGroupUpdateMeta metaUpdate) const
|
||||
{
|
||||
const RsGxsGroupUpdateMeta::GxsMetaUpdate* updates;
|
||||
RsGxsGroupUpdateMeta::GxsMetaUpdate::const_iterator mit = updates->begin();
|
||||
for(; mit != updates->end(); mit++)
|
||||
{
|
||||
const UpdateItem* item = mit->second;
|
||||
RsGxsGroupUpdateMeta::UpdateType utype = mit->first;
|
||||
|
||||
if(utype == RsGxsGroupUpdateMeta::NAME)
|
||||
{
|
||||
const StringUpdateItem* sitem = NULL;
|
||||
|
||||
if((sitem = dynamic_cast<const StringUpdateItem*>(item)) != NULL)
|
||||
{
|
||||
meta.mGroupName = sitem->getUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool RsGenExchange::splitKeys(const RsTlvSecurityKeySet& keySet, RsTlvSecurityKeySet& privateKeySet, RsTlvSecurityKeySet& publicKeySet)
|
||||
{
|
||||
|
||||
|
|
|
@ -527,12 +527,12 @@ protected:
|
|||
|
||||
/*!
|
||||
* Updates an existing group item \n
|
||||
* This will induce a related change message \n
|
||||
* Ownership of item passes to this rsgenexchange \n
|
||||
* @param token
|
||||
* @param grpItem
|
||||
*/
|
||||
void updateGroup(uint32_t& token, RsGxsGrpItem* grpItem);
|
||||
* This will induce a related change message \n
|
||||
* Ownership of item passes to this rsgenexchange \n
|
||||
* @param token
|
||||
* @param grpItem
|
||||
*/
|
||||
void updateGroup(uint32_t& token, RsGxsGroupUpdateMeta& updateMeta, RsGxsGrpItem* grpItem);
|
||||
|
||||
public:
|
||||
/*!
|
||||
|
@ -762,7 +762,20 @@ private:
|
|||
*/
|
||||
bool updateValid(RsGxsGrpMetaData& oldGrp, RsNxsGrp& newGrp) const;
|
||||
|
||||
bool splitKeys(const RsTlvSecurityKeySet& keySet, RsTlvSecurityKeySet& privateKeySet, RsTlvSecurityKeySet& publicKeySet);
|
||||
/*!
|
||||
* convenience function for splitting key sets into private and public
|
||||
* @param keySet The keys set to split into a private and public set
|
||||
* @param privateKeySet contains the publish and admin private keys
|
||||
* @param publicKeySet contains the publish and admin public keys
|
||||
* @return false, if 2 private and public keys are not found in keySet
|
||||
*/
|
||||
bool splitKeys(const RsTlvSecurityKeySet& keySet, RsTlvSecurityKeySet& privateKeySet,
|
||||
RsTlvSecurityKeySet& publicKeySet);
|
||||
|
||||
/*!
|
||||
* Convenience function for assigning the meta update items to the actual group meta
|
||||
*/
|
||||
void assignMetaUpdates(RsGroupMetaData& meta, const RsGxsGroupUpdateMeta metaUpdate) const;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -1366,6 +1366,7 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
|||
}
|
||||
|
||||
std::map<std::string, RsGxsGrpMetaData*> grpMetaMap;
|
||||
std::map<std::string, RsGxsGrpMetaData*>::const_iterator metaIter;
|
||||
mDataStore->retrieveGxsGrpMetaData(grpMetaMap);
|
||||
|
||||
// now do compare and add loop
|
||||
|
@ -1380,8 +1381,14 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
|||
{
|
||||
RsNxsSyncGrpItem*& grpSyncItem = *llit;
|
||||
const std::string& grpId = grpSyncItem->grpId;
|
||||
metaIter = grpMetaMap.find(grpId);
|
||||
bool haveItem = metaIter != grpMetaMap.end();
|
||||
bool latestItem = false;
|
||||
|
||||
if(grpMetaMap.find(grpId) == grpMetaMap.end()){
|
||||
if(!haveItem)
|
||||
latestItem = grpSyncItem->publishTs > metaIter->second->mPublishTs;
|
||||
|
||||
if(haveItem && latestItem){
|
||||
|
||||
// determine if you need to check reputation
|
||||
bool checkRep = !grpSyncItem->authorId.empty();
|
||||
|
|
|
@ -139,4 +139,14 @@ public:
|
|||
bool validUpdate;
|
||||
};
|
||||
|
||||
class GroupUpdatePublish
|
||||
{
|
||||
public:
|
||||
GroupUpdatePublish(RsGxsGrpItem* item, RsGxsGroupUpdateMeta updateMeta, uint32_t token)
|
||||
: grpItem(item), mToken(token), mUpdateMeta(updateMeta) {}
|
||||
RsGxsGrpItem* grpItem;
|
||||
RsGxsGroupUpdateMeta mUpdateMeta;
|
||||
uint32_t mToken;
|
||||
};
|
||||
|
||||
#endif /* GXSUTIL_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue