Monorepo for Tangled tangled.org
859
fork

Configure Feed

Select the types of activity you want to include in your feed.

appview: don't notify on replayed events #352

open opened by boltless.me targeting master from sl/comment
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:xasnlahkri4ewmbuzly2rlc5/sh.tangled.repo.pull/3mlehfetyvv22
+12 -14
Diff #1
+8 -10
appview/db/comments.go
··· 4 4 "database/sql" 5 5 "encoding/json" 6 6 "fmt" 7 - "log" 8 7 "sort" 9 8 "strings" 10 9 "time" ··· 15 14 "tangled.org/core/orm" 16 15 ) 17 16 18 - func PutComment(tx *sql.Tx, c *models.Comment, references []syntax.ATURI) error { 17 + func PutComment(tx *sql.Tx, c *models.Comment, references []syntax.ATURI) (bool, error) { 19 18 var bodyBlobs, replyToUri, replyToCid *string 20 19 if len(c.Body.Blobs) > 0 { 21 20 encoded, err := json.Marshal(c.Body.Blobs) 22 21 if err != nil { 23 - return fmt.Errorf("encoding blobs to json: %w", err) 22 + return false, fmt.Errorf("encoding blobs to json: %w", err) 24 23 } 25 24 encodedStr := string(encoded) 26 25 bodyBlobs = &encodedStr ··· 78 77 time.Now().Format(time.RFC3339), 79 78 ) 80 79 if err != nil { 81 - return err 80 + return false, err 82 81 } 83 82 84 83 c.Id, err = result.LastInsertId() 85 84 if err != nil { 86 - return err 85 + return false, err 87 86 } 88 87 89 88 affected, err := result.RowsAffected() 90 89 if err != nil { 91 - return err 90 + return false, err 92 91 } 93 92 94 93 if affected < 1 { 95 - log.Println("record is already stored. skipping operation") 96 - return nil 94 + return false, nil 97 95 } 98 96 99 97 // update references when comment is updated 100 98 if err := putReferences(tx, c.AtUri(), references); err != nil { 101 - return fmt.Errorf("put reference_links: %w", err) 99 + return false, fmt.Errorf("put reference_links: %w", err) 102 100 } 103 101 104 - return nil 102 + return true, nil 105 103 } 106 104 107 105 // PurgeComments actually purges a comment row from db instead of marking it as "deleted"
+2 -2
appview/ingester.go
··· 1337 1337 } 1338 1338 defer tx.Rollback() 1339 1339 1340 - err = db.PutComment(tx, comment, references) 1340 + updated, err := db.PutComment(tx, comment, references) 1341 1341 if err != nil { 1342 1342 return fmt.Errorf("failed to create comment: %w", err) 1343 1343 } ··· 1346 1346 return err 1347 1347 } 1348 1348 1349 - if e.Commit.Operation == jmodels.CommitOperationCreate { 1349 + if e.Commit.Operation == jmodels.CommitOperationCreate && updated { 1350 1350 i.Notifier.NewComment(ctx, comment, mentions) 1351 1351 } 1352 1352
+2 -2
appview/state/comment.go
··· 279 279 } 280 280 defer tx.Rollback() 281 281 282 - err = db.PutComment(tx, &comment, references) 282 + _, err = db.PutComment(tx, &comment, references) 283 283 if err != nil { 284 284 l.Error("failed to create comment", "err", err) 285 285 s.pages.Notice(w, noticeId, "Failed to create comment.") ··· 377 377 } 378 378 defer tx.Rollback() 379 379 380 - err = db.PutComment(tx, &newComment, references) 380 + _, err = db.PutComment(tx, &newComment, references) 381 381 if err != nil { 382 382 l.Error("failed to perform update-description query", "err", err) 383 383 s.pages.Notice(w, noticeId, "Failed to update comment, try again later.")

History

2 rounds 0 comments
sign up or login to add to the discussion
1 commit
expand
appview: don't notify on replayed events
merge conflicts detected
expand
  • appview/migration/migration.go:71
expand 0 comments
1 commit
expand
appview: don't notify on replayed events
expand 0 comments