/images/2024/anti-spam/spam-wave.png

一大波SPAM即将到来

最近,SPAM 狂潮来袭,一波又一波的 SPAM 的到来,让实例管理人员疲于奔命。

/images/2024/anti-spam/report-email.png

有关 Report 的提醒邮件 (未完,下方还有好几屏)

面对 SPAM 报告,我们需要封禁 SPAM 帐户,Limite 被 SPAM 入侵的实例以防进一步的骚扰。

但这几个步骤通过 Mastodon Web 自带的管理界面进行非常麻烦,需要打开好几个网页,点击好多次才能完成。 如果你还要发布管理操作报告,那就更麻烦了。

Mastodon Web 自带的管理工具,在这种大规模 SPAM 入侵时,显得有一些力不从心。

人肉管理 vs 脚本SPAM,人肉管理能不能胜利尚不好说,但累死是一定的。现代问题现代方法解决,管理也需要脚本辅助。

本文将介绍,如何使用脚本半自动化处理的黑猫SPAM。

Read more……

Mastodon 在较新 Linux 发行版本下会遇到前端预编译出错的问题。

本文大概记录一下,如何修复 Mastodon 前端预编译错误?

Read more……

今天阅读 《整一个同时用于浏览器和 Node.js 的模块》 这篇博文时,看到其中关于浏览器 fetch api 获取请求头部分,心有所感,于是就有了本文。

本文将说一说浏览器 fetch api 与 Forbidden header 的那些事情,在浏览器中可以设置并获取 Forbidden header 吗?

Read more……

记录一下自己开启 Firefox 视频硬件解码的过程。

Read more……

Step 1: delete unused large rooms

Step 1.1: Find large rooms

SELECT r.name, s.room_id, s.current_state_events
    FROM room_stats_current s
    LEFT JOIN room_stats_state r USING (room_id)
    ORDER BY current_state_events DESC
    LIMIT 20;
SELECT rss.name, s.room_id, COUNT(s.room_id)
    FROM state_groups_state s
    LEFT JOIN room_stats_state rss USING (room_id)
    GROUP BY s.room_id, rss.name
    ORDER BY COUNT(s.room_id) DESC
    LIMIT 20;

https://matrix-org.github.io/synapse/latest/usage/administration/useful_sql_for_admins.html#show-top-20-larger-rooms-by-state-events-count

Step 1.2: Use Admin API Purge the unused large rooms

https://matrix-org.github.io/synapse/latest/admin_api/rooms.html#version-2-new-version

curl "http://localhost:8008/_synapse/admin/v1/rooms/${ROOMID}" -X DELETE -H 'Accept: application/json' -H 'Referer: http://localhost:8080/' -H "authorization: Bearer ${TOKEN}" --data '{ "purge": true, "message": "Sorry - kicking you out to clean up the database" }'

Step 1.3: Delete orphan state_groups_state and state_groups

After using the Admin API to purge the rooms, but only removes the data in the events table, and there are still a lot of related room data in the state_groups_state and state_groups tables (the main space occupation). This may be a synapse bug.

So you need to remove them manually.

https://github.com/matrix-org/synapse/issues/12821#issuecomment-1295773504

DELETE FROM
state_groups_state
WHERE
room_id IN (
    SELECT
    DISTINCT(state_groups.room_id) AS room_id_gone
    FROM
    state_groups
    LEFT JOIN events USING(room_id)
    WHERE
    events.room_id IS NULL
    GROUP BY
    room_id_gone
);
DELETE FROM
state_groups
WHERE
room_id IN (
    SELECT
    DISTINCT(state_groups.room_id) AS room_id_gone
    FROM
    state_groups
    LEFT JOIN events USING(room_id)
    WHERE
    events.room_id IS NULL
    GROUP BY
    room_id_gone
);

Step 2: Run synapse_auto_compressor

https://github.com/matrix-org/rust-synapse-compress-state

git clone https://github.com/matrix-org/rust-synapse-compress-state.git

cd rust-synapse-compress-state/
cargo build -r

cd synapse_auto_compressor/
cargo build -r

cd ../target/release/

./synapse_auto_compressor -p postgresql://synapse_user:[password]@[host]/synapse -c 1000 -n 10000000 | tee ~/synapse_auto_compressor.log

Step 3: Vacuum Database

REINDEX (VERBOSE) DATABASE synapse;
VACUUM FULL VERBOSE;

Before:

/images/2023/how-to-clean-up-the-synapse-database/01.thumbnail.png

After:

/images/2023/how-to-clean-up-the-synapse-database/02.thumbnail.png