Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into feature/local-only...
authorlain <lain@soykaf.club>
Wed, 4 Nov 2020 10:47:41 +0000 (11:47 +0100)
committerlain <lain@soykaf.club>
Wed, 4 Nov 2020 10:47:41 +0000 (11:47 +0100)
1  2 
CHANGELOG.md
lib/pleroma/activity.ex
lib/pleroma/web/common_api.ex

diff --combined CHANGELOG.md
index d9410ccf39116169d21d76ab1f64129fbda4b139,2ee17d239dde32fbb707d3bc3dd47c4fc32d57af..b7ca479494bc4f1342a4a820345f89ef0ada0d72
@@@ -12,12 -12,11 +12,13 @@@ The format is based on [Keep a Changelo
  - Media preview proxy (requires `ffmpeg` and `ImageMagick` to be installed and media proxy to be enabled; see `:media_preview_proxy` config for more details).
  - Pleroma API: Importing the mutes users from CSV files.
  - Experimental websocket-based federation between Pleroma instances.
 +- Support for local-only statuses
  - Support pagination of blocks and mutes
  - App metrics: ability to restrict access to specified IP whitelist.
+ - Account backup
  - Configuration: Add `:instance, autofollowing_nicknames` setting to provide a way to make accounts automatically follow new users that register on the local Pleroma instance.
  
 +
  ### Changed
  
  - **Breaking** Requires `libmagic` (or `file`) to guess file types.
@@@ -40,6 -39,7 +41,7 @@@
  - Pleroma API: Pagination for remote/local packs and emoji.
  - Admin API: (`GET /api/pleroma/admin/users`) added filters user by `unconfirmed` status
  - Admin API: (`GET /api/pleroma/admin/users`) added filters user by `actor_type`
+ - Pleroma API: Add `idempotency_key` to the chat message entity that can be used for optimistic message sending.
  
  </details>
  
@@@ -58,6 -58,8 +60,8 @@@ switched to a new configuration mechani
  - Allow sending chat messages to yourself.
  - Fix remote users with a whitespace name.
  - OStatus / static FE endpoints: fixed inaccessibility for anonymous users on non-federating instances, switched to handling per `:restrict_unauthenticated` setting.
+ - Mastodon API: Current user is now included in conversation if it's the only participant
+ - Mastodon API: Fixed last_status.account being not filled with account data
  
  ## Unreleased (Patch)
  
diff --combined lib/pleroma/activity.ex
index 3b01f5e316a0b83d55b99ceba9d563aac60c8e41,553834da0b786f905f1544fc9feb395c66bc0285..648cfb623a0291a092d813ddc20fb60b17d5c49f
@@@ -14,12 -14,11 +14,13 @@@ defmodule Pleroma.Activity d
    alias Pleroma.ReportNote
    alias Pleroma.ThreadMute
    alias Pleroma.User
+   alias Pleroma.Web.ActivityPub.ActivityPub
  
    import Ecto.Changeset
    import Ecto.Query
  
 +  require Pleroma.Constants
 +
    @type t :: %__MODULE__{}
    @type actor :: String.t()
  
  
    def get_bookmark(_, _), do: nil
  
+   def get_report(activity_id) do
+     opts = %{
+       type: "Flag",
+       skip_preload: true,
+       preload_report_notes: true
+     }
+     ActivityPub.fetch_activities_query([], opts)
+     |> where(id: ^activity_id)
+     |> Repo.one()
+   end
    def change(struct, params \\ %{}) do
      struct
      |> cast(params, [:data, :recipients])
      actor = user_actor(activity)
      activity.id in actor.pinned_activities
    end
 +
 +  def local_only?(activity) do
 +    recipients = Enum.concat(activity.data["to"], Map.get(activity.data, "cc", []))
 +    public = Pleroma.Constants.as_public()
 +    local = Pleroma.Constants.as_local_public()
 +
 +    Enum.member?(recipients, local) and not Enum.member?(recipients, public)
 +  end
  end
index e5c66eea36359cd4c2fbb806c904404dccbfcc48,318ffc5d0077f7bff258fb2f95e161b7ffdd8660..4df37b69561b0e1a3c91edeac62e08e36d019478
@@@ -15,7 -15,6 +15,7 @@@ defmodule Pleroma.Web.CommonAPI d
    alias Pleroma.Web.ActivityPub.Pipeline
    alias Pleroma.Web.ActivityPub.Utils
    alias Pleroma.Web.ActivityPub.Visibility
 +  alias Pleroma.Web.CommonAPI.ActivityDraft
  
    import Pleroma.Web.Gettext
    import Pleroma.Web.CommonAPI.Utils
@@@ -46,7 -45,8 +46,8 @@@
           {_, {:ok, %Activity{} = activity, _meta}} <-
             {:common_pipeline,
              Pipeline.common_pipeline(create_activity_data,
-               local: true
+               local: true,
+               idempotency_key: opts[:idempotency_key]
              )} do
        {:ok, activity}
      else
    end
  
    def listen(user, data) do
 -    visibility = Map.get(data, :visibility, "public")
 -
 -    with {to, cc} <- get_to_and_cc(user, [], nil, visibility, nil),
 -         listen_data <-
 -           data
 -           |> Map.take([:album, :artist, :title, :length])
 -           |> Map.new(fn {key, value} -> {to_string(key), value} end)
 -           |> Map.put("type", "Audio")
 -           |> Map.put("to", to)
 -           |> Map.put("cc", cc)
 -           |> Map.put("actor", user.ap_id),
 -         {:ok, activity} <-
 -           ActivityPub.listen(%{
 -             actor: user,
 -             to: to,
 -             object: listen_data,
 -             context: Utils.generate_context_id(),
 -             additional: %{"cc" => cc}
 -           }) do
 -      {:ok, activity}
 +    with {:ok, draft} <- ActivityDraft.listen(user, data) do
 +      ActivityPub.listen(draft.changes)
      end
    end
  
    def post(user, %{status: _} = data) do
 -    with {:ok, draft} <- Pleroma.Web.CommonAPI.ActivityDraft.create(user, data) do
 +    with {:ok, draft} <- ActivityDraft.create(user, data) do
        ActivityPub.create(draft.changes, draft.preview?)
      end
    end