diff options
Diffstat (limited to 'backend/notes/note.go')
| -rw-r--r-- | backend/notes/note.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/backend/notes/note.go b/backend/notes/note.go index 8a73b70..7ef537f 100644 --- a/backend/notes/note.go +++ b/backend/notes/note.go @@ -40,13 +40,16 @@ func isChainContained(smallChainPost, bigChainPost Note) bool { return false } - // check if parents of smallChainPost are included in bigChainPost - offset := len(bigChainPost.Parents) - len(smallChainPost.Parents) - for i, note := range smallChainPost.Parents { - if bigChainPost.Parents[offset+i].URI != note.URI { - return false - } + // if the thread is going to differ at any post, it's going to be at the end + // thus if the posts match their parents MUST match too + // (not that I expect to ever compare a post to itself but this way it won't break if I do. And technically a thread contains itself) + if len(smallChainPost.Parents) == len(bigChainPost.Parents) { + return smallChainPost.URI == bigChainPost.URI } + + // check if the last post of the smaller chain is the (n+1)-th post of the bigger chain + // where n is the number of parents in the smaller reply chain + offset := len(bigChainPost.Parents) - len(smallChainPost.Parents) return smallChainPost.URI == bigChainPost.Parents[offset-1].URI } |
