emuarius icon indicating copy to clipboard operation
emuarius copied to clipboard

Tweets are not shown

Open freemountain opened this issue 7 years ago • 7 comments

Hi, i am not sure if this i an issue with emuarius, go-ostatus or mastodon but i am not able to see tweets from twitter users inside mastodon (v2.4.0), only the profile with an empty timeline is visible. The output from the emuarius http api looks good and contains all the information.

I am willing to help with a PR but have no clue where to start.

freemountain avatar Jun 23 '18 10:06 freemountain

It's possible that this is because of an incorrect signature. I've also seen issues with base64 encoding in the past.

I'd start by looking at Mastodon logs to see if there's anything interesting there.

emersion avatar Jun 23 '18 12:06 emersion

Looks like a bug in the salmon part of go-ostatus: I'm constantly recording HTTP 400 responses to a Mastodon instance when the /salmon path is posted.

One issue is: Mastodon sends a charset in their XRD responses: application/xrd+xml; charset=utf-8. This is fairly easy to fix:

diff --git a/xrd/client.go b/xrd/client.go
index 3e31c59..cb6d964 100644
--- a/xrd/client.go
+++ b/xrd/client.go
@@ -5,6 +5,7 @@ import (
        "encoding/xml"
        "errors"
        "net/http"
+       "strings"
 )

 // An HTTPError is returned when an HTTP error has occured. Its value is the
@@ -29,13 +30,13 @@ func Get(url string) (*Resource, error) {
        }

        resource := new(Resource)
-       switch resp.Header.Get("Content-Type") {
+       switch strings.Split(resp.Header.Get("Content-Type"), ";")[0] {
        case "application/xrd+xml", "application/xml", "text/xml":
                err = xml.NewDecoder(resp.Body).Decode(resource)
        case "application/jrd+json", "application/json", "":
                err = json.NewDecoder(resp.Body).Decode(resource)
        default:
-               err = errors.New("xrd: unsupported format")
+               err = errors.New("xrd: unsupported format: " + resp.Header.Get("Content-Type"))
        }
        return resource, err
 }

Then another problem is either something with the cryptographic signature in Mastodon or the verification in go-ostatus is broken… Until now I did not find the mismatch in there… The response sent to the Mastodon instance is: crypto/rsa: verification error

Luzifer avatar Nov 19 '18 22:11 Luzifer

Yeah, I recall having similar issues. IIRC there were also some issues with the base64 mode we're using...

(In any case, can you submit a PR for this first patch? Also, using mime.ParseMediaType is preferred)

emersion avatar Nov 19 '18 22:11 emersion

Sure, as soon as my copy of the library is cleaned up from tons of debugging code I'm trying to hunt the issue down with… :D

Luzifer avatar Nov 19 '18 22:11 Luzifer

The hint for base64 issues was marvellous: Spared me much time and therefore emersion/go-ostatus#10 fixes both issues and restores communication with a Mastodon instance. Sadly that wasn't everything to fix this issue… Older Toots still are not loaded…

Luzifer avatar Nov 19 '18 23:11 Luzifer

The hint for base64 issues was marvellous: Spared me much time and therefore emersion/go-ostatus#10 fixes both issues and restores communication with a Mastodon instance.

Cheers!

Sadly that wasn't everything to fix this issue… Older Toots still are not loaded…

Do you mean older tweets are not displayed as toots on Mastodon? Maybe that's some sort of pagination issue?

emersion avatar Nov 20 '18 07:11 emersion

When the account is first subscribed it shows an entirely empty Timeline instead of posts from the past. As soon as there was a first push those toots are shown. (When pushing old toots from before the subscribe they are displayed on top of the Timeline instead of being sorted so this might be an intended behavior of mastodon)

Luzifer avatar Nov 20 '18 08:11 Luzifer