diff options
-rw-r--r-- | docs/Clients.md | 8 | ||||
-rw-r--r-- | lib/pleroma/activity.ex | 12 | ||||
-rw-r--r-- | lib/pleroma/object.ex | 4 | ||||
-rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub.ex | 16 | ||||
-rw-r--r-- | lib/pleroma/web/activity_pub/transmogrifier.ex | 4 | ||||
-rw-r--r-- | lib/pleroma/web/streamer.ex | 8 | ||||
-rw-r--r-- | lib/pleroma/web/templates/layout/app.html.eex | 140 | ||||
-rw-r--r-- | lib/pleroma/web/templates/o_auth/o_auth/show.html.eex | 35 | ||||
-rw-r--r-- | test/web/streamer_test.exs | 10 |
9 files changed, 174 insertions, 63 deletions
diff --git a/docs/Clients.md b/docs/Clients.md index ed3a2938f..dc3e83bcc 100644 --- a/docs/Clients.md +++ b/docs/Clients.md @@ -4,8 +4,8 @@ Feel free to contact us to be added to this list! ## Desktop ### Roma for Desktop -- Homepage: <http://www.pleroma.com/desktop-app/> -- Source Code: ??? +- Homepage: <https://www.pleroma.com/#desktopApp> +- Source Code: <https://github.com/roma-apps/roma-desktop> - Platforms: Windows, Mac, (Linux?) - Features: Streaming Ready @@ -44,8 +44,8 @@ Feel free to contact us to be added to this list! - Features: Streaming Ready ### Roma -- Homepage: <http://www.pleroma.com/> -- Source Code: ??? +- Homepage: <https://www.pleroma.com/#mobileApps> +- Source Code: [iOS](https://github.com/roma-apps/roma-ios), [Android](https://github.com/roma-apps/roma-android) - Platforms: iOS, Android - Features: No Streaming diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index 66854dc2d..18d5b70de 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -107,6 +107,18 @@ defmodule Pleroma.Activity do def get_in_reply_to_activity(_), do: nil + def delete_by_ap_id(id) when is_binary(id) do + by_object_ap_id(id) + |> Repo.delete_all(returning: true) + |> elem(1) + |> Enum.find(fn + %{data: %{"type" => "Create", "object" => %{"id" => ap_id}}} -> ap_id == id + _ -> nil + end) + end + + def delete_by_ap_id(_), do: nil + for {ap_type, type} <- @mastodon_notification_types do def mastodon_notification_type(%Activity{data: %{"type" => unquote(ap_type)}}), do: unquote(type) diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex index 5f1fc801b..7510a09bb 100644 --- a/lib/pleroma/object.ex +++ b/lib/pleroma/object.ex @@ -86,9 +86,9 @@ defmodule Pleroma.Object do def delete(%Object{data: %{"id" => id}} = object) do with {:ok, _obj} = swap_object_with_tombstone(object), - Repo.delete_all(Activity.by_object_ap_id(id)), + deleted_activity = Activity.delete_by_ap_id(id), {:ok, true} <- Cachex.del(:object_cache, "object:#{id}") do - {:ok, object} + {:ok, object, deleted_activity} end end diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index adb42b9ab..2f11f8984 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -311,14 +311,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do user = User.get_cached_by_ap_id(actor) to = object.data["to"] || [] ++ object.data["cc"] || [] - data = %{ - "type" => "Delete", - "actor" => actor, - "object" => id, - "to" => to - } - - with {:ok, _} <- Object.delete(object), + with {:ok, object, activity} <- Object.delete(object), + data <- %{ + "type" => "Delete", + "actor" => actor, + "object" => id, + "to" => to, + "deleted_activity_id" => activity && activity.id + }, {:ok, activity} <- insert(data, local), # Changing note count prior to enqueuing federation task in order to avoid race conditions on updating user.info {:ok, _actor} <- decrease_note_count_if_public(user, object), diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 88007aa16..27d223a3e 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -736,6 +736,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do def prepare_outgoing(%{"type" => _type} = data) do data = data + |> strip_internal_fields |> maybe_fix_object_url |> Map.merge(Utils.make_json_ld_header()) @@ -870,7 +871,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do "announcements", "announcement_count", "emoji", - "context_id" + "context_id", + "deleted_activity_id" ]) end diff --git a/lib/pleroma/web/streamer.ex b/lib/pleroma/web/streamer.ex index 27e8020f4..ad888c361 100644 --- a/lib/pleroma/web/streamer.ex +++ b/lib/pleroma/web/streamer.ex @@ -211,15 +211,19 @@ defmodule Pleroma.Web.Streamer do end) end - def push_to_socket(topics, topic, %Activity{id: id, data: %{"type" => "Delete"}}) do + def push_to_socket(topics, topic, %Activity{ + data: %{"type" => "Delete", "deleted_activity_id" => deleted_activity_id} + }) do Enum.each(topics[topic] || [], fn socket -> send( socket.transport_pid, - {:text, %{event: "delete", payload: to_string(id)} |> Jason.encode!()} + {:text, %{event: "delete", payload: to_string(deleted_activity_id)} |> Jason.encode!()} ) end) end + def push_to_socket(_topics, _topic, %Activity{data: %{"type" => "Delete"}}), do: :noop + def push_to_socket(topics, topic, item) do Enum.each(topics[topic] || [], fn socket -> # Get the current user so we have up-to-date blocks etc. diff --git a/lib/pleroma/web/templates/layout/app.html.eex b/lib/pleroma/web/templates/layout/app.html.eex index db97ccac2..8333bc921 100644 --- a/lib/pleroma/web/templates/layout/app.html.eex +++ b/lib/pleroma/web/templates/layout/app.html.eex @@ -8,75 +8,145 @@ </title> <style> body { - background-color: #282c37; + background-color: #121a24; font-family: sans-serif; - color:white; + color: #b9b9ba; text-align: center; } .container { - margin: 50px auto; - max-width: 320px; - padding: 0; - padding: 40px 40px 40px 40px; - background-color: #313543; + max-width: 420px; + padding: 20px; + background-color: #182230; border-radius: 4px; + margin: auto; + margin-top: 10vh; + box-shadow: 0 1px 4px 0px rgba(0, 0, 0, 0.5); } h1 { margin: 0; + font-size: 24px; } h2 { - color: #9baec8; + color: #b9b9ba; font-weight: normal; - font-size: 20px; - margin-bottom: 40px; + font-size: 18px; + margin-bottom: 20px; } form { width: 100%; } + .input { + text-align: left; + color: #89898a; + display: flex; + flex-direction: column; + } + input { - box-sizing: border-box; - width: 100%; + box-sizing: content-box; padding: 10px; - margin-top: 20px; - background-color: rgba(0,0,0,.1); - color: white; + margin-top: 5px; + margin-bottom: 10px; + background-color: #121a24; + color: #b9b9ba; border: 0; - border-bottom: 2px solid #9baec8; + transition-property: border-bottom; + transition-duration: 0.35s; + border-bottom: 2px solid #2a384a; font-size: 14px; } - input:focus { - border-bottom: 2px solid #4b8ed8; + .scopes-input { + display: flex; + margin-top: 1em; + text-align: left; + color: #89898a; + } + + .scopes-input label:first-child { + flex-basis: 40%; } - input[type="checkbox"] { - width: auto; + .scopes { + display: flex; + flex-wrap: wrap; + text-align: left; + color: #b9b9ba; + } + + .scope { + flex-basis: 100%; + display: flex; + height: 2em; + align-items: center; + } + + [type="checkbox"] + label { + margin: 0.5em; + } + + [type="checkbox"] { + display: none; + } + + [type="checkbox"] + label:before { + display: inline-block; + color: white; + background-color: #121a24; + border: 4px solid #121a24; + box-sizing: border-box; + width: 1.2em; + height: 1.2em; + margin-right: 1.0em; + content: ""; + transition-property: background-color; + transition-duration: 0.35s; + color: #121a24; + margin-bottom: -0.2em; + border-radius: 2px; + } + + [type="checkbox"]:checked + label:before { + background-color: #d8a070; + } + + input:focus { + outline: none; + border-bottom: 2px solid #d8a070; } button { box-sizing: border-box; width: 100%; - color: white; - background-color: #419bdd; + background-color: #1c2a3a; + color: #b9b9ba; border-radius: 4px; border: none; padding: 10px; margin-top: 30px; text-transform: uppercase; - font-weight: 500; font-size: 16px; + box-shadow: 0px 0px 2px 0px black, + 0px 1px 0px 0px rgba(255, 255, 255, 0.2) inset, + 0px -1px 0px 0px rgba(0, 0, 0, 0.2) inset; + } + + button:hover { + cursor: pointer; + box-shadow: 0px 0px 0px 1px #d8a070, + 0px 1px 0px 0px rgba(255, 255, 255, 0.2) inset, + 0px -1px 0px 0px rgba(0, 0, 0, 0.2) inset; } .alert-danger { box-sizing: border-box; width: 100%; - color: #D8000C; - background-color: #FFD2D2; + background-color: #931014; border-radius: 4px; border: none; padding: 10px; @@ -88,20 +158,32 @@ .alert-info { box-sizing: border-box; width: 100%; - color: #00529B; - background-color: #BDE5F8; border-radius: 4px; - border: none; + border: 1px solid #7d796a; padding: 10px; margin-top: 20px; font-weight: 500; font-size: 16px; } + + @media all and (max-width: 440px) { + .container { + margin-top: 0 + } + + .scopes-input { + flex-direction: column; + } + + .scope { + flex-basis: 50%; + } + } </style> </head> <body> <div class="container"> - <h1>Pleroma</h1> + <h1><%= Application.get_env(:pleroma, :instance)[:name] %></h1> <%= render @view_module, @view_template, assigns %> </div> </body> diff --git a/lib/pleroma/web/templates/o_auth/o_auth/show.html.eex b/lib/pleroma/web/templates/o_auth/o_auth/show.html.eex index f50599bdb..161333847 100644 --- a/lib/pleroma/web/templates/o_auth/o_auth/show.html.eex +++ b/lib/pleroma/web/templates/o_auth/o_auth/show.html.eex @@ -6,23 +6,26 @@ <% end %> <h2>OAuth Authorization</h2> <%= form_for @conn, o_auth_path(@conn, :authorize), [as: "authorization"], fn f -> %> -<%= label f, :name, "Name or email" %> -<%= text_input f, :name %> -<br> -<br> -<%= label f, :password, "Password" %> -<%= password_input f, :password %> -<br> -<br> - +<div class="input"> + <%= label f, :name, "Name or email" %> + <%= text_input f, :name %> +</div> +<div class="input"> + <%= label f, :password, "Password" %> + <%= password_input f, :password %> +</div> +<div class="scopes-input"> <%= label f, :scope, "Permissions" %> -<br> -<%= for scope <- @available_scopes do %> - <%# Note: using hidden input with `unchecked_value` in order to distinguish user's empty selection from `scope` param being omitted %> - <%= checkbox f, :"scope_#{scope}", value: scope in @scopes && scope, checked_value: scope, unchecked_value: "", name: "authorization[scope][]" %> - <%= label f, :"scope_#{scope}", String.capitalize(scope) %> - <br> -<% end %> + <div class="scopes"> + <%= for scope <- @available_scopes do %> + <%# Note: using hidden input with `unchecked_value` in order to distinguish user's empty selection from `scope` param being omitted %> + <div class="scope"> + <%= checkbox f, :"scope_#{scope}", value: scope in @scopes && scope, checked_value: scope, unchecked_value: "", name: "authorization[scope][]" %> + <%= label f, :"scope_#{scope}", String.capitalize(scope) %> + </div> + <% end %> + </div> +</div> <%= hidden_input f, :client_id, value: @client_id %> <%= hidden_input f, :response_type, value: @response_type %> diff --git a/test/web/streamer_test.exs b/test/web/streamer_test.exs index 16d7b9c24..a0969e1d7 100644 --- a/test/web/streamer_test.exs +++ b/test/web/streamer_test.exs @@ -39,7 +39,15 @@ defmodule Pleroma.Web.StreamerTest do task = Task.async(fn -> - assert_receive {:text, _}, 4_000 + expected_event = + %{ + "event" => "delete", + "payload" => activity.id + } + |> Jason.encode!() + + assert_receive {:text, received_event}, 4_000 + assert received_event == expected_event end) fake_socket = %{ |