Skip to content

Commit

Permalink
cmd/bsky-webhook: ignore posts older than a day
Browse files Browse the repository at this point in the history
  • Loading branch information
Erisa committed Nov 19, 2024
1 parent f1965fb commit 7d5a24d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/bsky-webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func readJetstreamMessage(ctx context.Context, jetstreamMessageEncoded []byte, b
}

// we can ignore these messages
if bskyMessage.Kind != "commit" || bskyMessage.Commit == nil || bskyMessage.Commit.Operation != "create" || bskyMessage.Commit.Record == nil || bskyMessage.Commit.Rkey == "" {
if bskyMessage.Time < (time.Now().UnixMicro()-86400000000) || bskyMessage.Kind != "commit" || bskyMessage.Commit == nil || bskyMessage.Commit.Operation != "create" || bskyMessage.Commit.Record == nil || bskyMessage.Commit.Rkey == "" {
return nil
}

Expand Down
1 change: 1 addition & 0 deletions cmd/bsky-webhook/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type BskyMessage struct {
Did string `json:"did"`
Commit *BskyCommit `json:"commit"`
Kind string `json:"kind"`
Time int64 `json:"time_us"`
}

func (m *BskyMessage) toURL(handle *string) string {
Expand Down

0 comments on commit 7d5a24d

Please sign in to comment.