Merge branch 'develop' into feature/tag_feed
This commit is contained in:
commit
055edd3d72
|
@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- **Breaking:** Elixir >=1.8 is now required (was >= 1.7)
|
- **Breaking:** Elixir >=1.8 is now required (was >= 1.7)
|
||||||
- **Breaking:** attachment links (`config :pleroma, :instance, no_attachment_links` and `config :pleroma, Pleroma.Upload, link_name`) disabled by default
|
- **Breaking:** attachment links (`config :pleroma, :instance, no_attachment_links` and `config :pleroma, Pleroma.Upload, link_name`) disabled by default
|
||||||
- **Breaking:** OAuth: defaulted `[:auth, :enforce_oauth_admin_scope_usage]` setting to `true` which demands `admin` OAuth scope to perform admin actions (in addition to `is_admin` flag on User); make sure to use bundled or newer versions of AdminFE & PleromaFE to access admin / moderator features.
|
- **Breaking:** OAuth: defaulted `[:auth, :enforce_oauth_admin_scope_usage]` setting to `true` which demands `admin` OAuth scope to perform admin actions (in addition to `is_admin` flag on User); make sure to use bundled or newer versions of AdminFE & PleromaFE to access admin / moderator features.
|
||||||
|
- **Breaking:** Dynamic configuration has been rearchitected. The `:pleroma, :instance, dynamic_configuration` setting has been replaced with `config :pleroma, configurable_from_database`. Please backup your configuration to a file and run the migration task to ensure consistency with the new schema.
|
||||||
- Replaced [pleroma_job_queue](https://git.pleroma.social/pleroma/pleroma_job_queue) and `Pleroma.Web.Federator.RetryQueue` with [Oban](https://github.com/sorentwo/oban) (see [`docs/config.md`](docs/config.md) on migrating customized worker / retry settings)
|
- Replaced [pleroma_job_queue](https://git.pleroma.social/pleroma/pleroma_job_queue) and `Pleroma.Web.Federator.RetryQueue` with [Oban](https://github.com/sorentwo/oban) (see [`docs/config.md`](docs/config.md) on migrating customized worker / retry settings)
|
||||||
- Introduced [quantum](https://github.com/quantum-elixir/quantum-core) job scheduler
|
- Introduced [quantum](https://github.com/quantum-elixir/quantum-core) job scheduler
|
||||||
- Enabled `:instance, extended_nickname_format` in the default config
|
- Enabled `:instance, extended_nickname_format` in the default config
|
||||||
|
@ -98,6 +99,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Mastodon API: Add `emoji_reactions` property to Statuses
|
- Mastodon API: Add `emoji_reactions` property to Statuses
|
||||||
- Mastodon API: Change emoji reaction reply format
|
- Mastodon API: Change emoji reaction reply format
|
||||||
- Notifications: Added `pleroma:emoji_reaction` notification type
|
- Notifications: Added `pleroma:emoji_reaction` notification type
|
||||||
|
- Mastodon API: Change emoji reaction reply format once more
|
||||||
- Configuration: `feed.logo` option for tag feed.
|
- Configuration: `feed.logo` option for tag feed.
|
||||||
- Tag feed: `/tags/:tag.rss` - list public statuses by hashtag.
|
- Tag feed: `/tags/:tag.rss` - list public statuses by hashtag.
|
||||||
</details>
|
</details>
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
key: :uploader,
|
key: :uploader,
|
||||||
type: :module,
|
type: :module,
|
||||||
description: "Module which will be used for uploads",
|
description: "Module which will be used for uploads",
|
||||||
suggestions: [Pleroma.Uploaders.Local, Pleroma.Uploaders.MDII, Pleroma.Uploaders.S3]
|
suggestions: [Pleroma.Uploaders.Local, Pleroma.Uploaders.S3]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :filters,
|
key: :filters,
|
||||||
|
@ -515,6 +515,7 @@
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :email,
|
key: :email,
|
||||||
|
label: "Admin Email Address",
|
||||||
type: :string,
|
type: :string,
|
||||||
description: "Email used to reach an Administrator/Moderator of the instance",
|
description: "Email used to reach an Administrator/Moderator of the instance",
|
||||||
suggestions: [
|
suggestions: [
|
||||||
|
@ -523,8 +524,9 @@
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :notify_email,
|
key: :notify_email,
|
||||||
|
label: "Sender Email Address",
|
||||||
type: :string,
|
type: :string,
|
||||||
description: "Email used for notifications",
|
description: "Envelope FROM address for mail sent via Pleroma",
|
||||||
suggestions: [
|
suggestions: [
|
||||||
"notify@example.com"
|
"notify@example.com"
|
||||||
]
|
]
|
||||||
|
|
|
@ -29,7 +29,7 @@ Has these additional fields under the `pleroma` object:
|
||||||
- `spoiler_text`: a map consisting of alternate representations of the `spoiler_text` property with the key being it's mimetype. Currently the only alternate representation supported is `text/plain`
|
- `spoiler_text`: a map consisting of alternate representations of the `spoiler_text` property with the key being it's mimetype. Currently the only alternate representation supported is `text/plain`
|
||||||
- `expires_at`: a datetime (iso8601) that states when the post will expire (be deleted automatically), or empty if the post won't expire
|
- `expires_at`: a datetime (iso8601) that states when the post will expire (be deleted automatically), or empty if the post won't expire
|
||||||
- `thread_muted`: true if the thread the post belongs to is muted
|
- `thread_muted`: true if the thread the post belongs to is muted
|
||||||
- `emoji_reactions`: A list with emoji / reaction count tuples. Contains no information about the reacting users, for that use the `emoji_reactions_by` endpoint.
|
- `emoji_reactions`: A list with emoji / reaction maps. The format is {emoji: "☕", count: 1}. Contains no information about the reacting users, for that use the `emoji_reactions_by` endpoint.
|
||||||
|
|
||||||
## Attachments
|
## Attachments
|
||||||
|
|
||||||
|
|
|
@ -455,7 +455,7 @@ Emoji reactions work a lot like favourites do. They make it possible to react to
|
||||||
* Example Response:
|
* Example Response:
|
||||||
```json
|
```json
|
||||||
[
|
[
|
||||||
["😀", [{"id" => "xyz.."...}, {"id" => "zyx..."}]],
|
{"emoji": "😀", "count": 2, "accounts": [{"id" => "xyz.."...}, {"id" => "zyx..."}]},
|
||||||
["☕", [{"id" => "abc..."}]]
|
{"emoji": "☕", "count": 1, "accounts": [{"id" => "abc..."}]}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
|
@ -236,15 +236,7 @@ def from_binary_with_convert(binary) do
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec from_string(String.t()) :: atom() | no_return()
|
@spec from_string(String.t()) :: atom() | no_return()
|
||||||
def from_string(":" <> entity), do: String.to_existing_atom(entity)
|
def from_string(string), do: do_transform_string(string)
|
||||||
|
|
||||||
def from_string(entity) when is_binary(entity) do
|
|
||||||
if is_module_name?(entity) do
|
|
||||||
String.to_existing_atom("Elixir.#{entity}")
|
|
||||||
else
|
|
||||||
entity
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@spec convert(any()) :: any()
|
@spec convert(any()) :: any()
|
||||||
def convert(entity), do: do_convert(entity)
|
def convert(entity), do: do_convert(entity)
|
||||||
|
|
|
@ -337,7 +337,7 @@ def add_emoji_reaction_to_object(
|
||||||
%Activity{data: %{"content" => emoji, "actor" => actor}},
|
%Activity{data: %{"content" => emoji, "actor" => actor}},
|
||||||
object
|
object
|
||||||
) do
|
) do
|
||||||
reactions = object.data["reactions"] || []
|
reactions = get_cached_emoji_reactions(object)
|
||||||
|
|
||||||
new_reactions =
|
new_reactions =
|
||||||
case Enum.find_index(reactions, fn [candidate, _] -> emoji == candidate end) do
|
case Enum.find_index(reactions, fn [candidate, _] -> emoji == candidate end) do
|
||||||
|
@ -365,7 +365,7 @@ def remove_emoji_reaction_from_object(
|
||||||
%Activity{data: %{"content" => emoji, "actor" => actor}},
|
%Activity{data: %{"content" => emoji, "actor" => actor}},
|
||||||
object
|
object
|
||||||
) do
|
) do
|
||||||
reactions = object.data["reactions"] || []
|
reactions = get_cached_emoji_reactions(object)
|
||||||
|
|
||||||
new_reactions =
|
new_reactions =
|
||||||
case Enum.find_index(reactions, fn [candidate, _] -> emoji == candidate end) do
|
case Enum.find_index(reactions, fn [candidate, _] -> emoji == candidate end) do
|
||||||
|
@ -385,6 +385,14 @@ def remove_emoji_reaction_from_object(
|
||||||
update_element_in_object("reaction", new_reactions, object, count)
|
update_element_in_object("reaction", new_reactions, object, count)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_cached_emoji_reactions(object) do
|
||||||
|
if is_list(object.data["reactions"]) do
|
||||||
|
object.data["reactions"]
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@spec add_like_to_object(Activity.t(), Object.t()) ::
|
@spec add_like_to_object(Activity.t(), Object.t()) ::
|
||||||
{:ok, Object.t()} | {:error, Ecto.Changeset.t()}
|
{:ok, Object.t()} | {:error, Ecto.Changeset.t()}
|
||||||
def add_like_to_object(%Activity{data: %{"actor" => actor}}, object) do
|
def add_like_to_object(%Activity{data: %{"actor" => actor}}, object) do
|
||||||
|
|
|
@ -256,7 +256,7 @@ def render("show.json", %{activity: %{data: %{"object" => _object}} = activity}
|
||||||
emoji_reactions =
|
emoji_reactions =
|
||||||
with %{data: %{"reactions" => emoji_reactions}} <- object do
|
with %{data: %{"reactions" => emoji_reactions}} <- object do
|
||||||
Enum.map(emoji_reactions, fn [emoji, users] ->
|
Enum.map(emoji_reactions, fn [emoji, users] ->
|
||||||
[emoji, length(users)]
|
%{emoji: emoji, count: length(users)}
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
_ -> []
|
_ -> []
|
||||||
|
|
|
@ -49,7 +49,12 @@ def emoji_reactions_by(%{assigns: %{user: user}} = conn, %{"id" => activity_id})
|
||||||
emoji_reactions
|
emoji_reactions
|
||||||
|> Enum.map(fn [emoji, users] ->
|
|> Enum.map(fn [emoji, users] ->
|
||||||
users = Enum.map(users, &User.get_cached_by_ap_id/1)
|
users = Enum.map(users, &User.get_cached_by_ap_id/1)
|
||||||
{emoji, AccountView.render("index.json", %{users: users, for: user, as: :user})}
|
|
||||||
|
%{
|
||||||
|
emoji: emoji,
|
||||||
|
count: length(users),
|
||||||
|
accounts: AccountView.render("index.json", %{users: users, for: user, as: :user})
|
||||||
|
}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|
|
|
@ -105,17 +105,4 @@ test "transfer config values with full subkey update" do
|
||||||
Application.put_env(:pleroma, :assets, assets)
|
Application.put_env(:pleroma, :assets, assets)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "non existing atom" do
|
|
||||||
ConfigDB.create(%{
|
|
||||||
group: ":pleroma",
|
|
||||||
key: ":undefined_atom_key",
|
|
||||||
value: [live: 2, com: 3]
|
|
||||||
})
|
|
||||||
|
|
||||||
assert ExUnit.CaptureLog.capture_log(fn ->
|
|
||||||
TransferTask.start_link([])
|
|
||||||
end) =~
|
|
||||||
"updating env causes error, group: \":pleroma\" key: \":undefined_atom_key\" value: [live: 2, com: 3] error: %ArgumentError{message: \"argument error\"}"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -636,4 +636,17 @@ test "removes actor from announcements" do
|
||||||
assert updated_object.data["announcement_count"] == 1
|
assert updated_object.data["announcement_count"] == 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "get_cached_emoji_reactions/1" do
|
||||||
|
test "returns the data or an emtpy list" do
|
||||||
|
object = insert(:note)
|
||||||
|
assert Utils.get_cached_emoji_reactions(object) == []
|
||||||
|
|
||||||
|
object = insert(:note, data: %{"reactions" => [["x", ["lain"]]]})
|
||||||
|
assert Utils.get_cached_emoji_reactions(object) == [["x", ["lain"]]]
|
||||||
|
|
||||||
|
object = insert(:note, data: %{"reactions" => %{}})
|
||||||
|
assert Utils.get_cached_emoji_reactions(object) == []
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,7 +36,10 @@ test "has an emoji reaction list" do
|
||||||
activity = Repo.get(Activity, activity.id)
|
activity = Repo.get(Activity, activity.id)
|
||||||
status = StatusView.render("show.json", activity: activity)
|
status = StatusView.render("show.json", activity: activity)
|
||||||
|
|
||||||
assert status[:pleroma][:emoji_reactions] == [["☕", 2], ["🍵", 1]]
|
assert status[:pleroma][:emoji_reactions] == [
|
||||||
|
%{emoji: "☕", count: 2},
|
||||||
|
%{emoji: "🍵", count: 1}
|
||||||
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
test "loads and returns the direct conversation id when given the `with_direct_conversation_id` option" do
|
test "loads and returns the direct conversation id when given the `with_direct_conversation_id` option" do
|
||||||
|
|
|
@ -71,7 +71,7 @@ test "GET /api/v1/pleroma/statuses/:id/emoji_reactions_by", %{conn: conn} do
|
||||||
|> get("/api/v1/pleroma/statuses/#{activity.id}/emoji_reactions_by")
|
|> get("/api/v1/pleroma/statuses/#{activity.id}/emoji_reactions_by")
|
||||||
|> json_response(200)
|
|> json_response(200)
|
||||||
|
|
||||||
[["🎅", [represented_user]]] = result
|
[%{"emoji" => "🎅", "count" => 1, "accounts" => [represented_user]}] = result
|
||||||
assert represented_user["id"] == other_user.id
|
assert represented_user["id"] == other_user.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue