#social 2021-08-16
2021-08-16 UTC
timbl joined the channel
#
heluecht[m] Is someone here who does know a bit about the web push api and how it is implemented in Mastodon? I would like to know what payload is transmitted because I'm currently trying to implement it in Friendica.
#
nightpool[m] I think we ripped out Web Push a while ago, sorry
#
nightpool[m] oh you mean push notifications
#
nightpool[m] yes, I can speak to that
#
nightpool[m] I thought you were asking about the spec that evolved out of Pubsubhubbub
#
nightpool[m] * ~~I think we ripped out Web Push a while ago, sorry~~
#
nightpool[m] * ~~I think we ripped out Web Push a while ago, sorry~~
#
heluecht[m] I mean this one: https://docs.joinmastodon.org/methods/notifications/push/
#
nightpool[m] yep, yep, I'm on the right page now
#
nightpool[m] just got websub and webpush confused for a moment :p
#
heluecht[m] I haven't found a documentation about the content of the notification.
#
nightpool[m] hmm, not sure off hand. it's probably similar to the streaming API payload. is this for mastodon API compatibility?
#
nightpool[m] heluecht: here's the serializer: https://github.com/mastodon/mastodon/blob/master/app/serializers/web/notification_serializer.rb
#
heluecht[m] Yeah. Some apps are querying that part of the API, so we should implement it as well.
#
nightpool[m] the payload is very simple, it contains only enough information needed to display the preview of the notification to the user, everything else needs to be fetched from the API.
#
heluecht[m] So is the stuff with "def" the payload variables?
#
nightpool[m] ah, yes, the variables are `:access_token, :preferred_locale, :notification_id, :notification_type, :icon, :title, :body`
#
nightpool[m] and the `def` is the function definition for each one
#
heluecht[m] Are there samples in the code explaining the content? Some like the notification_id and the notification_type are clear. The icon could be a general icon for the application. But what is the access_token? Is this the token from the associated application?
#
nightpool[m] the icon is the icon of the user the notification is associated with. So for example if you like my post, when I get a notification for that like, it'll be your icon
#
nightpool[m] but ultimately it's very thin-client, the app will just display whatever you send it
#
nightpool[m] the access_token is created when setting up the push notification, it's part of the payload returned. I assume so that apps can associate the right push notifications with the right users?
#
heluecht[m] "Subway Tooter" doesn't seem to care about the payload at all. It doesn't matter what I send, it will always pull the notifications directly afterwars.
#
heluecht[m] Ah okay.
#
nightpool[m] ah, sorry, i was slightly wrong about that—the `access_token` is just the normal access_token for the app/user combination
#
heluecht[m] Ah, great. I was slightly confused.
#
heluecht[m] And "title" and "body" would be some "you have been mentioned by xzy" or more the real body of the message?
#
nightpool[m] title would be "you have been mentioned by xyz" and body would be a truncated version of the real body of the message
#
nightpool[m] we truncate to 140 characters, most push servers have very strict payload size limits
#
nightpool[m] * we truncate to 140 characters (with ...), most push servers have very strict payload size limits
#
nightpool[m] * we truncate to 140 characters (with "..." at the end), most push servers have very strict payload size limits
#
heluecht[m] Ah okay.
#
heluecht[m] And I guess that "preferred_locale" will be some normal "de_de" or "en_us" stuff?
#
nightpool[m] yep. I believe you can set a preferred locale when setting up the subscription.
#
nightpool[m] ah, no, it just uses the locale from the user
#
heluecht[m] And I guess that - like always with Mastodon - the "id" value is encoded as a string?
#
nightpool[m] hmm, i don't think so. that's only for snowflake IDs
#
heluecht[m] "snowflake ID"?
#
nightpool[m] IDs that are based on a timestamp, instead of an incrementing counter.
epilys left the channel
#
nightpool[m] i.e. status IDs
#
heluecht[m] In the API all the "id" values are transmitted as strings, like the status ids.
#
nightpool[m] hmm, i thought it was only status and account IDs
#
nightpool[m] i could definitely be wrong though
#
heluecht[m] I will try out. If everything else fails I will use my Mastodon test account to receive notifications.
#
nightpool[m] sent a long message: nightpool[m]_2021-08-16_22:06:38.txt <https://matrix.cybre.space/_matrix/media/v1/download/cybre.space/rDqqnTZSZKOmRpmnkQlEltXc>
#
heluecht[m] Thanks very much!
#
nightpool[m] np!
#
heluecht[m] Let's see if the clients like this better. I had tested several apps and with one exception nobody seemed to like me :-)
#
heluecht[m] With the right payload it should work out better.
#
heluecht[m] Hmm, B4X still returns "JSON Object expected". And Amaroq said "PayloadTooLarge" - but they are saying this even with an empty payload.
#
heluecht[m] It's getting late here, so I guess I will continue tomorrow. Thanks for your help!
#
nightpool[m] No problem!