Decentralizing my application doesn't work

I use AdonisJS V5 in my application. I want to use Activitypub to decentraliszed my application and connected it to the fediverse.
AdonisJS is very similar to Laravel or RubyOnRails. But Adonis don’t have package or librairie to use Activitypub but I saw that it’s not a problem because I will have to deal with JSON-LD only.
Here is my code :

public async get({ request, response }: HttpContextContract) {
    const user = await User.findBy('username', request.param('username'))
    if (!user) throw new APIException("Not found.", 404)

    const actor = {
      '@context': ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1'],
      'type': 'Person',
      'id': `https://api.creativeblogger.org/users/${user.username}`,
      'username': user.username,
      'acct': `${user.username}@api.creativeblogger.org`,
      'display_name': `${user.username}`,
      'url': `https://api.creativeblogger.org/users/${user.username}`,
      'avatar': `${user.pp}`,
      'inbox': `https://api.creativeblogger.org/users/${user.username}/inbox`,
      'outbox': `https://api.creativeblogger.org/users/${user.username}/outbox`,
      'avatar_static': `${user.pp}`,
      'note': `${user.biography}`,
      'note_text': `${user.biography}`,
      'created_at': `${user.createdAt}`,
      'icon': [`${user.pp}`],
      'publicKey': {
        id: `https://api.creativeblogger.org${request.url()}actor`,
        owner: `https://api.creativeblogger.org/users/${user.username}`,
        publicKeyPem: `-----BEGIN PUBLIC KEY-----content of my public.pem-----END PUBLIC KEY-----
        `,
      },
    }

    return response.status(200).json(actor)

I also have a WebFinger who works perfectly. When I search my users on pixelfed, I find my users but no one information about the users. Not the avatar, display name, created_at… nothing.
When I search on mastodon I don’t find my users but with Pixelfed I find the users but without their informations…
I have this problem since a long time and it’s very tired because I don’t know why I have the error.
If you want to check here is one of the users of my application :
squaredot@api.creativeblogger.org
https://api.creativeblogger.org/users/SquareDot/actor
“”/.well-known/webfinger?resource=acct:squaredot@api.creativeblogger.org

Please help me ! I really need help lol

You’re probably responding with the wrong Content-Type. Make sure your response has the header Content-Type: appliaction/activity+json or Content-Type: application/ld+json; profile="https://www.w3.org/ns/activitystreams"

1 Like

Yeah, I just checked and your response has the Header content-type: application/json; charset=utf-8. You’ll need to fix that.

You should set preferredUsername, too, if you want to interoperate with Mastodon. (Some other projects are less fussy.)

I try to modify this. Now the content type is application/activity+json on users but also on webfinger (I try all lol)
But my users don’t appears on Mastodon and I have the same weird problem on PixelFed.
And I don’t know if it’s normal (I presume no) but when I enter the URL to search a user on my API, the browser download a file with the informations of users but do not display them.
If you want to try :
https://api.creativeblogger.org/users/SquareDot
“”/.well-known/webfinger?resource=acct:squaredot@api.creativeblogger.org

I’m very sorry I presume that I don’t understand all and I understand that your time is not limited :face_with_open_eyes_and_hand_over_mouth:

Thank you,
Have a good day ^^

Hi, I think you have a typo in your header. Here are the headers I’m seeing:

brownsville:~$ curl -I 'https://api.creativeblogger.org/users/SquareDot'
HTTP/2 200 
date: Mon, 26 Feb 2024 15:16:29 GMT
content-type: appliaction/activity+json
content-length: 1361
x-powered-by: Phusion Passenger(R) 6.0.20
status: 200 OK
server: o2switch-PowerBoost-v3

This says appliaction, but it should say application

Oooh hem yeah lol I fix that.
But I still don’t see my users on Mastodon or Pixelfed I have the same issus…
To precise because I think it’s important I put the Content-Type on the response of the Webfinger and to the users searching route.
Ex :
https://api.creativeblogger.org/users/SquareDot/ have a application/activity+json content type
https://api.creativeblogger.org/.well-known/webfinger?resource=acct:squaredot@api.creativeblogger.org have also a application/activity+json content type.
Is it the right thing to do or just for webfinger or just for users searching ?

And other little thing but in my publicKeyPem field I saw on Mastodon blog “How create an activitypub server” that I have to put “\n” because JSON does not support verbatim line-breaks in strings but I see that in the string the “\n” are here, is it normal ?