Use likes
and shares
totalItems on status creations and updates (#32620)
This commit is contained in:
parent
77cd16f4ee
commit
9074c1fac9
14 changed files with 326 additions and 14 deletions
|
@ -53,6 +53,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
ApplicationRecord.transaction do
|
||||
@status = Status.create!(@params)
|
||||
attach_tags(@status)
|
||||
attach_counts(@status)
|
||||
end
|
||||
|
||||
resolve_thread(@status)
|
||||
|
@ -166,6 +167,18 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
end
|
||||
end
|
||||
|
||||
def attach_counts(status)
|
||||
likes = @status_parser.favourites_count
|
||||
shares = @status_parser.reblogs_count
|
||||
return if likes.nil? && shares.nil?
|
||||
|
||||
status.status_stat.tap do |status_stat|
|
||||
status_stat.untrusted_reblogs_count = shares unless shares.nil?
|
||||
status_stat.untrusted_favourites_count = likes unless likes.nil?
|
||||
status_stat.save if status_stat.changed?
|
||||
end
|
||||
end
|
||||
|
||||
def process_tags
|
||||
return if @object['tag'].nil?
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue