Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly parse Misskey object emoji format #1816

Merged

Conversation

dastardlylemon
Copy link
Contributor

I noticed that while Megalodon assumes that Misskey emojis come down in an array, in my testing, they have the same format as the reactionEmojis: that is to say, an object of key (shortcode) value (url) pairs. This change uses the same logic as for mapping emoji reactions to generate the emojis list.

I don't know if older versions of Misskey presented the emojis field as an array, so I've kept in the old logic for backwards compatibility. Both instances I tested on (misskey.io and misskey.design) exhibited the new behavior.

curl -d '{"i": $MISSKEY_ACCESS_KEY }' -H "Content-Type: application/json" -X POST https://misskey.design/api/notes/timeline

[
    {
        "id": "9hcg3rd24h",
        "createdAt": "2023-07-18T22:43:39.974Z",
        "userId": "9ccl3jbs6i",
        "user": {
            "id": "9ccl3jbs6i",
            "name": "望月ハル:skeb::verified_blue:",
            "username": "haltaro3",
            "host": "misskey.io",
            "avatarUrl": "https://misskey.design/proxy/avatar.webp?url=https%3A%2F%2Ffile.misskey.design%2Fpost%2F393a162a-61bb-46ed-b889-15d026be0e83.png&avatar=1",
            "avatarBlurhash": "ePQJAuRiI:D%.7~qs:smxuRQo}bIt7xuMx?Ht7WBspSzD*ayt6axxa",
            "isBot": false,
            "isCat": false,
            "instance": {
                "name": "Misskey.io",
                "softwareName": "misskey",
                "softwareVersion": "13.13.2",
                "iconUrl": "https://misskey.io/static-assets/icons/192.png",
                "faviconUrl": "https://s3.arkjp.net/misskey/webpublic-0c66b1ca-b8c0-4eaa-9827-47674f4a1580.png",
                "themeColor": "#86b300"
            },
            "emojis": {
                "skeb": "https://s3.arkjp.net/misskey/03e01164-c5f3-42e4-9c70-1619fef7f076.png",
                "verified_blue": "https://s3.arkjp.net/emoji/verified_blue.png"
            },
            "onlineStatus": "unknown"
        },
        "text": "ダンボールの山減らす作業しなきゃ:blobcozynap:",
        "cw": null,
        "visibility": "public",
        "localOnly": false,
        "reactionAcceptance": null,
        "renoteCount": 0,
        "repliesCount": 0,
        "reactions": {
            ":blobhai@misskey.io:": 1,
            ":super_igyo@misskey.io:": 9
        },
        "reactionEmojis": {
            "blobhai@misskey.io": "https://s3.arkjp.net/emoji/blobhai.gif",
            "super_igyo@misskey.io": "https://s3.arkjp.net/misskey/4ad1e9a6-9744-4a92-89bf-fac1ad3e7a65.png"
        },
        "emojis": {
            "blobcozynap": "https://s3.arkjp.net/emoji/blobcozynap.png"
        },
        "fileIds": [],
        "files": [],
        "replyId": null,
        "renoteId": null,
        "uri": "https://misskey.io/notes/9hcg3rd2uu"
    },
...
]

The emojis field is not mentioned at all in the API docs, so I don't have a source of truth other than my test requests.

@dastardlylemon dastardlylemon requested a review from h3poteto as a code owner July 18, 2023 23:59
@h3poteto
Copy link
Owner

I'm wondering when emojis field is filled. In my timeline, the field is always empty.

[
  {
    "id": "9hgx7auyzu",
    "createdAt": "2023-07-22T01:53:23.386Z",
    "userId": "7rl99pkppb",
    "user": {
      "id": "7rl99pkppb",
      "name": "h3poteto",
      "username": "h3poteto",
      "host": "pleroma.io",
      "avatarUrl": "https://proxy.misskeyusercontent.com/avatar.webp?url=https%3A%2F%2Fpleroma.io%2Fmedia%2F0dc2c5ad4b8416469a14570d7f2ccbf74c87b26a46ecd3728b0731bee763be9a.blob&avatar=1",
      "avatarBlurhash": "yNKC000[0F;]r==qXUEUr;r;kXofjYWBI^rqxBT0WAW?n$0;$xxuwZocOGRkIrxYjES$bbV@ofXUaengW?oIayoL9xxY$}NHR*bdsl",
      "isBot": false,
      "isCat": false,
      "instance": {
        "name": "Pleroma.io",
        "softwareName": "pleroma",
        "softwareVersion": "2.5.1-0-gdea5476",
        "iconUrl": "https://pleroma.io/static/logo.svg",
        "faviconUrl": "https://pleroma.io/favicon.png",
        "themeColor": "#282c37"
      },
      "emojis": {},
      "onlineStatus": "unknown"
    },
    "text": "ゆれてる?",
    "cw": null,
    "visibility": "public",
    "localOnly": false,
    "reactionAcceptance": null,
    "renoteCount": 0,
    "repliesCount": 0,
    "reactions": {},
    "reactionEmojis": {},
    "emojis": {},
    "fileIds": [],
    "files": [],
    "replyId": null,
    "renoteId": null,
    "uri": "https://pleroma.io/objects/c258b946-f5d1-451c-b41c-d221438461a2"
  },
  {
    "id": "9hgu9n3a02",
    "createdAt": "2023-07-22T00:31:13.702Z",
    "userId": "7rl99pkppb",
    "user": {
      "id": "7rl99pkppb",
      "name": "h3poteto",
      "username": "h3poteto",
      "host": "pleroma.io",
      "avatarUrl": "https://proxy.misskeyusercontent.com/avatar.webp?url=https%3A%2F%2Fpleroma.io%2Fmedia%2F0dc2c5ad4b8416469a14570d7f2ccbf74c87b26a46ecd3728b0731bee763be9a.blob&avatar=1",
      "avatarBlurhash": "yNKC000[0F;]r==qXUEUr;r;kXofjYWBI^rqxBT0WAW?n$0;$xxuwZocOGRkIrxYjES$bbV@ofXUaengW?oIayoL9xxY$}NHR*bdsl",
      "isBot": false,
      "isCat": false,
      "instance": {
        "name": "Pleroma.io",
        "softwareName": "pleroma",
        "softwareVersion": "2.5.1-0-gdea5476",
        "iconUrl": "https://pleroma.io/static/logo.svg",
        "faviconUrl": "https://pleroma.io/favicon.png",
        "themeColor": "#282c37"
      },
      "emojis": {},
      "onlineStatus": "unknown"
    },
    "text": "熱は下がってきたけど,喉がひどい",
    "cw": null,
    "visibility": "public",
    "localOnly": false,
    "reactionAcceptance": null,
    "renoteCount": 0,
    "repliesCount": 0,
    "reactions": {
      ":meowbongopat@misskey.social:": 1
    },
    "reactionEmojis": {
      "meowbongopat@misskey.social": "https://misskey.social/files/f723dfeb-ee52-4057-8096-99d4a49a12a6"
    },
    "emojis": {},
    "fileIds": [],
    "files": [],
    "replyId": null,
    "renoteId": null,
    "uri": "https://pleroma.io/objects/213f647b-4218-413d-adfc-83ce323d1caf"
  },

@dastardlylemon
Copy link
Contributor Author

I don't know if Pleroma uses this field, but Misskey populates it whenever the user has custom emojis in their username or bio, or if the note itself has custom emojis. (reactions are separate and used only for the reaction emojis, not related to the note itself)

@h3poteto h3poteto merged commit 5bc1a78 into h3poteto:master Jul 27, 2023
@dastardlylemon dastardlylemon deleted the jw-fix-misskey-emoji-conversion branch July 27, 2023 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants