Skip to content
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

RSS replies to a user #111 #145

Merged
merged 2 commits into from
Jul 9, 2018
Merged

Conversation

akosourov
Copy link
Contributor

@akosourov akosourov commented Jul 8, 2018

Added /rss/reply?user=userID&site=siteID endpoint. It retrieves last 100 comments for site siteID and for each comment reads parent to determine is it reply to userID or not. Stops iterate when max replies are found or comment were published later than 30 minutes. Skips replies when user replies to himself.
relates to #111

Copy link
Owner

@umputun umputun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor things

log.Printf("[DEBUG] get rss replies to user %s for site %s", userID, siteID)

data, err := s.Cache.Get(cache.Key(cache.URLKey(r), siteID, userID), func() ([]byte, error) {
comments, e := s.DataService.Last(siteID, 100)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls make a const for this, maxLastForReply or smth like this


replies := []store.Comment{}
for _, c := range comments {
if len(replies) > maxRssItems || c.Timestamp.Add(30*time.Minute).Before(time.Now()) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same story as above - MaxReplyMins

break
}
if c.ParentID != "" && !c.Deleted && c.User.ID != userID { // not interested replies to yourself
pc, e := s.DataService.Get(c.Locator, c.ParentID)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this made linter sad "app/rest/api/rss.go:111::warning: declaration of "e" shadows declaration at app/rest/api/rss.go:99 (vetshadow)"

@akosourov
Copy link
Contributor Author

Added consts and fixed linter warning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants