Merge pull request #2261 from csoler/v0.6-BugFixing_6

Better display of last seen info in groups
This commit is contained in:
csoler 2021-01-30 20:14:44 +01:00 committed by GitHub
commit 42dd13b0e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 80 additions and 5 deletions

View File

@ -1379,7 +1379,16 @@ bool RsGenExchange::getGroupMeta(const uint32_t &token, std::list<RsGroupMetaDat
{
m.mPop= 0 ;
m.mVisibleMsgCount = 0 ;
}
}
// We could save this in the net service, but it's a bit more than that since some services have
// specific usage footprints for their groups.
m.mLastSeen = (IS_GROUP_SUBSCRIBED(gMeta.mSubscribeFlags)) ? time(nullptr) : service_getLastGroupSeenTs(gMeta.mGroupId);
#ifdef GEN_EXCH_DEBUG
std::cerr << "Group: " << gMeta.mGroupId << " name \"" << gMeta.mGroupName << "\" last seen=" << m.mLastSeen << " now=" << time(nullptr) << std::endl;
#endif
groupInfo.push_back(m);
}
@ -1556,6 +1565,7 @@ bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem
if((!(IS_GROUP_SUBSCRIBED(gItem->meta.mSubscribeFlags))) || gItem->meta.mLastPost == 0)
gItem->meta.mLastPost = sts.mLastGroupModificationTS ;
}
else
{
@ -1563,6 +1573,14 @@ bool RsGenExchange::getGroupData(const uint32_t &token, std::vector<RsGxsGrpItem
gItem->meta.mVisibleMsgCount = 0;
}
// We could save this in the net service, but it's a bit more than that since some services have
// specific usage footprints for their groups.
gItem->meta.mLastSeen = (IS_GROUP_SUBSCRIBED(gItem->meta.mSubscribeFlags)) ? time(nullptr) : service_getLastGroupSeenTs(gItem->meta.mGroupId);
#ifdef GEN_EXCH_DEBUG
std::cerr << "Group: " << gItem->meta.mGroupId << " name \"" << gItem->meta.mGroupName << "\" last seen=" << gItem->meta.mLastSeen << " now=" << time(nullptr) << std::endl;
#endif
// Also check the group privacy flags. A while ago, it as possible to publish a group without privacy flags. Now it is not possible anymore.
// As a consequence, it's important to supply a correct value in this flag before the data can be edited/updated.

View File

@ -667,6 +667,14 @@ protected:
*/
virtual bool service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& /* meta */) { return true; } // see RsGenExchange
/*!
* \brief service_getLastGroupSeenTs
* \return
* returns the last time a friend sent information (statistics) about this group. That practically means when the
* group was still being subscribed by at least one friend. This is used by service_checkIfGroupIsStillUsed() to
* help getting rid of dead groups.
*/
virtual rstime_t service_getLastGroupSeenTs(const RsGxsGroupId&) { return 0; }
public:
/*!

View File

@ -88,9 +88,10 @@ struct RsGroupMetaData : RsSerializable
uint32_t mSubscribeFlags;
uint32_t mPop; // Popularity = number of friend subscribers
uint32_t mVisibleMsgCount; // Max messages reported by friends
rstime_t mLastPost; // Timestamp for last message. Not used yet.
uint32_t mPop; // Popularity = number of friend subscribers
uint32_t mVisibleMsgCount; // Max messages reported by friends
rstime_t mLastPost; // Timestamp for last message. Not used yet.
rstime_t mLastSeen; // Last time the group was advertised by friends.
uint32_t mGroupStatus;

View File

@ -1700,6 +1700,24 @@ bool p3GxsCircles::locked_checkCircleCacheForAutoSubscribe(RsGxsCircleCache& cac
return true;
}
rstime_t p3GxsCircles::service_getLastGroupSeenTs(const RsGxsGroupId& gid)
{
rstime_t now = time(nullptr);
RS_STACK_MUTEX(mKnownCirclesMtx);
auto it = mKnownCircles.find(gid);
bool unknown_posted = (it == mKnownCircles.end());
if(unknown_posted)
{
mKnownCircles[gid] = now;
IndicateConfigChanged();
return now;
}
else
return it->second;
}
bool p3GxsCircles::service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta)
{
#ifdef GXSFORUMS_CHANNELS

View File

@ -290,6 +290,7 @@ public:
virtual void updateGroup(uint32_t &token, RsGxsCircleGroup &group) override;
virtual bool service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta) override;
virtual rstime_t service_getLastGroupSeenTs(const RsGxsGroupId&) override;
/* membership management for external circles */

View File

@ -417,6 +417,24 @@ void p3GxsForums::service_tick()
return;
}
rstime_t p3GxsForums::service_getLastGroupSeenTs(const RsGxsGroupId& gid)
{
rstime_t now = time(nullptr);
RS_STACK_MUTEX(mKnownForumsMutex);
auto it = mKnownForums.find(gid);
bool unknown_forum = it == mKnownForums.end();
if(unknown_forum)
{
mKnownForums[gid] = now;
IndicateConfigChanged();
return now;
}
else
return it->second;
}
bool p3GxsForums::service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta)
{
#ifdef GXSFORUMS_DEBUG

View File

@ -53,6 +53,7 @@ protected:
virtual bool loadList(std::list<RsItem *>& loadList) override; // @see p3Config::loadList(std::list<RsItem *>&)
virtual bool service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta) override;
virtual rstime_t service_getLastGroupSeenTs(const RsGxsGroupId&) override;
public:
/// @see RsGxsForums::createForumV2
bool createForumV2(

View File

@ -695,7 +695,12 @@ void IdDialog::loadCircles(const std::list<RsGroupMetaData>& groupInfo)
if(am_I_subscribed)
tooltip += tr("subscribed (Receive/forward membership requests from others and invite list).") ;
else
tooltip += tr("unsubscribed (Only receive invite list).") ;
{
if(vit->mLastSeen>0)
tooltip += tr("unsubscribed (Only receive invite list). Last seen: %1 days ago.").arg( (time(nullptr)-vit->mLastSeen)/86400 );
else
tooltip += tr("unsubscribed (Only receive invite list).");
}
tooltip += "\n"+tr("Your status: ") ;

View File

@ -1065,6 +1065,11 @@ void GxsForumThreadWidget::updateForumDescription(bool success)
forum_description += QString("<b>%1: \t</b>%2<br/>").arg(tr("Synchronization"),getDurationString( rsGxsForums->getSyncPeriod(group.mMeta.mGroupId)/86400 )) ;
forum_description += QString("<b>%1: \t</b>%2<br/>").arg(tr("Storage"),getDurationString( rsGxsForums->getStoragePeriod(group.mMeta.mGroupId)/86400));
}
else
{
if(group.mMeta.mLastSeen > 0)
forum_description += QString("<b>%1: \t</b>%2 days ago<br/>").arg(tr("Last seen at friends:"),QString::number((time(nullptr) - group.mMeta.mLastSeen)/86400));
}
QString distrib_string = tr("[unknown]");
switch(static_cast<RsGxsCircleType>(group.mMeta.mCircleType))