[#58] pre-link MFM content #59

Merged
floatingghost merged 5 commits from prelink-mfm into develop 2022-07-10 17:06:26 +00:00

when misskey sends us a message, it gives us two different representations - the "federatable mfm" that misskey itself generates, this is a basic markdown-parsed HTML string which shows mfm formatting as italics

the other is either in the _misskey_content (deprecated) or source fields, and is the raw MFM source

this PR pre-parses the raw content and links mentions/hashtags/etc

when misskey sends us a message, it gives us two different representations - the "federatable mfm" that misskey itself generates, this is a basic markdown-parsed HTML string which shows mfm formatting as italics the other is either in the `_misskey_content` (deprecated) or `source` fields, and is the raw MFM source this PR pre-parses the raw content and links mentions/hashtags/etc
floatingghost added 4 commits 2022-07-10 16:23:28 +00:00
ci/woodpecker/push/release Pipeline was successful Details
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/test Pipeline failed Details
705a8a1fe9
pre-link MFM content
ci/woodpecker/push/release Pipeline was successful Details
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/pr/release Pipeline was successful Details
ci/woodpecker/pr/lint Pipeline was successful Details
ci/woodpecker/push/test Pipeline failed Details
ci/woodpecker/pr/test Pipeline failed Details
838b025337
fix typo
Contributor

dumb question, this is also going to do the same for MFM messages sent by akkoma, right?

dumb question, this is also going to do the same for MFM messages sent by akkoma, right?
Author
Owner

hm we probably should, shouldn't we

also seeing how that interacts with stuf

hm we probably should, shouldn't we also seeing how that interacts with stuf
Author
Owner

ok change of plan

{
  "account": "...",
  "content": "<processed by linker mfm>",
  "akkoma": {
    "source": {
      "content": "raw $[mfm] unlinked",
      "mediaType": "text/x.misskeymarkdown"
    }
  }
}

apparently source shouldn't contain anything like html, so we're going to throw out the silly html misskey generates and use our own, which i think was the initial suggestion

ok change of plan ```json { "account": "...", "content": "<processed by linker mfm>", "akkoma": { "source": { "content": "raw $[mfm] unlinked", "mediaType": "text/x.misskeymarkdown" } } } ``` apparently source shouldn't contain anything like html, so we're going to throw out the silly html misskey generates and use our own, which i think was the initial suggestion
Author
Owner

final AP format:

 {
  "actor": "https://akkoma.local.live/users/akkoma_user",
  "attachment": [],
  "attributedTo": "https://akkoma.local.live/users/akkoma_user",
  "cc": [
    "https://akkoma.local.live/users/akkoma_user/followers"
  ],
  "content": "<span class=\"h-card\"><a class=\"u-url mention\" data-user=\"ALKPkorAW5uljzcsMK\" href=\"https://misskey.local.live/@mmm_user\" rel=\"ugc\">@<span>mmm_user</span></a></span> $[mfm here] LINK",
  "context": "https://akkoma.local.live/contexts/d048e2c0-b900-46c0-8d12-e6df5c93844d",
  "conversation": "https://akkoma.local.live/contexts/d048e2c0-b900-46c0-8d12-e6df5c93844d",
  "id": "https://akkoma.local.live/objects/00d168db-4878-465f-836d-e5fbdc75e8c3",
  "published": "2022-07-10T16:45:24.395222Z",
  "sensitive": null,
  "source": {
    "content": "@mmm_user@misskey.local.live $[mfm here] LINK",
    "mediaType": "text/x.misskeymarkdown"
  },
  "summary": "",
  "tag": [
    {
      "href": "https://misskey.local.live/users/92hzkskwgy",
      "name": "@mmm_user@misskey.local.live",
      "type": "Mention"
    }
  ],
  "to": [
    "https://www.w3.org/ns/activitystreams#Public",
    "https://misskey.local.live/users/92hzkskwgy"
  ],
  "type": "Note"
}

this is converted to

{
  "account": {
    ...
  },
  "akkoma": {
    "source": {
      "content": "@mmm_user@misskey.local.live $[mfm here] LINK",
      "mediaType": "text/x.misskeymarkdown"
    }
  },
  "application": {
    "name": "PleromaFE_36309ebe\r\n_2022-06-30T13:34:19.062Z",
    "website": null
  },
  "bookmarked": false,
  "card": null,
  "content": "<span class=\"h-card\"><a class=\"u-url mention\" data-user=\"ALKPkorAW5uljzcsMK\" href=\"https://misskey.local.live/@mmm_user\" rel=\"ugc\">@<span>mmm_user</span></a></span> $[mfm here] LINK"

}

on the mastoAPI call

final AP format: ```json { "actor": "https://akkoma.local.live/users/akkoma_user", "attachment": [], "attributedTo": "https://akkoma.local.live/users/akkoma_user", "cc": [ "https://akkoma.local.live/users/akkoma_user/followers" ], "content": "<span class=\"h-card\"><a class=\"u-url mention\" data-user=\"ALKPkorAW5uljzcsMK\" href=\"https://misskey.local.live/@mmm_user\" rel=\"ugc\">@<span>mmm_user</span></a></span> $[mfm here] LINK", "context": "https://akkoma.local.live/contexts/d048e2c0-b900-46c0-8d12-e6df5c93844d", "conversation": "https://akkoma.local.live/contexts/d048e2c0-b900-46c0-8d12-e6df5c93844d", "id": "https://akkoma.local.live/objects/00d168db-4878-465f-836d-e5fbdc75e8c3", "published": "2022-07-10T16:45:24.395222Z", "sensitive": null, "source": { "content": "@mmm_user@misskey.local.live $[mfm here] LINK", "mediaType": "text/x.misskeymarkdown" }, "summary": "", "tag": [ { "href": "https://misskey.local.live/users/92hzkskwgy", "name": "@mmm_user@misskey.local.live", "type": "Mention" } ], "to": [ "https://www.w3.org/ns/activitystreams#Public", "https://misskey.local.live/users/92hzkskwgy" ], "type": "Note" } ``` this is converted to ```json { "account": { ... }, "akkoma": { "source": { "content": "@mmm_user@misskey.local.live $[mfm here] LINK", "mediaType": "text/x.misskeymarkdown" } }, "application": { "name": "PleromaFE_36309ebe\r\n_2022-06-30T13:34:19.062Z", "website": null }, "bookmarked": false, "card": null, "content": "<span class=\"h-card\"><a class=\"u-url mention\" data-user=\"ALKPkorAW5uljzcsMK\" href=\"https://misskey.local.live/@mmm_user\" rel=\"ugc\">@<span>mmm_user</span></a></span> $[mfm here] LINK" } ``` on the mastoAPI call
floatingghost added 1 commit 2022-07-10 16:47:36 +00:00
ci/woodpecker/push/release Pipeline was successful Details
ci/woodpecker/pr/release Pipeline was successful Details
ci/woodpecker/pr/lint Pipeline was successful Details
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/test Pipeline failed Details
ci/woodpecker/pr/test Pipeline was successful Details
e71a7893ec
only link in `content` field
floatingghost merged commit 5ad256f170 into develop 2022-07-10 17:06:26 +00:00
floatingghost deleted branch prelink-mfm 2022-07-10 17:06:26 +00:00
Contributor

o, noticed a bug
when a misskey user tags a user on the same instance it doesn't tag it
because this searches for that mention on our instance

o, noticed a bug when a misskey user tags a user on the same instance it doesn't tag it because this searches for that mention on our instance
Author
Owner

interdasting, i'll see if i can replicate
suffering :angery:

interdasting, i'll see if i can replicate suffering :angery:
Author
Owner

well fixing THAT was a pain in the bum let me tell you

well fixing _THAT_ was a pain in the bum let me tell you
Sign in to join this conversation.
No description provided.