From 1d4137fb88532de3cc2ffe487bc5c37ed04c759d Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Sat, 3 Jun 2023 11:35:15 +0200 Subject: [PATCH] [bugfix] Fix first item of thread dereferencing always being skipped (#1858) * [bugfix] Fix first item of thread dereferencing always being skipped * tweak to status descendant item iteration Signed-off-by: kim --------- Signed-off-by: kim Co-authored-by: kim --- internal/federation/dereferencing/thread.go | 31 ++++++++------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/internal/federation/dereferencing/thread.go b/internal/federation/dereferencing/thread.go index 3b58b4eed..ec22c66a8 100644 --- a/internal/federation/dereferencing/thread.go +++ b/internal/federation/dereferencing/thread.go @@ -22,6 +22,7 @@ import ( "net/url" "codeberg.org/gruf/go-kv" + "github.com/superseriousbusiness/activity/pub" "github.com/superseriousbusiness/activity/streams/vocab" "github.com/superseriousbusiness/gotosocial/internal/ap" "github.com/superseriousbusiness/gotosocial/internal/config" @@ -97,7 +98,8 @@ func (d *deref) dereferenceStatusAncestors(ctx context.Context, username string, l.Tracef("following remote status ancestors: %s", status.InReplyToURI) // Fetch the remote status found at this IRI - remoteStatus, _, err := d.getStatusByURI(ctx, + remoteStatus, _, err := d.getStatusByURI( + ctx, username, replyIRI, ) @@ -184,8 +186,8 @@ stackLoop: } if current.page == nil { - // This is a local status, no looping to do if current.statusIRI.Host == config.GetHost() { + // This is a local status, no looping to do continue stackLoop } @@ -227,33 +229,24 @@ stackLoop: // Start off the item iterator current.itemIter = items.Begin() - if current.itemIter == nil { - continue stackLoop - } } itemLoop: for { - var itemIRI *url.URL - - // Get next item iterator object - current.itemIter = current.itemIter.Next() + // Check for remaining iter if current.itemIter == nil { break itemLoop } - if iri := current.itemIter.GetIRI(); iri != nil { - // Item is already an IRI type - itemIRI = iri - } else if note := current.itemIter.GetActivityStreamsNote(); note != nil { - // Item is a note, fetch the note ID IRI - if id := note.GetJSONLDId(); id != nil { - itemIRI = id.GetIRI() - } - } + // Get current item iterator + itemIter := current.itemIter + // Set the next available iterator + current.itemIter = itemIter.Next() + + // Check for available IRI on item + itemIRI, _ := pub.ToId(itemIter) if itemIRI == nil { - // Unusable iter object continue itemLoop }