From 9b046d2a8481c50e244071be1192830e0bbd08bc Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 22 Aug 2018 16:10:59 +0300 Subject: fixed notifications API completely breaking if there's a like for missing (deleted) post. --- lib/pleroma/web/twitter_api/views/activity_view.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index 55b5287f5..0efc0df2e 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -188,7 +188,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do text = "#{user.nickname} favorited a status." - %{ + if liked_activity, do: %{ "id" => activity.id, "user" => UserView.render("show.json", %{user: user, for: opts[:for]}), "statusnet_html" => text, @@ -200,7 +200,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do "in_reply_to_status_id" => liked_activity.id, "external_url" => activity.data["id"], "activity_type" => "like" - } + }, else: %{} end def render( -- cgit v1.2.3 From 83efaa3af6470485c5b47959ea94f7089971e205 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Tue, 7 Aug 2018 22:45:40 +0200 Subject: [MastodonAPI] Add streaming of hashtags --- lib/pleroma/web/activity_pub/activity_pub.ex | 3 +++ lib/pleroma/web/mastodon_api/mastodon_socket.ex | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 68b398786..749ffbcd4 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -84,6 +84,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do Pleroma.Web.Streamer.stream("public:local", activity) end + activity.data["object"]["tag"] + |> Enum.map(fn tag -> Pleroma.Web.Streamer.stream("hashtag:" <> tag, activity) end) + if activity.data["object"]["attachment"] != [] do Pleroma.Web.Streamer.stream("public:media", activity) diff --git a/lib/pleroma/web/mastodon_api/mastodon_socket.ex b/lib/pleroma/web/mastodon_api/mastodon_socket.ex index 174293906..bc628ba56 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_socket.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_socket.ex @@ -23,16 +23,18 @@ defmodule Pleroma.Web.MastodonAPI.MastodonSocket do "public:local:media", "user", "direct", - "list" + "list", + "hashtag" ] <- params["stream"] do topic = if stream == "list", do: "list:#{params["list"]}", else: stream + socket_stream = if stream == "hashtag", do: "hashtag:#{params["tag"]}", else: stream socket = socket |> assign(:topic, topic) |> assign(:user, user) - Pleroma.Web.Streamer.add_socket(params["stream"], socket) + Pleroma.Web.Streamer.add_socket(socket_stream, socket) {:ok, socket} else _e -> :error -- cgit v1.2.3 From 97e20d293266689d57c23abc7ae12ee05996517a Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Tue, 7 Aug 2018 23:49:35 +0200 Subject: =?UTF-8?q?[MastodonAPI]=20the=20tag=20field=20isn=E2=80=99t=20fix?= =?UTF-8?q?ed=20to=20a=20static=20type=20in=20pleroma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pleroma/web/activity_pub/activity_pub.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 749ffbcd4..ed2240530 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -84,7 +84,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do Pleroma.Web.Streamer.stream("public:local", activity) end - activity.data["object"]["tag"] + activity.data["object"] + |> Map.get("tag", []) + |> Enum.filter(fn tag -> is_bitstring(tag) end) |> Enum.map(fn tag -> Pleroma.Web.Streamer.stream("hashtag:" <> tag, activity) end) if activity.data["object"]["attachment"] != [] do -- cgit v1.2.3 From d008f2d69c96616f8d665851994414d1b42f8761 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 10 Aug 2018 01:44:38 +0200 Subject: [Pleroma.Web.MastodonAPI.AccountView]: Add bot field --- lib/pleroma/web/mastodon_api/views/account_view.ex | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex index d9edcae7f..9dd635a63 100644 --- a/lib/pleroma/web/mastodon_api/views/account_view.ex +++ b/lib/pleroma/web/mastodon_api/views/account_view.ex @@ -13,6 +13,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do image = User.avatar_url(user) |> MediaProxy.url() header = User.banner_url(user) |> MediaProxy.url() user_info = User.user_info(user) + bot = (user.info["source_data"]["type"] || "Person") in ["Application", "Service"] emojis = (user.info["source_data"]["tag"] || []) @@ -44,6 +45,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do header_static: header, emojis: emojis, fields: [], + bot: bot, source: %{ note: "", privacy: "public", -- cgit v1.2.3 From a5adb251ab101e7ad1084a772b66b049998c72a5 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 10 Aug 2018 02:41:01 +0200 Subject: [Pleroma.Web.MastodonAPI.AccountView]: Add fields support --- lib/pleroma/web/mastodon_api/views/account_view.ex | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex index 9dd635a63..634985fb6 100644 --- a/lib/pleroma/web/mastodon_api/views/account_view.ex +++ b/lib/pleroma/web/mastodon_api/views/account_view.ex @@ -27,6 +27,11 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do } end) + fields = + (user.info["source_data"]["attachment"] || []) + |> Enum.filter(fn %{"type" => t} -> t == "PropertyValue" end) + |> Enum.map(fn fields -> Map.take(fields, ["name", "value"]) end) + %{ id: to_string(user.id), username: hd(String.split(user.nickname, "@")), @@ -44,7 +49,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do header: header, header_static: header, emojis: emojis, - fields: [], + fields: fields, bot: bot, source: %{ note: "", -- cgit v1.2.3 From 6e030129fb33926e6a5bd75c27af6f657f9da2a5 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Tue, 14 Aug 2018 04:27:28 +0200 Subject: [MastodonAPI] Add filters --- lib/pleroma/filter.ex | 62 ++++++++++++++++++++++ .../web/mastodon_api/mastodon_api_controller.ex | 61 ++++++++++++++++++++- lib/pleroma/web/mastodon_api/views/filter_view.ex | 20 +++++++ lib/pleroma/web/router.ex | 6 +++ 4 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 lib/pleroma/filter.ex create mode 100644 lib/pleroma/web/mastodon_api/views/filter_view.ex (limited to 'lib') diff --git a/lib/pleroma/filter.ex b/lib/pleroma/filter.ex new file mode 100644 index 000000000..fe904df3a --- /dev/null +++ b/lib/pleroma/filter.ex @@ -0,0 +1,62 @@ +defmodule Pleroma.Filter do + use Ecto.Schema + import Ecto.{Changeset, Query} + alias Pleroma.{User, Repo, Activity} + + schema "filters" do + belongs_to(:user, Pleroma.User) + field(:filter_id, :integer) + field(:hide, :boolean, default: false) + field(:whole_word, :boolean, default: true) + field(:phrase, :string) + field(:context, {:array, :string}) + field(:expires_at, :utc_datetime) + + timestamps() + end + + def get(id, %{id: user_id} = _user) do + query = + from( + f in Pleroma.Filter, + where: f.filter_id == ^id, + where: f.user_id == ^user_id + ) + + Repo.one(query) + end + + def get_filters(%Pleroma.User{id: user_id} = user) do + query = + from( + f in Pleroma.Filter, + where: f.user_id == ^user_id + ) + + Repo.all(query) + end + + def create(%Pleroma.Filter{} = filter) do + Repo.insert(filter) + end + + def delete(%Pleroma.Filter{id: filter_key} = filter) when is_number(filter_key) do + Repo.delete(filter) + end + + def delete(%Pleroma.Filter{id: filter_key} = filter) when is_nil(filter_key) do + %Pleroma.Filter{id: id} = get(filter.filter_id, %{id: filter.user_id}) + + filter + |> Map.put(:id, id) + |> Repo.delete() + end + + def update(%Pleroma.Filter{} = filter) do + destination = Map.from_struct(filter) + + Pleroma.Filter.get(filter.filter_id, %{id: filter.user_id}) + |> cast(destination, [:phrase, :context, :hide, :expires_at, :whole_word]) + |> Repo.update() + end +end diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index f482de6fd..649ee033e 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -2,7 +2,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do use Pleroma.Web, :controller alias Pleroma.{Repo, Object, Activity, User, Notification, Stats} alias Pleroma.Web - alias Pleroma.Web.MastodonAPI.{StatusView, AccountView, MastodonView, ListView} + alias Pleroma.Web.MastodonAPI.{StatusView, AccountView, MastodonView, ListView, FilterView} alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.ActivityPub.Utils alias Pleroma.Web.CommonAPI @@ -1089,6 +1089,65 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do end end + def get_filters(%{assigns: %{user: user}} = conn, params) do + filters = Pleroma.Filter.get_filters(user) + res = FilterView.render("filters.json", filters: filters) + json(conn, res) + end + + def create_filter( + %{assigns: %{user: user}} = conn, + %{"phrase" => phrase, "context" => context} = params + ) do + query = %Pleroma.Filter{ + user_id: user.id, + phrase: phrase, + context: context, + hide: Map.get(params, "irreversible", nil), + whole_word: Map.get(params, "boolean", true) + # expires_at + } + + {:ok, response} = Pleroma.Filter.create(query) + res = FilterView.render("filter.json", filter: response) + json(conn, res) + end + + def get_filter(%{assigns: %{user: user}} = conn, %{"id" => filter_id} = params) do + filter = Pleroma.Filter.get(filter_id, user) + res = FilterView.render("filter.json", filter: filter) + json(conn, res) + end + + def update_filter( + %{assigns: %{user: user}} = conn, + %{"phrase" => phrase, "context" => context, "id" => filter_id} = params + ) do + query = %Pleroma.Filter{ + user_id: user.id, + filter_id: filter_id, + phrase: phrase, + context: context, + hide: Map.get(params, "irreversible", nil), + whole_word: Map.get(params, "boolean", true) + # expires_at + } + + {:ok, response} = Pleroma.Filter.update(query) + res = FilterView.render("filter.json", filter: response) + json(conn, res) + end + + def delete_filter(%{assigns: %{user: user}} = conn, %{"id" => filter_id} = params) do + query = %Pleroma.Filter{ + user_id: user.id, + filter_id: filter_id + } + + {:ok, response} = Pleroma.Filter.delete(query) + json(conn, %{}) + end + def errors(conn, _) do conn |> put_status(500) diff --git a/lib/pleroma/web/mastodon_api/views/filter_view.ex b/lib/pleroma/web/mastodon_api/views/filter_view.ex new file mode 100644 index 000000000..3f8c62f24 --- /dev/null +++ b/lib/pleroma/web/mastodon_api/views/filter_view.ex @@ -0,0 +1,20 @@ +defmodule Pleroma.Web.MastodonAPI.FilterView do + use Pleroma.Web, :view + alias Pleroma.Web.MastodonAPI.FilterView + alias Pleroma.Web.CommonAPI.Utils + + def render("filters.json", %{filters: filters} = opts) do + render_many(filters, FilterView, "filter.json", opts) + end + + def render("filter.json", %{filter: filter}) do + %{ + id: to_string(filter.filter_id), + phrase: filter.phrase, + context: filter.context, + expires_at: Utils.to_masto_date(filter.expires_at), + irreversible: filter.hide, + whole_word: false + } + end +end diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 927323794..b212a2909 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -154,6 +154,12 @@ defmodule Pleroma.Web.Router do post("/domain_blocks", MastodonAPIController, :block_domain) delete("/domain_blocks", MastodonAPIController, :unblock_domain) + get("/filters", MastodonAPIController, :get_filters) + post("/filters", MastodonAPIController, :create_filter) + get("/filters/:id", MastodonAPIController, :get_filter) + put("/filters/:id", MastodonAPIController, :update_filter) + delete("/filters/:id", MastodonAPIController, :delete_filter) + get("/suggestions", MastodonAPIController, :suggestions) end -- cgit v1.2.3 From d571a571fe969821923ea26c874c7cd77eec5465 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 10 Aug 2018 04:28:29 +0200 Subject: [Pleroma.Web.MastodonAPI.MastodonAPIController]: Bump mastodon_api_level to 2.4.3 --- lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 649ee033e..b930b002e 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -124,7 +124,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do end @instance Application.get_env(:pleroma, :instance) - @mastodon_api_level "2.3.3" + @mastodon_api_level "2.4.3" def masto_instance(conn, _params) do response = %{ -- cgit v1.2.3 From 9bddb39ff097d527ef71860a1d0498dc57f7cd06 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Tue, 21 Aug 2018 19:45:58 +0200 Subject: [Pleroma.Web.MastodonAPI.FilterView]: expires_at should be null when N/A --- lib/pleroma/web/mastodon_api/views/filter_view.ex | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/mastodon_api/views/filter_view.ex b/lib/pleroma/web/mastodon_api/views/filter_view.ex index 3f8c62f24..e8401cc2d 100644 --- a/lib/pleroma/web/mastodon_api/views/filter_view.ex +++ b/lib/pleroma/web/mastodon_api/views/filter_view.ex @@ -8,11 +8,17 @@ defmodule Pleroma.Web.MastodonAPI.FilterView do end def render("filter.json", %{filter: filter}) do + if filter.expires_at do + expires_at = Utils.to_masto_date(filter.expires_at) + else + expires_at = nil + end + %{ id: to_string(filter.filter_id), phrase: filter.phrase, context: filter.context, - expires_at: Utils.to_masto_date(filter.expires_at), + expires_at: expires_at, irreversible: filter.hide, whole_word: false } -- cgit v1.2.3 From 6973b77e9462475361772907ddd690a960041b64 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Tue, 21 Aug 2018 20:35:14 +0200 Subject: [Pleroma.Web.MastodonAPI.FilterView] fix expires_at being a unsafe variable --- lib/pleroma/web/mastodon_api/views/filter_view.ex | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/mastodon_api/views/filter_view.ex b/lib/pleroma/web/mastodon_api/views/filter_view.ex index e8401cc2d..6bd687d46 100644 --- a/lib/pleroma/web/mastodon_api/views/filter_view.ex +++ b/lib/pleroma/web/mastodon_api/views/filter_view.ex @@ -8,11 +8,12 @@ defmodule Pleroma.Web.MastodonAPI.FilterView do end def render("filter.json", %{filter: filter}) do - if filter.expires_at do - expires_at = Utils.to_masto_date(filter.expires_at) - else - expires_at = nil - end + expires_at = + if filter.expires_at do + Utils.to_masto_date(filter.expires_at) + else + nil + end %{ id: to_string(filter.filter_id), -- cgit v1.2.3 From 0f1c629d657f569058c36fb0f0c7855a261d5257 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 27 Aug 2018 17:07:26 +0300 Subject: better solution, added test. --- lib/pleroma/web/twitter_api/views/activity_view.ex | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/twitter_api/views/activity_view.ex b/lib/pleroma/web/twitter_api/views/activity_view.ex index 0efc0df2e..909eefdd8 100644 --- a/lib/pleroma/web/twitter_api/views/activity_view.ex +++ b/lib/pleroma/web/twitter_api/views/activity_view.ex @@ -181,6 +181,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do def render("activity.json", %{activity: %{data: %{"type" => "Like"}} = activity} = opts) do user = get_user(activity.data["actor"], opts) liked_activity = Activity.get_create_activity_by_object_ap_id(activity.data["object"]) + liked_activity_id = if liked_activity, do: liked_activity.id, else: nil created_at = activity.data["published"] @@ -188,7 +189,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do text = "#{user.nickname} favorited a status." - if liked_activity, do: %{ + %{ "id" => activity.id, "user" => UserView.render("show.json", %{user: user, for: opts[:for]}), "statusnet_html" => text, @@ -197,10 +198,10 @@ defmodule Pleroma.Web.TwitterAPI.ActivityView do "is_post_verb" => false, "uri" => "tag:#{activity.data["id"]}:objectType=Favourite", "created_at" => created_at, - "in_reply_to_status_id" => liked_activity.id, + "in_reply_to_status_id" => liked_activity_id, "external_url" => activity.data["id"], "activity_type" => "like" - }, else: %{} + } end def render( -- cgit v1.2.3 From a9c0f395cb4d854e552a3205cb5b38ff610f8e27 Mon Sep 17 00:00:00 2001 From: Thurloat Date: Fri, 31 Aug 2018 14:28:39 -0300 Subject: add nil clause for Formatter.get_emoji/1 to return an empty result --- lib/pleroma/formatter.ex | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex index cf2944c38..fc2c643da 100644 --- a/lib/pleroma/formatter.ex +++ b/lib/pleroma/formatter.ex @@ -157,6 +157,8 @@ defmodule Pleroma.Formatter do end) end + def get_emoji(nil), do: [] + def get_emoji(text) do Enum.filter(@emoji, fn {emoji, _} -> String.contains?(text, ":#{emoji}:") end) end -- cgit v1.2.3 From 4257f784bc8e742888e978fccbab0f566c549376 Mon Sep 17 00:00:00 2001 From: Thurloat Date: Sun, 2 Sep 2018 20:44:37 -0300 Subject: sloop around get_emoji/1 to check is_binary and have a fallthrough default that returns empty --- lib/pleroma/formatter.ex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex index fc2c643da..e5ccc7a49 100644 --- a/lib/pleroma/formatter.ex +++ b/lib/pleroma/formatter.ex @@ -157,12 +157,12 @@ defmodule Pleroma.Formatter do end) end - def get_emoji(nil), do: [] - - def get_emoji(text) do + def get_emoji(text) when is_binary(text) do Enum.filter(@emoji, fn {emoji, _} -> String.contains?(text, ":#{emoji}:") end) end + def get_emoji(_), do: [] + def get_custom_emoji() do @emoji end -- cgit v1.2.3 From 2b2bd0e047c96085dda003f0ae11ddc05bbc8c12 Mon Sep 17 00:00:00 2001 From: shadowfacts Date: Mon, 3 Sep 2018 01:40:05 +0000 Subject: Render notification IDs as strings, not numbers --- lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index e0267f1dc..b3c234010 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -1033,7 +1033,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do case activity.data["type"] do "Create" -> %{ - id: id, + id: id |> to_string, type: "mention", created_at: created_at, account: AccountView.render("account.json", %{user: actor}), @@ -1044,7 +1044,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do liked_activity = Activity.get_create_activity_by_object_ap_id(activity.data["object"]) %{ - id: id, + id: id |> to_string, type: "favourite", created_at: created_at, account: AccountView.render("account.json", %{user: actor}), @@ -1055,7 +1055,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do announced_activity = Activity.get_create_activity_by_object_ap_id(activity.data["object"]) %{ - id: id, + id: id |> to_string, type: "reblog", created_at: created_at, account: AccountView.render("account.json", %{user: actor}), @@ -1064,7 +1064,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do "Follow" -> %{ - id: id, + id: id |> to_string, type: "follow", created_at: created_at, account: AccountView.render("account.json", %{user: actor}) -- cgit v1.2.3 From 26f8697400cf9c9fd4d33748bf3aadedbb55d981 Mon Sep 17 00:00:00 2001 From: shadowfacts Date: Mon, 3 Sep 2018 01:52:02 +0000 Subject: Update mastodon_api_controller.ex --- lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index b3c234010..576e9d3ce 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -1029,11 +1029,13 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do created_at = NaiveDateTime.to_iso8601(created_at) |> String.replace(~r/(\.\d+)?$/, ".000Z", global: false) + + id = id |> to_string case activity.data["type"] do "Create" -> %{ - id: id |> to_string, + id: id, type: "mention", created_at: created_at, account: AccountView.render("account.json", %{user: actor}), @@ -1044,7 +1046,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do liked_activity = Activity.get_create_activity_by_object_ap_id(activity.data["object"]) %{ - id: id |> to_string, + id: id, type: "favourite", created_at: created_at, account: AccountView.render("account.json", %{user: actor}), @@ -1055,7 +1057,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do announced_activity = Activity.get_create_activity_by_object_ap_id(activity.data["object"]) %{ - id: id |> to_string, + id: id, type: "reblog", created_at: created_at, account: AccountView.render("account.json", %{user: actor}), @@ -1064,7 +1066,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do "Follow" -> %{ - id: id |> to_string, + id: id, type: "follow", created_at: created_at, account: AccountView.render("account.json", %{user: actor}) -- cgit v1.2.3 From 35515cfa66f39d618be5702137d296b7bc25b65e Mon Sep 17 00:00:00 2001 From: shadowfacts Date: Mon, 3 Sep 2018 01:58:55 +0000 Subject: Update mastodon_api_controller.ex --- lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 576e9d3ce..8279db93e 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -1029,7 +1029,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do created_at = NaiveDateTime.to_iso8601(created_at) |> String.replace(~r/(\.\d+)?$/, ".000Z", global: false) - + id = id |> to_string case activity.data["type"] do -- cgit v1.2.3 From b1124f1605717ec841d3693745536e49bdadd8c5 Mon Sep 17 00:00:00 2001 From: Hakaba Hitoyo Date: Mon, 3 Sep 2018 21:13:30 +0900 Subject: report chat and gopher support at /nodeinfo/2.0.json --- lib/pleroma/web/nodeinfo/nodeinfo_controller.ex | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex index 2fab60274..9155e42cd 100644 --- a/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex +++ b/lib/pleroma/web/nodeinfo/nodeinfo_controller.ex @@ -22,6 +22,8 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do instance = Application.get_env(:pleroma, :instance) media_proxy = Application.get_env(:pleroma, :media_proxy) suggestions = Application.get_env(:pleroma, :suggestions) + chat = Application.get_env(:pleroma, :chat) + gopher = Application.get_env(:pleroma, :gopher) stats = Stats.get_stats() response = %{ @@ -52,7 +54,9 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do thirdPartyEngine: Keyword.get(suggestions, :third_party_engine, ""), timeout: Keyword.get(suggestions, :timeout, 5000), web: Keyword.get(suggestions, :web, "") - } + }, + chat: Keyword.get(chat, :enabled), + gopher: Keyword.get(gopher, :enabled) } } -- cgit v1.2.3