Skip to content

Commit

Permalink
palomar: clear createdAt datetime for 'future' posts
Browse files Browse the repository at this point in the history
  • Loading branch information
bnewbold committed Dec 15, 2023
1 parent acd8a85 commit 83cb076
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions search/transform.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package search

import (
"log/slog"
"strings"
"time"

appbsky "github.com/bluesky-social/indigo/api/bsky"
"github.com/bluesky-social/indigo/atproto/identity"
Expand Down Expand Up @@ -180,8 +182,13 @@ func TransformPost(post *appbsky.FeedPost, ident *identity.Identity, rkey, cid s
// there are some old bad timestamps out there!
dt, err := syntax.ParseDatetimeLenient(post.CreatedAt)
if nil == err { // *not* an error
s := dt.String()
doc.CreatedAt = &s
// not more than a few minutes in the future
if time.Since(dt.Time()) >= -1*5*time.Minute {
s := dt.String()
doc.CreatedAt = &s
} else {
slog.Warn("rejecting future post CreatedAt", "datetime", dt.String(), "did", ident.DID.String(), "rkey", rkey)
}
}
}

Expand Down

0 comments on commit 83cb076

Please sign in to comment.