Conversation
Notices
-
@welcomebot you iz unblocked by dcc@annihilation.social
-
@dcc @blockbot @charlie_root @welcomebot @zero Yes, there won't be a setting; the problem is that the code is bad. There should at least be a scope option.
I pasted a fix into an old post; good luck finding it, I guess. The basic idea is to make two caches with Cachex, one of which stores a counter for a total and the other of which stores a per-actor timestamp. If the global counter exceeds some count per minute, or the per-actor timestamp is too recent, you don't send the notification.
-
@p @blockbot @charlie_root @welcomebot @zero i will see if i can go fine it
-
@dcc @blockbot @charlie_root @welcomebot @zero FSE's only tags one participant and posts as a DM; if the PleromaFE just told you when you're blocked, it wouldn't be necessary. (bloat just tells you.)
You're going to get one delivery per instance per message with it like that unless it posts as a DM (which eliminates the problem) or followers-only (which just mitigates slightly). If it's a DM, it can't get you DDoS'd, nothing will fetch it. You also need to rate-limit it: per-user and total number of posts per minute. If it's rate-limited, it can't be used as a spam cannon.
DRC's bot just does a periodic scan of the DB. It'd be difficult to cause problems with.
-
@p @blockbot @charlie_root @welcomebot @zero so how do i rate limit the bot? i dont see any setting to do it to the user, do i need to add some more code to the bot?
-
@p @blockbot @charlie_root @welcomebot @zero yea thats why i dont tag both people, so what can i do to fix the issuse
-
@p @blockbot @charlie_root @welcomebot really? i was assured that "btw here's the block bot he can't exploit" by @zero :terrylol: . Whats cachex
-
@dcc @blockbot @charlie_root @welcomebot @zero Yeah, I know he *says* that, but he also says that it's because I care how he runs his instance instead of because the bots tagging me annoys me. He's out of meds still: "can't" is incorrect. I'm instance-blocked there (because they fear my raw power and massive dick) so their blockbot hasn't tagged me, or I would have already. I really don't care about those bots until they decide to bother me.
Cachex is the thing I used in the rate-limiting code I posted. It's just an in-memory cache, it's used all over the codebase. Sure as hell beats the retarded "just blank the file from a cron job" strategy.
Nobody listens when I say that the problem with this bot is that there's no rate-limiting and if it is public, it will grow the deliveries table without bound. This is really simple. The ones that tag both participants are spambots.
-
@dcc @blockbot @charlie_root @welcomebot I have seen that one. It's the retard version and can be spammed. Just use Cachex.
-
@p @blockbot @charlie_root @welcomebot
defmodule Pleroma.Web.ActivityPub.MRF.BlockNotification do
@moduledoc "Notify local users upon remote block."
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
alias Pleroma.User
alias Pleroma.Web.CommonAPI
defp is_block_or_unblock(%{"type" => "Block", "object" => object}),
do: {true, "blocked", object}
defp is_block_or_unblock(%{
"type" => "Undo",
"object" => %{"type" => "Block", "object" => object}
}),
do: {true, "unblocked", object}
defp is_block_or_unblock(_), do: {false, nil, nil}
defp is_remote_or_displaying_local?(%User{local: false}), do: true
defp is_remote_or_displaying_local?(_), do: true
@impl true
def filter(message) do
with {true, action, object} <- is_block_or_unblock(message),
%User{} = actor <- User.get_cached_by_ap_id(message["actor"]),
%User{} = recipient <- User.get_cached_by_ap_id(object),
true <- recipient.local,
true <- is_remote_or_displaying_local?(actor),
false <- User.blocks_user?(recipient, actor) do
# Create /opt/pleroma/logs/ with write perms for user pleroma
# Make a cron job to delete the log file every hour or whatever
# Not my problem
log_file = "/opt/pleroma/logs/blocks.log"
bot_user = "blockbot"
log_contents = if File.exists?(log_file) do
File.read!(log_file)
else
""
end
logged_blocks = String.split(log_contents, "\n")
actor_name = (fn actor_uri -> Path.basename(actor_uri.path) <> "@" <> actor_uri.authority end).(URI.parse(message["actor"]))
log_entry = actor_name <> ":" <> action
unless Enum.member?(logged_blocks, log_entry) do
File.write!(log_file, log_entry <> "\n", [:append])
_reply =
CommonAPI.post(User.get_by_nickname(bot_user), %{
status: "@" <> recipient.nickname <> " you iz " <> action <> " by " <> actor_name,
visibility: "public"
})
end
end
{:ok, message}
end
@impl true
def describe, do: {:ok, %{}}
end
-
@p @blockbot @charlie_root @welcomebot i think so
-
@dcc @blockbot @charlie_root @welcomebot Let's see the code.
-
@blockbot @welcomebot @charlie_root the new unspamable block bot works :jackdripper:
-
@dcc @blockbot @charlie_root @welcomebot Oh, no, unspammable? You're sure about that?
-
@dcc @blockbot @charlie_root @welcomebot @zero It's like a year old, I don't think you're going to find it, and it was a snippet, not full code. It definitely won't be in your DB, and it will take forever, and you'll still have to understand enough of the code to figure out how to fit it in. Just read the Cachex docs and then grep the Pleroma source code to see how it's used.