-
-
Notifications
You must be signed in to change notification settings - Fork 330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bugfix] Tidy up rss feed serving; don't error on empty feed #1970
Conversation
} | ||
|
||
// Retrieve latest statuses as they'd be shown on the web view of the account profile. | ||
statuses, err := p.state.DB.GetAccountWebStatuses(ctx, account.ID, rssFeedLength, "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this whole section, up to the feed.ToRss()
, could be made part of the else
block? When lastPostAt.IsZero()
is true, we can skip doing the database call entirely in that case. The query GetAccountWebStatuses
generates is kinda beefy, although it should be really quick I suppose if there's nothing in it.
I'm fine with either honestly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Fixed it now by returning early.
return true | ||
} | ||
|
||
return t1.Unix() > t2.Unix() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious as to why we're comparing the .Unix()
values instead of t1.After(t2)
? Looking at the Go playground, I think using the time functions directly always do what we want: https://go.dev/play/p/z35W9c5ch7M
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's timezone related, basically. I found that doing After wasn't always reliable when you're comparing dates from different timezones, but casting them to unix time always seemed to get the expected result.
edit: there's probably a nicer, go-approved way of doing this, i just found it easier to cast them to unix because it makes sense to me
Description
This PR tidies up some of the very messy rss feed logic and adds comments for clarity.
Also allows RSS feeds to be served even when the account owner hasn't posted anything yet (closes #1951). In such a case, the result will be a feed that just doesn't have any items in it.
Example with items:
Example with no items:
Checklist
Please put an x inside each checkbox to indicate that you've read and followed it:
[ ]
->[x]
If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want).
go fmt ./...
andgolangci-lint run
.