Compare commits
18 commits
Author | SHA1 | Date | |
---|---|---|---|
|
ccb7973b8b | ||
|
21765150ad | ||
|
7624ea5f93 | ||
|
f6422461b3 | ||
|
6a20f59a42 | ||
|
baf3725d92 | ||
|
f940c646c6 | ||
|
eccc12ac92 | ||
|
3fc0ed8f66 | ||
2ca025147a | |||
c19a5f8582 | |||
|
717b370809 | ||
4ec12d7668 | |||
8b7f850ea2 | |||
65058232c4 | |||
2700294693 | |||
79e5bae71a | |||
|
74ea422ebf |
3 changed files with 106 additions and 27 deletions
|
@ -36,33 +36,6 @@ config :logger, :console,
|
|||
level: :info
|
||||
```
|
||||
|
||||
## Testing with HTTPS
|
||||
|
||||
If you end up developing alongside other software like misskey,
|
||||
you will not be able to federate without an SSL certificate. You should
|
||||
be able to use the snakeoil certificate that comes standard with most
|
||||
distributions or generate one from scratch, then force elixir to accept it.
|
||||
|
||||
HTTP clients are none too keen to accept self-signed certs, but we can do
|
||||
this:
|
||||
|
||||
```elixir
|
||||
config :pleroma, :http,
|
||||
adapter: [
|
||||
pools: %{
|
||||
default: [
|
||||
conn_opts: [
|
||||
transport_opts: [
|
||||
verify: :verify_none
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
Now your SSL requests will work. Hooray.
|
||||
|
||||
## Testing
|
||||
|
||||
1. Create a `test.secret.exs` file with the content as shown below
|
48
lib/pleroma/web/activity_pub/mrf/dont_boost_guppe_replies.ex
Normal file
48
lib/pleroma/web/activity_pub/mrf/dont_boost_guppe_replies.ex
Normal file
|
@ -0,0 +1,48 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.MRF.DontBoostGuppeReplies do
|
||||
alias Pleroma.User
|
||||
@moduledoc "Ignores boosts that have a reply to a guppe account, written by foxes@myfriendsare.gay"
|
||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||
|
||||
alias Pleroma.Object
|
||||
|
||||
require Logger
|
||||
|
||||
def history_awareness, do: :auto
|
||||
|
||||
def filter(
|
||||
%{
|
||||
"type" => "Announce",
|
||||
"actor" => actor,
|
||||
"object" => object
|
||||
} = message
|
||||
) do
|
||||
|
||||
Logger.debug("GUPPE ACTOR #{inspect(actor)}")
|
||||
if actor =~ "https://a.gup.pe/u/" do
|
||||
child = Object.get_by_ap_id(object).data
|
||||
Logger.debug("GUPPE OBJECT #{inspect(child)}")
|
||||
if child["inReplyTo"] != nil do
|
||||
Logger.debug("GUPPE REJECT #{object}")
|
||||
{:reject, message}
|
||||
else
|
||||
Logger.debug("GUPPE ALLOW #{object}")
|
||||
{:ok, message}
|
||||
end
|
||||
else
|
||||
{:ok, message}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
@impl true
|
||||
def filter(message), do: {:ok, message}
|
||||
|
||||
@impl true
|
||||
def describe, do: {:ok, %{}}
|
||||
end
|
58
lib/pleroma/web/activity_pub/mrf/unlist_undescribed_media.ex
Normal file
58
lib/pleroma/web/activity_pub/mrf/unlist_undescribed_media.ex
Normal file
|
@ -0,0 +1,58 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.MRF.UnlistUndescribedMedia do
|
||||
alias Pleroma.User
|
||||
@moduledoc "Unlists posts with media that does not have a description, written by foxes@myfriendsare.gay"
|
||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||
|
||||
require Pleroma.Constants
|
||||
|
||||
defp check_media(%{"attachment" => attachments}),
|
||||
do: not Enum.all?(attachments, fn x -> x["name"] != nil && x["name"] |> String.trim() != "" end)
|
||||
defp check_media(_),
|
||||
do: false
|
||||
|
||||
def filter(
|
||||
%{
|
||||
"type" => "Create",
|
||||
"to" => to,
|
||||
"cc" => cc,
|
||||
"actor" => actor,
|
||||
"object" => object
|
||||
} = message
|
||||
) do
|
||||
user = User.get_cached_by_ap_id(actor)
|
||||
undescribed = check_media(object)
|
||||
|
||||
# unlist
|
||||
if undescribed and Enum.member?(to, Pleroma.Constants.as_public()) do
|
||||
to = List.delete(to, Pleroma.Constants.as_public()) ++ [user.follower_address]
|
||||
cc = List.delete(cc, user.follower_address) ++ [Pleroma.Constants.as_public()]
|
||||
|
||||
object =
|
||||
object
|
||||
|> Map.put("to", to)
|
||||
|> Map.put("cc", cc)
|
||||
|
||||
message =
|
||||
message
|
||||
|> Map.put("to", to)
|
||||
|> Map.put("cc", cc)
|
||||
|> Map.put("object", object)
|
||||
|
||||
{:ok, message}
|
||||
else
|
||||
{:ok, message}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
@impl true
|
||||
def filter(message), do: {:ok, message}
|
||||
|
||||
@impl true
|
||||
def describe, do: {:ok, %{}}
|
||||
end
|
Loading…
Reference in a new issue