軽量なActivityPub Server のsnac 2.88 でミュートワードやメタデータ除去機能追加

snac susie

ミニマムで軽量なActivityPub Server のsnac 2.88 がリリースされました.

2.88

If disable_emojireact is set to true in server.json, EmojiReacts (incoming and outgoing) are totally disabled.

New command-line option top_ten, that returns the top ten most popular posts by a user (ordered by the sum of likes and boosts) (contributed by aov).

Added a new set of per-user muted words; if a post contains any of them, it’s hidden behind a dropdown (contributed by byte).

If an account has a metadata named pronouns, it’s shown by the name (contributed by violette).

Mastodon API: children of a post are returned recursively, not just the first level (contributed by violette).

Implemented optional metadata stripping for images and videos using external tools (contributed by Stefano Marinelli).

— https://codeberg.org/grunfink/snac2/src/branch/master/RELEASE_NOTES.md#2-88

それぞれのcommit はこのあたりでしょうか

絵文字リアクションの無効設定

今回の更新で,サーバー設定ファイルの server.json の中に disable_emojireact が設定できるようになりました.これを true にすることで絵文字リアクションの送受信が無効化できます.
自分は有効にしたいのでこの設定はスルー.

$ man doc/snac.8 | grep -A1 disable_emojireact
       disable_emojireact
                   If set to true, all EmojiReact support (for input and output) is disabled.

top_ten コマンド

top_ten という新しいコマンドラインオプションが実装されました.これを実行すると対象ユーザーのいいねとブースト数から最も人気のあった投稿のトップ10が表示できます.オプションで指定件数にもできます.

$ ./snac2/snac top_ten
snac 2.88 - A simple, minimalistic ActivityPub instance
Copyright (c) 2022 - 2026 grunfink et al. / MIT license

top_ten {basedir} {uid} [{N}]        Prints the most popular posts
$ ./snac2/snac top_ten snac-data matoken 5
https://snac.matoken.org/matoken/p/1768641700.668031 1★ 0↺
https://snac.matoken.org/matoken/p/1768600460.460220 0★ 0↺
https://snac.matoken.org/matoken/p/1768690681.713879 0★ 0↺
https://snac.matoken.org/matoken/p/1768690814.893464 0★ 0↺
https://snac.matoken.org/matoken/p/1768690913.716133 0★ 0↺
man doc/snac.1 | grep -A1 top_ten
             top_ten basedir uid [N]
                     Returns the ids of the top ten (or top N) most popular posts (considering the sum of likes and boosts).

ユーザーミュートワード

ユーザーごとにミュートワードが設定できるようになりました.投稿に設定ワードが含まれていた場合隠されるようになります.
設定は,対象アカウントの「private」 → 「Muted words…​」にあります.

snac 2.88 muted words

$ man doc/snac.5 | grep muted
       muted/      This directory contains files which names are hashes of muted actors. The content is a line containing the actor URL.  Messages from these actors will be ignored on input and not shown in any timeline.

画像とビデオのメタデータ除去

外部ツールを利用して画像とビデオからメタデータを除去できるようになりました.
既定値では無効になっています.有効にしたい場合は,server.json"strip_exif": true, を設定します.
画像のメタデータ除去にはImageMagickのmogrify を,動画のメタデータ除去にはffmpeg を利用します.導入していない場合は導入が必要です.
外部ツールがパスの通っていない場所にある場合は,mogrify_path, ffmpeg_path で指定可能です.

server.json 設定例
    "strip_exif": true,
    "mogrify_path": "/usr/local/bin/mogrify",
    "ffmpeg_path": "/usr/local/bin/ffmpeg",

実際にexif 付きの画像を投稿して確認してみます.

サンプル画像の入手と確認
$ wget https://raw.githubusercontent.com/ianare/exif-samples/refs/heads/master/jpg/Pentax_K10D.jpg
$ exif Pentax_K10D.jpg
EXIF tags in '/home/matoken/Downloads/Pentax_K10D.jpg' ('Intel' byte order):
--------------------+----------------------------------------------------------
Tag                 |Value
--------------------+----------------------------------------------------------
Manufacturer        |PENTAX Corporation
Model               |PENTAX K10D
Orientation         |Top-left
X-Resolution        |350
Y-Resolution        |350
Resolution Unit     |Inch
Software            |GIMP 2.4.5
Date and Time       |2008:07:31 15:56:49
Copyright           |Laitche (This file is in the public domain.) (Photographer
XP Author           |www.laitche.com
Compression         |JPEG compression
X-Resolution        |72
Y-Resolution        |72
Resolution Unit     |Inch
Exposure Time       |1/180 sec.
F-Number            |f/11.0
Exposure Program    |Aperture priority
ISO Speed Ratings   |200
Exif Version        |Exif Version 2.21
Date and Time (Origi|2008:05:04 16:47:24
Date and Time (Digit|2008:05:04 16:47:24
Exposure Bias       |0.00 EV
Metering Mode       |Pattern
Flash               |Flash did not fire, compulsory flash mode
Focal Length        |90.0 mm
FlashPixVersion     |FlashPix Version 1.0
Color Space         |sRGB
Pixel X Dimension   |100
Pixel Y Dimension   |72
Sensing Method      |One-chip color area sensor
--------------------+----------------------------------------------------------
EXIF data contains a thumbnail (1349 bytes).

exif 付きの画像を投稿します.

snac 2.88 strip exif

投稿された画像をダウンロードして確認するとexif は消えていました.

$ wget http://127.0.0.1:8001/test/s/post-d2e2931a72bbe1cafaaf94e82ea27e66.jpg
$ exif ./post-d2e2931a72bbe1cafaaf94e82ea27e66.jpg
Corrupt data
The data provided does not follow the specification.
ExifLoader: The data supplied does not seem to contain EXIF data.

以下のようなコマンドを発行しているようです.

mogrify
            xs *cmd = xs_fmt("cd \"%s\" && %s -auto-orient -strip \"%s\" 2>/dev/null", srv_basedir, mp, r_fn);
ffmpeg
 	            /* -map_metadata -1 strips all global metadata */
	            /* -c copy copies input streams without re-encoding */
	            /* we don't silence stderr so we can debug issues */
	            /* we explicitly cd to srv_basedir to ensure relative paths work */
	            xs *cmd = xs_fmt("cd \"%s\" && %s -y -i \"%s\" -map_metadata -1 -c copy \"%s\"", srv_basedir, fp, r_fn, tmp_fn);
man doc/snac.8 | grep -A1 metadata
$ man doc/snac.8 | grep strip_exif -A7
       strip_exif  If  set  to  true,  EXIF and other metadata will be stripped from uploaded images (jpg, png, webp, heic, avif, tiff, gif, bmp) and videos (mp4, m4v, mov, webm, mkv, avi). This requires the mogrify (from ImageMagick) and
                   ffmpeg tools to be installed. If snac cannot find or execute these tools at startup, it will refuse to run.

       mogrify_path
                   Overrides the default "mogrify" command name or path. Use this if the tool is not in the system PATH or has a different name.

       ffmpeg_path
                   Overrides the default "ffmpeg" command name or path. Use this if the tool is not in the system PATH or has a different name.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です