diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index af0e83fc3..5ddb0be26 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -1379,7 +1379,16 @@ bool RsGenExchange::getGroupMeta(const uint32_t &token, std::listmeta.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. diff --git a/libretroshare/src/gxs/rsgenexchange.h b/libretroshare/src/gxs/rsgenexchange.h index 9551cc652..1bb8bbde6 100644 --- a/libretroshare/src/gxs/rsgenexchange.h +++ b/libretroshare/src/gxs/rsgenexchange.h @@ -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: /*! diff --git a/libretroshare/src/retroshare/rsgxsifacetypes.h b/libretroshare/src/retroshare/rsgxsifacetypes.h index dbd071987..0f78b3738 100644 --- a/libretroshare/src/retroshare/rsgxsifacetypes.h +++ b/libretroshare/src/retroshare/rsgxsifacetypes.h @@ -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; diff --git a/libretroshare/src/services/p3gxscircles.cc b/libretroshare/src/services/p3gxscircles.cc index 24bc7c096..b1a3bc5e2 100644 --- a/libretroshare/src/services/p3gxscircles.cc +++ b/libretroshare/src/services/p3gxscircles.cc @@ -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 diff --git a/libretroshare/src/services/p3gxscircles.h b/libretroshare/src/services/p3gxscircles.h index 8bdce3756..a98e09184 100644 --- a/libretroshare/src/services/p3gxscircles.h +++ b/libretroshare/src/services/p3gxscircles.h @@ -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 */ diff --git a/libretroshare/src/services/p3gxsforums.cc b/libretroshare/src/services/p3gxsforums.cc index f2145ccee..a301997e6 100644 --- a/libretroshare/src/services/p3gxsforums.cc +++ b/libretroshare/src/services/p3gxsforums.cc @@ -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 diff --git a/libretroshare/src/services/p3gxsforums.h b/libretroshare/src/services/p3gxsforums.h index da45afcdc..97f04cc7b 100644 --- a/libretroshare/src/services/p3gxsforums.h +++ b/libretroshare/src/services/p3gxsforums.h @@ -53,6 +53,7 @@ protected: virtual bool loadList(std::list& loadList) override; // @see p3Config::loadList(std::list&) virtual bool service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta) override; + virtual rstime_t service_getLastGroupSeenTs(const RsGxsGroupId&) override; public: /// @see RsGxsForums::createForumV2 bool createForumV2( diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index bffed9508..4e319860b 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -695,7 +695,12 @@ void IdDialog::loadCircles(const std::list& 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: ") ; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 66e92fbb9..f95392bea 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -1065,6 +1065,11 @@ void GxsForumThreadWidget::updateForumDescription(bool success) forum_description += QString("%1: \t%2
").arg(tr("Synchronization"),getDurationString( rsGxsForums->getSyncPeriod(group.mMeta.mGroupId)/86400 )) ; forum_description += QString("%1: \t%2
").arg(tr("Storage"),getDurationString( rsGxsForums->getStoragePeriod(group.mMeta.mGroupId)/86400)); } + else + { + if(group.mMeta.mLastSeen > 0) + forum_description += QString("%1: \t%2 days ago
").arg(tr("Last seen at friends:"),QString::number((time(nullptr) - group.mMeta.mLastSeen)/86400)); + } QString distrib_string = tr("[unknown]"); switch(static_cast(group.mMeta.mCircleType))