From 1dcdc2b0327a05fb18d3fab994b5e9e5b22c8f5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Sat, 17 May 2025 18:22:11 +0400 Subject: [PATCH] Allow syncing a single Mastodon profile --- .../mastodon_manager/sync_account_profiles.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/services/mastodon_manager/sync_account_profiles.rb b/app/services/mastodon_manager/sync_account_profiles.rb index 71b08cf..2502ed0 100644 --- a/app/services/mastodon_manager/sync_account_profiles.rb +++ b/app/services/mastodon_manager/sync_account_profiles.rb @@ -1,8 +1,9 @@ module MastodonManager class SyncAccountProfiles < MastodonManagerService - def initialize(direction: "down", overwrite: false) + def initialize(direction: "down", overwrite: false, user: nil) @direction = direction @overwrite = overwrite + @user = user if @direction != "down" raise NotImplementedError @@ -10,9 +11,15 @@ module MastodonManager end def call - Rails.logger.debug { "Syncing account profiles (direction: #{@direction}, overwrite: #{@overwrite})"} + if @user + Rails.logger.debug { "Syncing account profile for user #{@user.cn} (direction: #{@direction}, overwrite: #{@overwrite})"} + users = User.where(cn: @user.cn) + else + Rails.logger.debug { "Syncing account profiles (direction: #{@direction}, overwrite: #{@overwrite})"} + users = User + end - User.find_each do |user| + users.find_each do |user| if user.mastodon_id.blank? mastodon_user = MastodonManager::FindUser.call username: user.cn if mastodon_user