Class: ArchiveImporter

Inherits:
Object
  • Object
show all
Includes:
ArchiveHelper, Diaspora::Logging
Defined in:
lib/archive_importer.rb,
lib/archive_importer/post_importer.rb,
lib/archive_importer/archive_helper.rb,
lib/archive_importer/entity_importer.rb,
lib/archive_importer/contact_importer.rb,
lib/archive_importer/own_entity_importer.rb,
lib/archive_importer/own_relayable_importer.rb

Defined Under Namespace

Modules: ArchiveHelper Classes: ContactImporter, EntityImporter, OwnEntityImporter, OwnRelayableImporter, PostImporter

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ArchiveHelper

#archive_author_diaspora_id, #contact_groups, #contacts, #others_relayables, #person, #post_subscriptions, #posts, #private_key, #relayables, #serialized_private_key

Constructor Details

#initialize(archive_hash) ⇒ ArchiveImporter

Returns a new instance of ArchiveImporter.


9
10
11
# File 'lib/archive_importer.rb', line 9

def initialize(archive_hash)
  @archive_hash = archive_hash
end

Instance Attribute Details

#userObject

Returns the value of attribute user


7
8
9
# File 'lib/archive_importer.rb', line 7

def user
  @user
end

Instance Method Details

#create_user(attr) ⇒ Object


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/archive_importer.rb', line 23

def create_user(attr)
  allowed_keys = %w[
    email strip_exif show_community_spotlight_in_stream language disable_mail auto_follow_back
  ]
  data = convert_keys(archive_hash["user"], allowed_keys)
  # setting getting_started to false as the user doesn't need to see the getting started wizard
  data.merge!(
    username:              attr[:username],
    password:              attr[:password],
    password_confirmation: attr[:password],
    getting_started:       false,
    person:                {
      profile_attributes: profile_attributes
    }
  )
  self.user = User.build(data)
  user.save!
end

#importObject


13
14
15
16
17
18
19
20
21
# File 'lib/archive_importer.rb', line 13

def import
  import_tag_followings
  import_aspects
  import_contacts
  import_posts
  import_relayables
  import_subscriptions
  import_others_relayables
end