about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorNaoki Kosaka <n.k@mail.yukimochi.net>2019-01-05 15:17:12 +0900
committerEugen Rochko <eugen@zeonfederated.com>2019-01-05 07:17:12 +0100
commitfae32634b15a29e66d5c2a04015f2f947cf54627 (patch)
treef551dd85c02d0769bc54f232f6085d11befd5875 /app/models
parent45899cfa691b1e4f43da98c456ae8faa584eb437 (diff)
Use Contact User as Relay, Report, Subscribe. (#9661)
* Use Contact User as Relay, Report, Subscribe.

* Use Account.representative to fetch contact user.

* Use find_local.

* No reason to use Account.representative in subscribe_service.

* Don't required representative!

* Fallback is included in Account.representative method.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/concerns/account_finder_concern.rb4
-rw-r--r--app/models/relay.rb2
2 files changed, 5 insertions, 1 deletions
diff --git a/app/models/concerns/account_finder_concern.rb b/app/models/concerns/account_finder_concern.rb
index 6b7237e89..7e3bbde09 100644
--- a/app/models/concerns/account_finder_concern.rb
+++ b/app/models/concerns/account_finder_concern.rb
@@ -12,6 +12,10 @@ module AccountFinderConcern
       find_remote(username, domain) || raise(ActiveRecord::RecordNotFound)
     end
 
+    def representative
+      find_local(Setting.site_contact_username.gsub(/\A@/, '')) || Account.local.find_by(suspended: false)
+    end
+
     def find_local(username)
       find_remote(username, nil)
     end
diff --git a/app/models/relay.rb b/app/models/relay.rb
index 75cb060b2..7478c110d 100644
--- a/app/models/relay.rb
+++ b/app/models/relay.rb
@@ -68,7 +68,7 @@ class Relay < ApplicationRecord
   end
 
   def some_local_account
-    @some_local_account ||= Account.local.find_by(suspended: false)
+    @some_local_account ||= Account.representative
   end
 
   def ensure_disabled