Allow syncing a single Mastodon profile
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
bfa1514181
commit
1dcdc2b032
@ -1,8 +1,9 @@
|
|||||||
module MastodonManager
|
module MastodonManager
|
||||||
class SyncAccountProfiles < MastodonManagerService
|
class SyncAccountProfiles < MastodonManagerService
|
||||||
def initialize(direction: "down", overwrite: false)
|
def initialize(direction: "down", overwrite: false, user: nil)
|
||||||
@direction = direction
|
@direction = direction
|
||||||
@overwrite = overwrite
|
@overwrite = overwrite
|
||||||
|
@user = user
|
||||||
|
|
||||||
if @direction != "down"
|
if @direction != "down"
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
@ -10,9 +11,15 @@ module MastodonManager
|
|||||||
end
|
end
|
||||||
|
|
||||||
def call
|
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?
|
if user.mastodon_id.blank?
|
||||||
mastodon_user = MastodonManager::FindUser.call username: user.cn
|
mastodon_user = MastodonManager::FindUser.call username: user.cn
|
||||||
if mastodon_user
|
if mastodon_user
|
||||||
|
Loading…
x
Reference in New Issue
Block a user