superseriousbusiness / gotosocial

Fast, fun, small ActivityPub server.
https://docs.gotosocial.org
GNU Affero General Public License v3.0
3.61k stars 304 forks source link

[feature] Fetching remote accounts directly should refresh DB info #229

Closed NyaaaWhatsUpDoc closed 1 year ago

NyaaaWhatsUpDoc commented 2 years ago

Due to restarting my instance at points I've obviously missed the profile change AP messages at some point so my profile data for multiple people is out of date. Performing a direct fetch of an account, i.e. visiting a user's profile page, should perform the equivalent of GetRemoteStatus(refresh = true) to keep profiles up-to-date

tsmethurst commented 2 years ago

Agree that this is a problem, but I'm not sure if we want to trigger a refresh every time a profile is visited directly, since this could easily end up spamming remote instances. I think it's probably better if we implement something with LastWebfingeredAt on accounts; if an account hasn't been webfingered (ie., refreshed) in say 6 hours (or some other time limit), then a refresh is performed the next time an account is 'seen'. That seems less prone to spam, although the price we pay then is not having minute-to-minute updates of an account if we miss the Update activitypub message.

NyaaaWhatsUpDoc commented 2 years ago

I mean even a 5 minute timeout would prevent spam and would ensure near-enough minute-to-minute updates IMO

tsmethurst commented 2 years ago

Ah yes, so maybe we do a refresh UNLESS lastwebfingered at is within x amount of time? That could work indeed

NyaaaWhatsUpDoc commented 2 years ago

We could do the same for fetching remote statuses in direct-view and their lastmodtime -- which I'm assuming would allow us to keep some kind of an eye of favourites / reblogs count?

tsmethurst commented 2 years ago

Reblog and favourite counts aren't pinned to the activitypub representation of the status, so thankfully we don't need to dereference a status once we've got it already (unless we assume some kind of 'Update' thing, which afaik not many (any?) AP implementations use yet). We just use the amount of reblogs and faves we've seen to generate those numbers :)

NyaaaWhatsUpDoc commented 2 years ago

Ah gotcha that does make things much simpler :)

Would a combo of domain != nil && time.Now().Sub(lastmodtime) > threshold do essentially the same on accounts? I'm just wondering if we need to use the last-webfingered check, as an account update via AP wouldn't update the webfingered time I'm assuming?

tsmethurst commented 2 years ago

an account update via AP wouldn't update the webfingered time I'm assuming

Good point... Maybe we should change that column to 'lastDereferencedAt' and count an Update as a dereference (just one that we're having pushed to us, rather than pulling).

NyaaaWhatsUpDoc commented 2 years ago

Sure a last modified time would serve this purpose? And have the bonus of not being useful only for remote accounts

tsmethurst commented 2 years ago

Mmm yes on reflection I think you're right, maybe we can just drop 'lastWebfingeredAt' altogether then :)

tsmethurst commented 1 year ago

Related to #822

tsmethurst commented 1 year ago

closed by https://github.com/superseriousbusiness/gotosocial/pull/1411