move user variables to `users` relation
parent
9a2f0131c6
commit
436f7984d9
|
@ -28,7 +28,7 @@ class Bangtags
|
||||||
# list of post-processing commands
|
# list of post-processing commands
|
||||||
@post_cmds = []
|
@post_cmds = []
|
||||||
# hash of bangtag variables
|
# hash of bangtag variables
|
||||||
@vars = account.vars
|
@vars = account.user.vars
|
||||||
# keep track of what variables we're appending the value of between chunks
|
# keep track of what variables we're appending the value of between chunks
|
||||||
@vore_stack = []
|
@vore_stack = []
|
||||||
# keep track of what type of nested components are active so we can !end them in order
|
# keep track of what type of nested components are active so we can !end them in order
|
||||||
|
@ -516,7 +516,7 @@ class Bangtags
|
||||||
|
|
||||||
postprocess_before_save
|
postprocess_before_save
|
||||||
|
|
||||||
account.save
|
account.user.save
|
||||||
|
|
||||||
status.text = @chunks.join
|
status.text = @chunks.join
|
||||||
status.save
|
status.save
|
||||||
|
|
|
@ -313,6 +313,10 @@ class Account < ApplicationRecord
|
||||||
self[:also_known_as] || []
|
self[:also_known_as] || []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def field
|
||||||
|
@field ||= fields.map { |f| [f.name, f.value] }.to_h
|
||||||
|
end
|
||||||
|
|
||||||
def fields
|
def fields
|
||||||
(self[:fields] || []).map { |f| Field.new(self, f) }
|
(self[:fields] || []).map { |f| Field.new(self, f) }
|
||||||
end
|
end
|
||||||
|
@ -352,6 +356,7 @@ class Account < ApplicationRecord
|
||||||
self.fields = tmp
|
self.fields = tmp
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# needs to be removed after migration
|
||||||
def vars
|
def vars
|
||||||
self[:vars]
|
self[:vars]
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
# chosen_languages :string is an Array
|
# chosen_languages :string is an Array
|
||||||
# created_by_application_id :bigint(8)
|
# created_by_application_id :bigint(8)
|
||||||
# approved :boolean default(TRUE), not null
|
# approved :boolean default(TRUE), not null
|
||||||
|
# vars :jsonb not null
|
||||||
#
|
#
|
||||||
|
|
||||||
class User < ApplicationRecord
|
class User < ApplicationRecord
|
||||||
|
@ -151,6 +152,10 @@ class User < ApplicationRecord
|
||||||
attr_reader :invite_code
|
attr_reader :invite_code
|
||||||
attr_writer :external
|
attr_writer :external
|
||||||
|
|
||||||
|
def vars
|
||||||
|
self[:vars]
|
||||||
|
end
|
||||||
|
|
||||||
def confirmed?
|
def confirmed?
|
||||||
confirmed_at.present?
|
confirmed_at.present?
|
||||||
end
|
end
|
||||||
|
|
|
@ -100,8 +100,8 @@ class ImportService < BaseService
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_json_statuses
|
def import_json_statuses
|
||||||
@account.vars['_bangtags:disable'] = true
|
@account.user.vars['_bangtags:disable'] = true
|
||||||
@account.save
|
@account.user.save
|
||||||
|
|
||||||
@data.each do |json|
|
@data.each do |json|
|
||||||
# skip if invalid status object
|
# skip if invalid status object
|
||||||
|
@ -172,8 +172,8 @@ class ImportService < BaseService
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@account.vars.delete('_bangtags:disable')
|
@account.user.vars.delete('_bangtags:disable')
|
||||||
@account.save
|
@account.user.save
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_activitypub
|
def import_activitypub
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddVarsToUsers < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
safety_assured { add_column :users, :vars, :jsonb, null:false, default: {} }
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
class MoveAccountVarsToUsers < ActiveRecord::Migration[5.2]
|
||||||
|
def up
|
||||||
|
Account.local.find_each { |a| a.user.vars = a.vars; a.user.save }
|
||||||
|
end
|
||||||
|
end
|
|
@ -762,6 +762,7 @@ ActiveRecord::Schema.define(version: 2019_05_21_003909) do
|
||||||
t.string "chosen_languages", array: true
|
t.string "chosen_languages", array: true
|
||||||
t.bigint "created_by_application_id"
|
t.bigint "created_by_application_id"
|
||||||
t.boolean "approved", default: true, null: false
|
t.boolean "approved", default: true, null: false
|
||||||
|
t.jsonb "vars", default: {}, null: false
|
||||||
t.index ["account_id"], name: "index_users_on_account_id"
|
t.index ["account_id"], name: "index_users_on_account_id"
|
||||||
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
||||||
t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id"
|
t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id"
|
||||||
|
|
Loading…
Reference in New Issue