Add backend support for local_only on status create
Based off ThibG implementation on glitch #502
This commit is contained in:
@ -130,6 +130,10 @@ class Status < ApplicationRecord
|
||||
attributes['local'] || uri.nil?
|
||||
end
|
||||
|
||||
def local_only?
|
||||
local_only
|
||||
end
|
||||
|
||||
def reblog?
|
||||
!reblog_of_id.nil?
|
||||
end
|
||||
@ -222,6 +226,8 @@ class Status < ApplicationRecord
|
||||
|
||||
around_create Mastodon::Snowflake::Callbacks
|
||||
|
||||
before_create :set_locality
|
||||
|
||||
before_validation :prepare_contents, if: :local?
|
||||
before_validation :set_reblog
|
||||
before_validation :set_visibility
|
||||
@ -445,6 +451,10 @@ class Status < ApplicationRecord
|
||||
self.local = account.local?
|
||||
end
|
||||
|
||||
def set_locality
|
||||
self.local_only = reblog.local_only if reblog?
|
||||
end
|
||||
|
||||
def update_statistics
|
||||
return unless public_visibility? || unlisted_visibility?
|
||||
ActivityTracker.increment('activity:statuses:local')
|
||||
|
Reference in New Issue
Block a user