0
0
Fork 0

Change author_account to be authors in REST API (#30846)

This commit is contained in:
Eugen Rochko 2024-06-27 15:17:18 +02:00 committed by GitHub
parent 6d1c1fd684
commit 096057b845
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 48 additions and 9 deletions

View file

@ -128,6 +128,22 @@ class PreviewCard < ApplicationRecord
@history ||= Trends::History.new('links', id)
end
def authors
@authors ||= [PreviewCard::Author.new(self)]
end
class Author < ActiveModelSerializers::Model
attributes :name, :url, :account
def initialize(preview_card)
super(
name: preview_card.author_name,
url: preview_card.author_url,
account: preview_card.author_account,
)
end
end
class << self
private