Over the past couple of days we at 0011.LT have noticed a significant influx of ...

@admin@mastodon.0011.lt

Over the past couple of days we at 0011.LT have noticed a significant influx of spam sign-ups on our mastodon instance, which led to us patching our Mastodon instance to filter the spam out.

If you are a Mastodon administrator and have seen an overwhelming amount of spam coming from usernames such as `bpb0d2998ed8778b19` you can simply block them by editing live/app/models/account.rb:

1. Before other `validate` lines (after includes and enums) in the `Account` class add:

```
enum ...

validate :block_spam_usernames, if: -> { local? && will_save_change_to_username? }

validate ...
```

2. Below the occurrence of the `private` keyword, add your function:

```
...

private

def block_spam_usernames
if username.to_s.match?(/bp[a-f0-9]{16}/i)
errors.add(:username, :invalid)
end
end

...
```

... or that's at least how we handled the situation :)

Although note that you will have to re-apply this patch should you update your instance.

#mastodon #mastoadm #spam #mastodonadmin