Merge branch 'develop' into 'hide-muted-reactions'
authorminibikini <egor@kislitsyn.com>
Wed, 18 Nov 2020 20:22:40 +0000 (20:22 +0000)
committerminibikini <egor@kislitsyn.com>
Wed, 18 Nov 2020 20:22:40 +0000 (20:22 +0000)
# Conflicts:
#   CHANGELOG.md

1  2 
CHANGELOG.md
lib/pleroma/user.ex

diff --combined CHANGELOG.md
index 33ff9a9f0bed72c95ac7b0d869c67796566c0796,cd90562c29fed5c35dc4933d2a8626ef32a2878a..8658d544099f7bae38c731b891ba59870b0aa502
@@@ -28,6 -28,7 +28,7 @@@ The format is based on [Keep a Changelo
  - Pleroma API: Add `idempotency_key` to the chat message entity that can be used for optimistic message sending.
  - Pleroma API: (`GET /api/v1/pleroma/federation_status`) Add a way to get a list of unreachable instances.
  - Mastodon API: User and conversation mutes can now auto-expire if `expires_in` parameter was given while adding the mute.
+ - Admin API: An endpoint to manage frontends
  
  </details>
  
  </details>
  
  ## Unreleased (Patch)
+ ### Changed
+ - Fix ability to update Pleroma Chat push notifications with PUT /api/v1/push/subscription and alert type pleroma:chat_mention
  ### Fixed
  
  - Config generation: rename `Pleroma.Upload.Filter.ExifTool` to `Pleroma.Upload.Filter.Exiftool`.
  - S3 Uploads with Elixir 1.11.
 +- Fixed Emoji Reaction activity filtering from blocked and muted accounts
+ - Mix task pleroma.user delete_activities for source installations.
  
  ## [2.2.0] - 2020-11-12
  
diff --combined lib/pleroma/user.ex
index 66f5efca756bf473c7fbbb2744e7d92f9c19b6b6,a240579f35030cda6fd4fbb4b614041d718fc909..bcd5256c8e0d51203e6a00aab2ee974e2c6d1da3
@@@ -245,18 -245,6 +245,18 @@@ defmodule Pleroma.User d
      end
    end
  
 +  def cached_blocked_users_ap_ids(user) do
 +    Cachex.fetch!(:user_cache, "blocked_users_ap_ids:#{user.ap_id}", fn _ ->
 +      blocked_users_ap_ids(user)
 +    end)
 +  end
 +
 +  def cached_muted_users_ap_ids(user) do
 +    Cachex.fetch!(:user_cache, "muted_users_ap_ids:#{user.ap_id}", fn _ ->
 +      muted_users_ap_ids(user)
 +    end)
 +  end
 +
    defdelegate following_count(user), to: FollowingRelationship
    defdelegate following(user), to: FollowingRelationship
    defdelegate following?(follower, followed), to: FollowingRelationship
      Cachex.del(:user_cache, "ap_id:#{user.ap_id}")
      Cachex.del(:user_cache, "nickname:#{user.nickname}")
      Cachex.del(:user_cache, "friends_ap_ids:#{user.ap_id}")
 +    Cachex.del(:user_cache, "blocked_users_ap_ids:#{user.ap_id}")
 +    Cachex.del(:user_cache, "muted_users_ap_ids:#{user.ap_id}")
    end
  
    @spec get_cached_by_ap_id(String.t()) :: User.t() | nil
          )
        end
  
 +      Cachex.del(:user_cache, "muted_users_ap_ids:#{muter.ap_id}")
 +
        {:ok, Enum.filter([user_mute, user_notification_mute], & &1)}
      end
    end
      with {:ok, user_mute} <- UserRelationship.delete_mute(muter, mutee),
           {:ok, user_notification_mute} <-
             UserRelationship.delete_notification_mute(muter, mutee) do
 +      Cachex.del(:user_cache, "muted_users_ap_ids:#{muter.ap_id}")
        {:ok, [user_mute, user_notification_mute]}
      end
    end
  
    def html_filter_policy(_), do: Config.get([:markup, :scrub_policy])
  
-   def fetch_by_ap_id(ap_id, opts \\ []), do: ActivityPub.make_user_from_ap_id(ap_id, opts)
+   def fetch_by_ap_id(ap_id), do: ActivityPub.make_user_from_ap_id(ap_id)
  
-   def get_or_fetch_by_ap_id(ap_id, opts \\ []) do
+   def get_or_fetch_by_ap_id(ap_id) do
      cached_user = get_cached_by_ap_id(ap_id)
  
-     maybe_fetched_user = needs_update?(cached_user) && fetch_by_ap_id(ap_id, opts)
+     maybe_fetched_user = needs_update?(cached_user) && fetch_by_ap_id(ap_id)
  
      case {cached_user, maybe_fetched_user} do
        {_, {:ok, %User{} = user}} ->
  
    def public_key(_), do: {:error, "key not found"}
  
-   def get_public_key_for_ap_id(ap_id, opts \\ []) do
-     with {:ok, %User{} = user} <- get_or_fetch_by_ap_id(ap_id, opts),
+   def get_public_key_for_ap_id(ap_id) do
+     with {:ok, %User{} = user} <- get_or_fetch_by_ap_id(ap_id),
           {:ok, public_key} <- public_key(user) do
        {:ok, public_key}
      else
    @spec add_to_block(User.t(), User.t()) ::
            {:ok, UserRelationship.t()} | {:error, Ecto.Changeset.t()}
    defp add_to_block(%User{} = user, %User{} = blocked) do
 -    UserRelationship.create_block(user, blocked)
 +    with {:ok, relationship} <- UserRelationship.create_block(user, blocked) do
 +      Cachex.del(:user_cache, "blocked_users_ap_ids:#{user.ap_id}")
 +      {:ok, relationship}
 +    end
    end
  
    @spec add_to_block(User.t(), User.t()) ::
            {:ok, UserRelationship.t()} | {:ok, nil} | {:error, Ecto.Changeset.t()}
    defp remove_from_block(%User{} = user, %User{} = blocked) do
 -    UserRelationship.delete_block(user, blocked)
 +    with {:ok, relationship} <- UserRelationship.delete_block(user, blocked) do
 +      Cachex.del(:user_cache, "blocked_users_ap_ids:#{user.ap_id}")
 +      {:ok, relationship}
 +    end
    end
  
    def set_invisible(user, invisible) do