mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-26 09:41:29 -05:00
added circle invite notifications
This commit is contained in:
parent
f5af7dfeb3
commit
767440afc5
@ -183,7 +183,7 @@ enum class RsGxsCircleEventCode: uint8_t
|
|||||||
CIRCLE_MEMBERSHIP_JOIN = 0x04,
|
CIRCLE_MEMBERSHIP_JOIN = 0x04,
|
||||||
|
|
||||||
/** mCircleId contains the circle id and mGxsId is the id that was revoqued * by admin */
|
/** mCircleId contains the circle id and mGxsId is the id that was revoqued * by admin */
|
||||||
CIRCLE_MEMBERSHIP_REVOQUED= 0x05,
|
CIRCLE_MEMBERSHIP_REVOKED = 0x05,
|
||||||
|
|
||||||
/** mCircleId contains the circle id */
|
/** mCircleId contains the circle id */
|
||||||
NEW_CIRCLE = 0x06,
|
NEW_CIRCLE = 0x06,
|
||||||
|
@ -119,7 +119,7 @@ const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_REQ = RS_FEED_TYPE_CIRCLE | 0x0001
|
|||||||
const uint32_t RS_FEED_ITEM_CIRCLE_INVIT_REC = RS_FEED_TYPE_CIRCLE | 0x0002;
|
const uint32_t RS_FEED_ITEM_CIRCLE_INVIT_REC = RS_FEED_TYPE_CIRCLE | 0x0002;
|
||||||
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_LEAVE = RS_FEED_TYPE_CIRCLE | 0x0003;
|
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_LEAVE = RS_FEED_TYPE_CIRCLE | 0x0003;
|
||||||
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_JOIN = RS_FEED_TYPE_CIRCLE | 0x0004;
|
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_JOIN = RS_FEED_TYPE_CIRCLE | 0x0004;
|
||||||
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_REVOQUED = RS_FEED_TYPE_CIRCLE | 0x0005;
|
const uint32_t RS_FEED_ITEM_CIRCLE_MEMB_REVOKED = RS_FEED_TYPE_CIRCLE | 0x0005;
|
||||||
|
|
||||||
const uint32_t RS_MESSAGE_CONNECT_ATTEMPT = 0x0001;
|
const uint32_t RS_MESSAGE_CONNECT_ATTEMPT = 0x0001;
|
||||||
|
|
||||||
|
@ -679,6 +679,64 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RsGxsGroupUpdate *grpUpdate = dynamic_cast<RsGxsGroupUpdate*>(*it);
|
||||||
|
|
||||||
|
if (grpUpdate && rsEvents)
|
||||||
|
{
|
||||||
|
// Happens when the group data has changed. In this case we need to analyse the old and new group in order to detect possible notifications for clients
|
||||||
|
|
||||||
|
RsGxsCircleGroupItem *old_circle_grp_item = dynamic_cast<RsGxsCircleGroupItem*>(grpUpdate->mOldGroupItem);
|
||||||
|
RsGxsCircleGroupItem *new_circle_grp_item = dynamic_cast<RsGxsCircleGroupItem*>(grpUpdate->mNewGroupItem);
|
||||||
|
|
||||||
|
const RsGxsCircleId circle_id ( old_circle_grp_item->meta.mGroupId );
|
||||||
|
|
||||||
|
if(old_circle_grp_item == nullptr || new_circle_grp_item == nullptr)
|
||||||
|
{
|
||||||
|
RsErr() << __PRETTY_FUNCTION__ << " received GxsGroupUpdate item with mOldGroup and mNewGroup not of type RsGxsCircleGroupItem. This is inconsistent!" << std::endl;
|
||||||
|
delete grpUpdate;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// First of all, we check if there is a difference between the old and new list of invited members
|
||||||
|
|
||||||
|
std::list<RsGxsId> added_identities, removed_identities;
|
||||||
|
std::list<RsGxsId> own_ids_lst;
|
||||||
|
rsIdentity->getOwnIds(own_ids_lst,false); // retrieve own identities
|
||||||
|
|
||||||
|
std::set<RsGxsId> own_ids;
|
||||||
|
for(auto& id:own_ids_lst)
|
||||||
|
own_ids.insert(id); // put them in a std::set for O(log(n)) search
|
||||||
|
|
||||||
|
for(auto& gxs_id: new_circle_grp_item->gxsIdSet.ids)
|
||||||
|
if(old_circle_grp_item->gxsIdSet.ids.find(gxs_id) == old_circle_grp_item->gxsIdSet.ids.end() && own_ids.find(gxs_id)!=own_ids.end())
|
||||||
|
added_identities.push_back(gxs_id);
|
||||||
|
|
||||||
|
for(auto& gxs_id: old_circle_grp_item->gxsIdSet.ids)
|
||||||
|
if(new_circle_grp_item->gxsIdSet.ids.find(gxs_id) == old_circle_grp_item->gxsIdSet.ids.end() && own_ids.find(gxs_id)!=own_ids.end())
|
||||||
|
removed_identities.push_back(gxs_id);
|
||||||
|
|
||||||
|
for(auto& gxs_id:added_identities)
|
||||||
|
{
|
||||||
|
auto ev = std::make_shared<RsGxsCircleEvent>();
|
||||||
|
|
||||||
|
ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_INVITE;
|
||||||
|
ev->mCircleId = circle_id;
|
||||||
|
ev->mGxsId = gxs_id;
|
||||||
|
|
||||||
|
rsEvents->sendEvent(ev);
|
||||||
|
}
|
||||||
|
for(auto& gxs_id:removed_identities)
|
||||||
|
{
|
||||||
|
auto ev = std::make_shared<RsGxsCircleEvent>();
|
||||||
|
|
||||||
|
ev->mCircleEventType = RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REVOKED;
|
||||||
|
ev->mCircleId = circle_id;
|
||||||
|
ev->mGxsId = gxs_id;
|
||||||
|
|
||||||
|
rsEvents->sendEvent(ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
delete *it;
|
delete *it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -438,7 +438,7 @@ void IdDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
|||||||
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_INVITE:
|
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_INVITE:
|
||||||
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_LEAVE:
|
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_LEAVE:
|
||||||
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_JOIN:
|
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_JOIN:
|
||||||
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REVOQUED:
|
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REVOKED:
|
||||||
case RsGxsCircleEventCode::CACHE_DATA_UPDATED:
|
case RsGxsCircleEventCode::CACHE_DATA_UPDATED:
|
||||||
|
|
||||||
updateCircles();
|
updateCircles();
|
||||||
|
@ -329,8 +329,8 @@ void NewsFeed::handleCircleEvent(std::shared_ptr<const RsEvent> event)
|
|||||||
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_INVITE:
|
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_INVITE:
|
||||||
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_INVIT_REC),true);
|
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_INVIT_REC),true);
|
||||||
break;
|
break;
|
||||||
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REVOQUED:
|
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REVOKED:
|
||||||
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_REVOQUED),true);
|
addFeedItemIfUnique(new GxsCircleItem(this, NEWSFEED_CIRCLELIST, pe->mCircleId, pe->mGxsId, RS_FEED_ITEM_CIRCLE_MEMB_REVOKED),true);
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ void GxsCircleItem::setup()
|
|||||||
ui->acceptButton->setHidden(true);
|
ui->acceptButton->setHidden(true);
|
||||||
ui->revokeButton->setHidden(true);
|
ui->revokeButton->setHidden(true);
|
||||||
}
|
}
|
||||||
else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_REVOQUED)
|
else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_REVOKED)
|
||||||
{
|
{
|
||||||
if(rsIdentity->isOwnId(mGxsId))
|
if(rsIdentity->isOwnId(mGxsId))
|
||||||
ui->titleLabel->setText(tr("Your identity %1 has been revoqued from this circle.").arg(idName));
|
ui->titleLabel->setText(tr("Your identity %1 has been revoqued from this circle.").arg(idName));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user