diff options
| author | Hazelnoot <acomputerdog@gmail.com> | 2024-10-13 18:11:16 -0400 |
|---|---|---|
| committer | Hazelnoot <acomputerdog@gmail.com> | 2024-10-15 14:17:19 -0400 |
| commit | 93cf2f9045e4af485a29690313b7d74b0f54cab6 (patch) | |
| tree | 607b7952d47c687b6d4cd236557969afeab5be9f /packages/backend/src/models | |
| parent | update latest note in background (don't await the result) (diff) | |
| download | sharkey-93cf2f9045e4af485a29690313b7d74b0f54cab6.tar.gz sharkey-93cf2f9045e4af485a29690313b7d74b0f54cab6.tar.bz2 sharkey-93cf2f9045e4af485a29690313b7d74b0f54cab6.zip | |
factor out latest_note logic into LatestNoteService
Diffstat (limited to 'packages/backend/src/models')
| -rw-r--r-- | packages/backend/src/models/LatestNote.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/packages/backend/src/models/LatestNote.ts b/packages/backend/src/models/LatestNote.ts index d36a4d568a..ff8815bd42 100644 --- a/packages/backend/src/models/LatestNote.ts +++ b/packages/backend/src/models/LatestNote.ts @@ -82,4 +82,16 @@ export class SkLatestNote { isQuote: isRenote(note) && isQuote(note), }; } + + /** + * Checks if two notes would produce equivalent compound keys. + */ + static areEquivalent(first: MiNote, second: MiNote): boolean { + return ( + first.userId === second.userId && + first.visibility === second.visibility && + (first.replyId != null) === (second.replyId != null) && + (isRenote(first) && isQuote(first)) === (isRenote(second) && isQuote(second)) + ); + } } |