move user variables to `users` relation
parent
9a2f0131c6
commit
436f7984d9
|
@ -28,7 +28,7 @@ class Bangtags
|
|||
# list of post-processing commands
|
||||
@post_cmds = []
|
||||
# hash of bangtag variables
|
||||
@vars = account.vars
|
||||
@vars = account.user.vars
|
||||
# keep track of what variables we're appending the value of between chunks
|
||||
@vore_stack = []
|
||||
# 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
|
||||
|
||||
account.save
|
||||
account.user.save
|
||||
|
||||
status.text = @chunks.join
|
||||
status.save
|
||||
|
|
|
@ -313,6 +313,10 @@ class Account < ApplicationRecord
|
|||
self[:also_known_as] || []
|
||||
end
|
||||
|
||||
def field
|
||||
@field ||= fields.map { |f| [f.name, f.value] }.to_h
|
||||
end
|
||||
|
||||
def fields
|
||||
(self[:fields] || []).map { |f| Field.new(self, f) }
|
||||
end
|
||||
|
@ -352,6 +356,7 @@ class Account < ApplicationRecord
|
|||
self.fields = tmp
|
||||
end
|
||||
|
||||
# needs to be removed after migration
|
||||
def vars
|
||||
self[:vars]
|
||||
end
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
# chosen_languages :string is an Array
|
||||
# created_by_application_id :bigint(8)
|
||||
# approved :boolean default(TRUE), not null
|
||||
# vars :jsonb not null
|
||||
#
|
||||
|
||||
class User < ApplicationRecord
|
||||
|
@ -151,6 +152,10 @@ class User < ApplicationRecord
|
|||
attr_reader :invite_code
|
||||
attr_writer :external
|
||||
|
||||
def vars
|
||||
self[:vars]
|
||||
end
|
||||
|
||||
def confirmed?
|
||||
confirmed_at.present?
|
||||
end
|
||||
|
|
|
@ -100,8 +100,8 @@ class ImportService < BaseService
|
|||
end
|
||||
|
||||
def import_json_statuses
|
||||
@account.vars['_bangtags:disable'] = true
|
||||
@account.save
|
||||
@account.user.vars['_bangtags:disable'] = true
|
||||
@account.user.save
|
||||
|
||||
@data.each do |json|
|
||||
# skip if invalid status object
|
||||
|
@ -172,8 +172,8 @@ class ImportService < BaseService
|
|||
nil
|
||||
end
|
||||
|
||||
@account.vars.delete('_bangtags:disable')
|
||||
@account.save
|
||||
@account.user.vars.delete('_bangtags:disable')
|
||||
@account.user.save
|
||||
end
|
||||
|
||||
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.bigint "created_by_application_id"
|
||||
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 ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
||||
t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id"
|
||||
|
|
Loading…
Reference in New Issue