Class: ImportService

Inherits:
Object
  • Object
show all
Includes:
Diaspora::Logging
Defined in:
app/services/import_service.rb

Instance Method Summary collapse

Instance Method Details

#import_by_files(path_to_profile, path_to_photos, username, opts = {}) ⇒ Object

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/services/import_service.rb', line 10

def import_by_files(path_to_profile, path_to_photos, username, opts={})
  if path_to_profile.present?
    logger.info "Import for profile #{username} at path #{path_to_profile} requested"
    (path_to_profile, username, opts.merge(photo_migration: path_to_photos.present?))
  end

  user = User.find_by(username: username)
  raise ArgumentError, "Username #{username} should exist before uploading photos." if user.nil?

  if path_to_photos.present?
    logger.info("Importing photos from import file for '#{username}' from #{path_to_photos}")
    import_user_photos(user, path_to_photos)
  end
  remove_file_references(user)
end

#import_by_user(user, opts = {}) ⇒ Object



6
7
8
# File 'app/services/import_service.rb', line 6

def import_by_user(user, opts={})
  import_by_files(user.export.current_path, user.exported_photos_file.current_path, user.username, opts)
end