travis-api/lib/travis/services/sync_user.rb
Aakriti Gupta 65f1a29d86 Move travis-core files from /vendor to /lib.
- Re-factor
- Remove code for notifications
- Remove addons
- Remove travis-core gem.
- Ignore logs directory only
- Move core tests to spec/lib
2016-07-20 11:22:25 +02:00

27 lines
614 B
Ruby

require 'travis/sidekiq/synchronize_user'
require 'travis/services/base'
module Travis
module Services
class SyncUser < Base
register :sync_user
def run
trigger_sync unless user.syncing?
end
def trigger_sync
logger.info("Synchronizing via Sidekiq for user: #{user.login}")
Travis::Sidekiq::SynchronizeUser.perform_async(user.id)
user.update_column(:is_syncing, true)
true
end
def user
# TODO check that clients are only passing the id
@user ||= current_user || User.find(params[:id])
end
end
end
end