jointakahe / takahe

An ActivityPub/Fediverse server
BSD 3-Clause "New" or "Revised" License
1.13k stars 88 forks source link

Implement Emoji Reactions #304

Open kromonos opened 1 year ago

kromonos commented 1 year ago

Could also be from MissKey:

users-runner     | Tasks processed this loop:
users-runner     |   users.inboxmessage: 2
users-runner     | Running cleaning and scheduling
users-runner     | Attempting transition on users.inboxmessage#69809 from state received
users-runner     | Traceback (most recent call last):
users-runner     |   File "/usr/local/lib/python3.11/site-packages/asgiref/sync.py", line 486, in thread_handler
users-runner     |     raise exc_info[1]
users-runner     |   File "/takahe/stator/models.py", line 172, in atransition_attempt
users-runner     |     next_state = await current_state.handler(self)  # type: ignore
users-runner     |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
users-runner     |   File "/takahe/users/models/inbox_message.py", line 120, in handle_received
users-runner     |     raise ValueError(f"Cannot handle activity of type {unknown}")
users-runner     | ValueError: Cannot handle activity of type http://litepub.social/ns#emojireact

Personally, I'm feeling a bit mixed about the function. Surely it is sometimes quite nice, but necessary? Not really. After all, there is the little star under the message. Admittedly, the emoji reaction could express other “feelings” as well, than just like.

andrewgodwin commented 1 year ago

Oh right, emoji reactions. I'll just put in a thing to drop and ignore these for now and we'll revisit if we want to support them in future.

whatSocks commented 1 year ago

Another option is to treat them like favorites, which is how I believe mastodon handles emojireacts from fedibird

andrewgodwin commented 1 year ago

I hesitated to do that given that the emoji in the react might be negative, but if it's an established pattern...

kromonos commented 1 year ago

I think, a reaction is a reaction, never mind, if it's a star, or an emoji. If it's meant negative, that's ok. That's on their side, but it hasn't meant to be negative on Takahe side?

shuuji3 commented 1 year ago

It looks like both Misskey and Firefish are sending the type=Like object at this time. So Takahē already accepts any emoji reaction on the other server as a like reaction now.

Here's an example object sent from Firefish when I send 😇 reaction:

{
    'id': 'https://firefish.social/likes/9ik9ujpnd11k67xc',
    'type': 'Like',
    'actor': 'https://firefish.social/users/9i761tefz4uyltlz',
    'object': 'https://takahe.shuuji3.xyz/@shuuji3@takahe.shuuji3.xyz/posts/215037658374555952/',
    'content': '😇',
    '@context': [
        'https://www.w3.org/ns/activitystreams',
        'https://w3id.org/security/v1',
        {
            'toot': 'http://joinmastodon.org/ns#',
            'Emoji': 'toot:Emoji',
            'isCat': 'misskey:isCat',
            'value': 'schema:value',
            'vcard': 'http://www.w3.org/2006/vcard/ns#',
            'schema': 'http://schema.org#',
            'Hashtag': 'as:Hashtag',
            'misskey': 'https://misskey-hub.net/ns#',
            'featured': 'toot:featured',
            'fedibird': 'http://fedibird.com/ns#',
            'quoteUri': 'fedibird:quoteUri',
            'quoteUrl': 'as:quoteUrl',
            'sensitive': 'as:sensitive',
            'movedToUri': 'as:movedTo',
            'discoverable': 'toot:discoverable',
            'PropertyValue': 'schema:PropertyValue',
            '_misskey_talk': 'misskey:_misskey_talk',
            '_misskey_quote': 'misskey:_misskey_quote',
            '_misskey_votes': 'misskey:_misskey_votes',
            '_misskey_content':'misskey:_misskey_content',
            '_misskey_reaction': 'misskey:_misskey_reaction',
            'manuallyApprovesFollowers': 'as:manuallyApprovesFollowers'
        },
        'https://w3id.org/security/v1'
    ],
    '_misskey_reaction': '😇'
}

On Firefish

Screenshot 2023-08-19 at 0 34 47

Takahē on Elk

Screenshot 2023-08-18 at 23 26 57

So this issue had already been resolved without any action...?

I agree it's a bit weird to be liked even if it's 👎🏻 reaction. But both UI shows the server icon on a user account if they use a different application with an icon, so at least users can be aware when sending a reaction to Takahē account.

andrewgodwin commented 1 year ago

This ticket was more "actually support emoji reactions" in my mind rather than merely translating them all to Likes (which is what Mastodon does anyway, so :-1: being a star is kind of expected behaviour for most servers!)

AstraLuma commented 1 year ago

Ok, I'm guessing three bits here:

andrewgodwin commented 1 year ago

Yeah - PostInteraction is prepped to accept arbitrary reaction types, so the problem is mostly inbound and outbound comms.

The mastadon API has no way of seeing these reactions or sending them though, so I don't know how important it is (they'll only be visible on the web UI from external sources)

AstraLuma commented 1 year ago

Do we have any example activities of unreacting? Or custom emoji?

AstraLuma commented 1 year ago

The Iceshrimp UI suggests it only supports one reaction per user.

AstraLuma commented 1 year ago

Ok, some example messages (Unicode emoji reactions from iceshrimp):

{
  "id": "https://fediverse.gay/likes/9lv0n6wjz85mpu6p",
  "type": "Like",
  "actor": "https://fediverse.gay/users/9ltneg7gvuorfb2i",
  "object": "https://derez.zone/@astraluma@derez.zone/posts/244939510870121776/",
  "content": "❤️",
  "@context": [
    "https://www.w3.org/ns/activitystreams",
    "https://w3id.org/security/v1",
    {
      "toot": "http://joinmastodon.org/ns#",
      "Emoji": "toot:Emoji",
      "isCat": "misskey:isCat",
      "value": "schema:value",
      "vcard": "http://www.w3.org/2006/vcard/ns#",
      "schema": "http://schema.org#",
      "Hashtag": "as:Hashtag",
      "misskey": "https://misskey-hub.net/ns#",
      "featured": "toot:featured",
      "fedibird": "http://fedibird.com/ns#",
      "quoteUri": "fedibird:quoteUri",
      "quoteUrl": "as:quoteUrl",
      "sensitive": "as:sensitive",
      "movedToUri": "as:movedTo",
      "discoverable": "toot:discoverable",
      "PropertyValue": "schema:PropertyValue",
      "_misskey_talk": "misskey:_misskey_talk",
      "_misskey_quote": "misskey:_misskey_quote",
      "_misskey_votes": "misskey:_misskey_votes",
      "_misskey_content": "misskey:_misskey_content",
      "_misskey_reaction": "misskey:_misskey_reaction",
      "manuallyApprovesFollowers": "as:manuallyApprovesFollowers"
    },
    "https://w3id.org/security/v1"
  ],
  "_misskey_reaction": "❤️"
}
{
  "id": "https://fediverse.gay/likes/9lv0n6wjz85mpu6p/undo",
  "type": "Undo",
  "actor": "https://fediverse.gay/users/9ltneg7gvuorfb2i",
  "object": {
    "id": "https://fediverse.gay/likes/9lv0n6wjz85mpu6p",
    "type": "Like",
    "actor": "https://fediverse.gay/users/9ltneg7gvuorfb2i",
    "object": "https://derez.zone/@astraluma@derez.zone/posts/244939510870121776/",
    "content": "❤️",
    "_misskey_reaction": "❤️"
  },
  "@context": [
    "https://www.w3.org/ns/activitystreams",
    "https://w3id.org/security/v1",
    {
      "toot": "http://joinmastodon.org/ns#",
      "Emoji": "toot:Emoji",
      "isCat": "misskey:isCat",
      "value": "schema:value",
      "vcard": "http://www.w3.org/2006/vcard/ns#",
      "schema": "http://schema.org#",
      "Hashtag": "as:Hashtag",
      "misskey": "https://misskey-hub.net/ns#",
      "featured": "toot:featured",
      "fedibird": "http://fedibird.com/ns#",
      "quoteUri": "fedibird:quoteUri",
      "quoteUrl": "as:quoteUrl",
      "sensitive": "as:sensitive",
      "movedToUri": "as:movedTo",
      "discoverable": "toot:discoverable",
      "PropertyValue": "schema:PropertyValue",
      "_misskey_talk": "misskey:_misskey_talk",
      "_misskey_quote": "misskey:_misskey_quote",
      "_misskey_votes": "misskey:_misskey_votes",
      "_misskey_content": "misskey:_misskey_content",
      "_misskey_reaction": "misskey:_misskey_reaction",
      "manuallyApprovesFollowers": "as:manuallyApprovesFollowers"
    },
    "https://w3id.org/security/v1"
  ],
  "published": "2023-11-09T17:17:56.420Z"
}

I can't actually get the Iceshrimp UI to change a reaction without removing the old one, and I'm unfamiliar with the Misskey client ecosystem. (Using fediverse.gay because firefish.social is being kinda laggy in a not-confidence-inspiring way.)

iacore commented 11 months ago

Calling this "Emoji" Reaction might be a misnomer. The reaction content can be any text, with (misskey extension) emoji replacement.