Skip to content

Commit

Permalink
[bugfix] Fix first item of thread dereferencing always being skipped (#…
Browse files Browse the repository at this point in the history
…1858)

* [bugfix] Fix first item of thread dereferencing always being skipped

* tweak to status descendant item iteration

Signed-off-by: kim <grufwub@gmail.com>

---------

Signed-off-by: kim <grufwub@gmail.com>
Co-authored-by: kim <grufwub@gmail.com>
  • Loading branch information
tsmethurst and NyaaaWhatsUpDoc committed Jun 3, 2023
1 parent 1f39275 commit 1d4137f
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions internal/federation/dereferencing/thread.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 1d4137f

Please sign in to comment.