Skip to content

Instantly share code, notes, and snippets.

@qnighy
Created March 30, 2026 14:48
Show Gist options
  • Select an option

  • Save qnighy/16f598a44dfaf6fa3551ca9d480bace0 to your computer and use it in GitHub Desktop.

Select an option

Save qnighy/16f598a44dfaf6fa3551ca9d480bace0 to your computer and use it in GitHub Desktop.

Mastodon 投稿再配送

misskey.io が数時間の障害に見舞われていたため、投稿の再送を行いました。

前提

サーバーによって最適なアプローチは異なります。今回の前提は以下の通りです。

  • おひとり様サーバー
  • リモートユーザーがほとんど、ローカルユーザーはごくわずか
  • リモート投稿がほとんど、ローカル投稿は相対的には少ない
  • ローカル投稿は相対的には少ないが、それでも全体を列挙できるほど少なくはない

手順

以下のようにして、特定期間のローカル投稿を全て洗い出して全ての関連するinboxに再送します。

since_id = (Time.parse('2026-03-29 02:25:00 UTC').to_f * 1000).to_i << 16
until_id = (Time.parse('2026-03-29 16:50:00 UTC').to_f * 1000).to_i << 16

count = 0

Account.local.where(suspended_at: nil).find_each do |account|
  Status.where(account_id: account.id)
        .where(id: since_id...until_id)
        .where(deleted_at: nil)
        .reorder(id: :asc)
        .pluck(:id)
        .each do |status_id|

    ActivityPub::DistributionWorker.perform_async(status_id)
    count += 1
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment