Allow authoring MFM
authorFloatingGhost <hannah@coffee-and-dreams.uk>
Tue, 14 Jun 2022 14:56:12 +0000 (15:56 +0100)
committerFloatingGhost <hannah@coffee-and-dreams.uk>
Tue, 14 Jun 2022 14:56:12 +0000 (15:56 +0100)
config/config.exs
lib/pleroma/emoji.ex
lib/pleroma/web/common_api/activity_draft.ex
lib/pleroma/web/common_api/utils.ex

index 417f298d702836cb959bb0af84c408feb7b482f5..ad70966692b8d861e9a8b007178b908a2a808bf8 100644 (file)
@@ -222,7 +222,8 @@ config :pleroma, :instance,
     "text/plain",
     "text/html",
     "text/markdown",
-    "text/bbcode"
+    "text/bbcode",
+    "text/x.misskeymarkdown"
   ],
   staff_transparency: [],
   autofollowed_nicknames: [],
index f4043ac80b9d317ab6c39369b5d7cc69cd74ecdf..9e1858ae73308ae333b293af7a999e07a8ceaaa2 100644 (file)
@@ -165,7 +165,7 @@ defmodule Pleroma.Emoji do
 
   def maybe_quote(name), do: name
 
-  def emoji_url(%{"type" => "EmojiReact", "content" => emoji, "tag" => []}), do: nil
+  def emoji_url(%{"type" => "EmojiReact", "content" => _, "tag" => []}), do: nil
 
   def emoji_url(%{"type" => "EmojiReact", "content" => emoji, "tag" => tags}) do
     tag =
index b4e3e37aec3bff82db68577af9a768a690dad18d..08e704ed4b9b844ee61a27c5e03fd388967e778f 100644 (file)
@@ -213,13 +213,14 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
       end
 
     emoji = Map.merge(emoji, summary_emoji)
-
     {:ok, note_data, _meta} = Builder.note(draft)
-
     object =
       note_data
       |> Map.put("emoji", emoji)
-      |> Map.put("source", draft.status)
+      |> Map.put("source", %{
+        "content" => draft.status,
+        "mediaType" => draft.params[:content_type]
+      })
       |> Map.put("generator", draft.params[:generator])
 
     %__MODULE__{draft | object: object}
index b6feaf32a6304ac66a37690838cbeb531a27e85a..8fde9ae156efb615addc05c51e2bbb10718382a6 100644 (file)
@@ -291,6 +291,15 @@ defmodule Pleroma.Web.CommonAPI.Utils do
     |> Formatter.html_escape("text/html")
   end
 
+  def format_input(text, "text/x.misskeymarkdown", options) do
+    text
+    |> Formatter.html_escape("text/plain")
+    |> Formatter.linkify(options)
+    |> (fn {text, mentions, tags} ->
+          {String.replace(text, ~r/\r?\n/, "<br>"), mentions, tags}
+        end).()
+  end
+
   def format_naive_asctime(date) do
     date |> DateTime.from_naive!("Etc/UTC") |> format_asctime
   end