From 4ec1771165ab8dd40e52804fd087eacfab25290b Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 28 Sep 2017 15:31:31 +0200 Subject: Add ability to specify alternative text for media attachments (#5123) * Fix #117 - Add ability to specify alternative text for media attachments - POST /api/v1/media accepts `description` straight away - PUT /api/v1/media/:id to update `description` (only for unattached ones) - Serialized as `name` of Document object in ActivityPub - Uploads form adjusted for better performance and description input * Add tests * Change undo button blend mode to difference --- app/serializers/activitypub/note_serializer.rb | 6 +++++- app/serializers/rest/media_attachment_serializer.rb | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'app/serializers') diff --git a/app/serializers/activitypub/note_serializer.rb b/app/serializers/activitypub/note_serializer.rb index f94c3b9dc..4dbf6a444 100644 --- a/app/serializers/activitypub/note_serializer.rb +++ b/app/serializers/activitypub/note_serializer.rb @@ -89,12 +89,16 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer class MediaAttachmentSerializer < ActiveModel::Serializer include RoutingHelper - attributes :type, :media_type, :url + attributes :type, :media_type, :url, :name def type 'Document' end + def name + object.description + end + def media_type object.file_content_type end diff --git a/app/serializers/rest/media_attachment_serializer.rb b/app/serializers/rest/media_attachment_serializer.rb index f6e7c79d1..e6e9c8e82 100644 --- a/app/serializers/rest/media_attachment_serializer.rb +++ b/app/serializers/rest/media_attachment_serializer.rb @@ -4,7 +4,8 @@ class REST::MediaAttachmentSerializer < ActiveModel::Serializer include RoutingHelper attributes :id, :type, :url, :preview_url, - :remote_url, :text_url, :meta + :remote_url, :text_url, :meta, + :description def id object.id.to_s -- cgit From 47ecd652d3f8256a191401f005d42760e858e6de Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 2 Oct 2017 01:23:32 +0200 Subject: Make Chrome splash screen same color as web UI's background color (#5169) --- app/controllers/manifests_controller.rb | 8 ++--- app/serializers/manifest_serializer.rb | 52 +++++++++++++++++++++++++++ app/views/manifests/show.json.rabl | 11 ------ spec/controllers/manifests_controller_spec.rb | 4 --- 4 files changed, 54 insertions(+), 21 deletions(-) create mode 100644 app/serializers/manifest_serializer.rb delete mode 100644 app/views/manifests/show.json.rabl (limited to 'app/serializers') diff --git a/app/controllers/manifests_controller.rb b/app/controllers/manifests_controller.rb index 832e1eb6f..ac267c229 100644 --- a/app/controllers/manifests_controller.rb +++ b/app/controllers/manifests_controller.rb @@ -1,11 +1,7 @@ # frozen_string_literal: true class ManifestsController < ApplicationController - before_action :set_instance_presenter - - def show; end - - def set_instance_presenter - @instance_presenter = InstancePresenter.new + def show + render json: InstancePresenter.new, serializer: ManifestSerializer end end diff --git a/app/serializers/manifest_serializer.rb b/app/serializers/manifest_serializer.rb new file mode 100644 index 000000000..95bcc21bb --- /dev/null +++ b/app/serializers/manifest_serializer.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +class ManifestSerializer < ActiveModel::Serializer + include RoutingHelper + include ActionView::Helpers::TextHelper + + attributes :name, :short_name, :description, + :icons, :theme_color, :background_color, + :display, :start_url, :scope + + def name + object.site_title + end + + def short_name + object.site_title + end + + def description + strip_tags(object.site_description.presence || I18n.t('about.about_mastodon_html')) + end + + def icons + [ + { + src: '/android-chrome-192x192.png', + sizes: '192x192', + type: 'image/png', + }, + ] + end + + def theme_color + '#282c37' + end + + def background_color + '#191b22' + end + + def display + 'standalone' + end + + def start_url + '/web/timelines/home' + end + + def scope + root_url + end +end diff --git a/app/views/manifests/show.json.rabl b/app/views/manifests/show.json.rabl deleted file mode 100644 index ee0a70324..000000000 --- a/app/views/manifests/show.json.rabl +++ /dev/null @@ -1,11 +0,0 @@ -object false - -node(:name) { Setting.site_title } -node(:short_name) { Setting.site_title } -node(:description) { strip_tags(Setting.site_description.presence || I18n.t('about.about_mastodon_html')) } -node(:icons) { [{ src: '/android-chrome-192x192.png', sizes: '192x192', type: 'image/png' }] } -node(:theme_color) { '#282c37' } -node(:background_color) { '#d9e1e8' } -node(:display) { 'standalone' } -node(:start_url) { '/web/timelines/home' } -node(:scope) { root_url } diff --git a/spec/controllers/manifests_controller_spec.rb b/spec/controllers/manifests_controller_spec.rb index 6f188fa35..71967e4f0 100644 --- a/spec/controllers/manifests_controller_spec.rb +++ b/spec/controllers/manifests_controller_spec.rb @@ -8,10 +8,6 @@ describe ManifestsController do get :show, format: :json end - it 'assigns @instance_presenter' do - expect(assigns(:instance_presenter)).to be_kind_of InstancePresenter - end - it 'returns http success' do expect(response).to have_http_status(:success) end -- cgit From b9c76e2edbc372e1b472f6ba480631b79fe24722 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 5 Oct 2017 23:41:47 +0200 Subject: When processing custom emoji, ensure a non-animated version exists (#5230) Use the non-animated version in web UI, but return both in API --- app/javascript/mastodon/emoji.js | 2 +- app/javascript/mastodon/reducers/statuses.js | 2 +- app/lib/formatter.rb | 2 +- app/models/custom_emoji.rb | 2 +- app/serializers/rest/custom_emoji_serializer.rb | 6 +++++- 5 files changed, 9 insertions(+), 5 deletions(-) (limited to 'app/serializers') diff --git a/app/javascript/mastodon/emoji.js b/app/javascript/mastodon/emoji.js index 1df2373d9..cf0077958 100644 --- a/app/javascript/mastodon/emoji.js +++ b/app/javascript/mastodon/emoji.js @@ -52,7 +52,7 @@ export const buildCustomEmojis = customEmojis => { customEmojis.forEach(emoji => { const shortcode = emoji.get('shortcode'); - const url = emoji.get('url'); + const url = emoji.get('static_url'); const name = shortcode.replace(':', ''); emojis.push({ diff --git a/app/javascript/mastodon/reducers/statuses.js b/app/javascript/mastodon/reducers/statuses.js index 2d72b12e8..ed16e016f 100644 --- a/app/javascript/mastodon/reducers/statuses.js +++ b/app/javascript/mastodon/reducers/statuses.js @@ -60,7 +60,7 @@ const normalizeStatus = (state, status) => { const searchContent = [status.spoiler_text, status.content].join(' ').replace(/
/g, '\n').replace(/<\/p>

/g, '\n\n'); const emojiMap = normalStatus.emojis.reduce((obj, emoji) => { - obj[`:${emoji.shortcode}:`] = emoji.url; + obj[`:${emoji.shortcode}:`] = emoji.static_url; return obj; }, {}); diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb index 42cd72990..d7f6ec47b 100644 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@ -92,7 +92,7 @@ class Formatter def encode_custom_emojis(html, emojis) return html if emojis.empty? - emoji_map = emojis.map { |e| [e.shortcode, full_asset_url(e.image.url)] }.to_h + emoji_map = emojis.map { |e| [e.shortcode, full_asset_url(e.image.url(:static))] }.to_h i = -1 inside_tag = false diff --git a/app/models/custom_emoji.rb b/app/models/custom_emoji.rb index e80c58155..9e9be5e12 100644 --- a/app/models/custom_emoji.rb +++ b/app/models/custom_emoji.rb @@ -21,7 +21,7 @@ class CustomEmoji < ApplicationRecord :(#{SHORTCODE_RE_FRAGMENT}): (?=[^[:alnum:]:]|$)/x - has_attached_file :image + has_attached_file :image, styles: { static: { format: 'png', convert_options: '-coalesce -strip' } } validates_attachment :image, content_type: { content_type: 'image/png' }, presence: true, size: { in: 0..50.kilobytes } validates :shortcode, uniqueness: { scope: :domain }, format: { with: /\A#{SHORTCODE_RE_FRAGMENT}\z/ }, length: { minimum: 2 } diff --git a/app/serializers/rest/custom_emoji_serializer.rb b/app/serializers/rest/custom_emoji_serializer.rb index b744dd4ec..b958e6a5d 100644 --- a/app/serializers/rest/custom_emoji_serializer.rb +++ b/app/serializers/rest/custom_emoji_serializer.rb @@ -3,9 +3,13 @@ class REST::CustomEmojiSerializer < ActiveModel::Serializer include RoutingHelper - attributes :shortcode, :url + attributes :shortcode, :url, :static_url def url full_asset_url(object.image.url) end + + def static_url + full_asset_url(object.image.url(:static)) + end end -- cgit From 3a3475450e46f670e8beaf4bf804b820ad39a5f9 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 7 Oct 2017 17:43:42 +0200 Subject: Encode custom emojis as resolveable objects in ActivityPub (#5243) * Encode custom emojis as resolveable objects in ActivityPub * Improve code style --- app/controllers/accounts_controller.rb | 5 +++- app/controllers/emojis_controller.rb | 22 ++++++++++++++++ app/controllers/follower_accounts_controller.rb | 5 +++- app/controllers/following_accounts_controller.rb | 5 +++- app/controllers/statuses_controller.rb | 10 ++++++-- app/controllers/tags_controller.rb | 5 +++- app/lib/activitypub/activity/create.rb | 12 ++++++--- app/lib/activitypub/tag_manager.rb | 2 ++ app/models/custom_emoji.rb | 6 +++++ app/serializers/activitypub/actor_serializer.rb | 18 ++------------ app/serializers/activitypub/emoji_serializer.rb | 29 ++++++++++++++++++++++ app/serializers/activitypub/image_serializer.rb | 19 ++++++++++++++ app/serializers/activitypub/note_serializer.rb | 17 +------------ config/routes.rb | 5 ++-- .../20171006142024_add_uri_to_custom_emojis.rb | 6 +++++ db/schema.rb | 4 ++- spec/lib/activitypub/activity/create_spec.rb | 10 +++++--- 17 files changed, 132 insertions(+), 48 deletions(-) create mode 100644 app/controllers/emojis_controller.rb create mode 100644 app/serializers/activitypub/emoji_serializer.rb create mode 100644 app/serializers/activitypub/image_serializer.rb create mode 100644 db/migrate/20171006142024_add_uri_to_custom_emojis.rb (limited to 'app/serializers') diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 26ab6636b..75915b337 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -26,7 +26,10 @@ class AccountsController < ApplicationController end format.json do - render json: @account, serializer: ActivityPub::ActorSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json' + render json: @account, + serializer: ActivityPub::ActorSerializer, + adapter: ActivityPub::Adapter, + content_type: 'application/activity+json' end end end diff --git a/app/controllers/emojis_controller.rb b/app/controllers/emojis_controller.rb new file mode 100644 index 000000000..a82b9340b --- /dev/null +++ b/app/controllers/emojis_controller.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class EmojisController < ApplicationController + before_action :set_emoji + + def show + respond_to do |format| + format.json do + render json: @emoji, + serializer: ActivityPub::EmojiSerializer, + adapter: ActivityPub::Adapter, + content_type: 'application/activity+json' + end + end + end + + private + + def set_emoji + @emoji = CustomEmoji.local.find(params[:id]) + end +end diff --git a/app/controllers/follower_accounts_controller.rb b/app/controllers/follower_accounts_controller.rb index 8eb4d2822..399e79665 100644 --- a/app/controllers/follower_accounts_controller.rb +++ b/app/controllers/follower_accounts_controller.rb @@ -10,7 +10,10 @@ class FollowerAccountsController < ApplicationController format.html format.json do - render json: collection_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json' + render json: collection_presenter, + serializer: ActivityPub::CollectionSerializer, + adapter: ActivityPub::Adapter, + content_type: 'application/activity+json' end end end diff --git a/app/controllers/following_accounts_controller.rb b/app/controllers/following_accounts_controller.rb index 1ca6f0fe7..1e73d4bd4 100644 --- a/app/controllers/following_accounts_controller.rb +++ b/app/controllers/following_accounts_controller.rb @@ -10,7 +10,10 @@ class FollowingAccountsController < ApplicationController format.html format.json do - render json: collection_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json' + render json: collection_presenter, + serializer: ActivityPub::CollectionSerializer, + adapter: ActivityPub::Adapter, + content_type: 'application/activity+json' end end end diff --git a/app/controllers/statuses_controller.rb b/app/controllers/statuses_controller.rb index 65206ea96..e8a360fb5 100644 --- a/app/controllers/statuses_controller.rb +++ b/app/controllers/statuses_controller.rb @@ -21,13 +21,19 @@ class StatusesController < ApplicationController end format.json do - render json: @status, serializer: ActivityPub::NoteSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json' + render json: @status, + serializer: ActivityPub::NoteSerializer, + adapter: ActivityPub::Adapter, + content_type: 'application/activity+json' end end end def activity - render json: @status, serializer: ActivityPub::ActivitySerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json' + render json: @status, + serializer: ActivityPub::ActivitySerializer, + adapter: ActivityPub::Adapter, + content_type: 'application/activity+json' end def embed diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 3001b2ee3..240ef058a 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -12,7 +12,10 @@ class TagsController < ApplicationController format.html format.json do - render json: collection_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json' + render json: collection_presenter, + serializer: ActivityPub::CollectionSerializer, + adapter: ActivityPub::Adapter, + content_type: 'application/activity+json' end end end diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index be656de48..9421a0aa7 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -86,15 +86,19 @@ class ActivityPub::Activity::Create < ActivityPub::Activity end def process_emoji(tag, _status) - return if tag['name'].blank? || tag['href'].blank? + return if skip_download? + return if tag['name'].blank? || tag['icon'].blank? || tag['icon']['url'].blank? shortcode = tag['name'].delete(':') + image_url = tag['icon']['url'] + uri = tag['id'] + updated = tag['updated'] emoji = CustomEmoji.find_by(shortcode: shortcode, domain: @account.domain) - return if !emoji.nil? || skip_download? + return unless emoji.nil? || emoji.updated_at >= updated - emoji = CustomEmoji.new(domain: @account.domain, shortcode: shortcode) - emoji.image_remote_url = tag['href'] + emoji ||= CustomEmoji.new(domain: @account.domain, shortcode: shortcode, uri: uri) + emoji.image_remote_url = image_url emoji.save end diff --git a/app/lib/activitypub/tag_manager.rb b/app/lib/activitypub/tag_manager.rb index 4ec3b8c56..0708713e6 100644 --- a/app/lib/activitypub/tag_manager.rb +++ b/app/lib/activitypub/tag_manager.rb @@ -33,6 +33,8 @@ class ActivityPub::TagManager when :note, :comment, :activity return activity_account_status_url(target.account, target) if target.reblog? account_status_url(target.account, target) + when :emoji + emoji_url(target) end end diff --git a/app/models/custom_emoji.rb b/app/models/custom_emoji.rb index 258b50c82..65d9840d5 100644 --- a/app/models/custom_emoji.rb +++ b/app/models/custom_emoji.rb @@ -13,6 +13,8 @@ # created_at :datetime not null # updated_at :datetime not null # disabled :boolean default(FALSE), not null +# uri :string +# image_remote_url :string # class CustomEmoji < ApplicationRecord @@ -37,6 +39,10 @@ class CustomEmoji < ApplicationRecord domain.nil? end + def object_type + :emoji + end + class << self def from_text(text, domain) return [] if text.blank? diff --git a/app/serializers/activitypub/actor_serializer.rb b/app/serializers/activitypub/actor_serializer.rb index a11178f5b..896d67115 100644 --- a/app/serializers/activitypub/actor_serializer.rb +++ b/app/serializers/activitypub/actor_serializer.rb @@ -10,20 +10,6 @@ class ActivityPub::ActorSerializer < ActiveModel::Serializer has_one :public_key, serializer: ActivityPub::PublicKeySerializer - class ImageSerializer < ActiveModel::Serializer - include RoutingHelper - - attributes :type, :url - - def type - 'Image' - end - - def url - full_asset_url(object.url(:original)) - end - end - class EndpointsSerializer < ActiveModel::Serializer include RoutingHelper @@ -36,8 +22,8 @@ class ActivityPub::ActorSerializer < ActiveModel::Serializer has_one :endpoints, serializer: EndpointsSerializer - has_one :icon, serializer: ImageSerializer, if: :avatar_exists? - has_one :image, serializer: ImageSerializer, if: :header_exists? + has_one :icon, serializer: ActivityPub::ImageSerializer, if: :avatar_exists? + has_one :image, serializer: ActivityPub::ImageSerializer, if: :header_exists? def id account_url(object) diff --git a/app/serializers/activitypub/emoji_serializer.rb b/app/serializers/activitypub/emoji_serializer.rb new file mode 100644 index 000000000..7b06b1e5d --- /dev/null +++ b/app/serializers/activitypub/emoji_serializer.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class ActivityPub::EmojiSerializer < ActiveModel::Serializer + include RoutingHelper + + attributes :id, :type, :name, :updated + + has_one :icon, serializer: ActivityPub::ImageSerializer + + def id + ActivityPub::TagManager.instance.uri_for(object) + end + + def type + 'Emoji' + end + + def icon + object.image + end + + def updated + object.updated_at.iso8601 + end + + def name + ":#{object.shortcode}:" + end +end diff --git a/app/serializers/activitypub/image_serializer.rb b/app/serializers/activitypub/image_serializer.rb new file mode 100644 index 000000000..a015c6b1b --- /dev/null +++ b/app/serializers/activitypub/image_serializer.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class ActivityPub::ImageSerializer < ActiveModel::Serializer + include RoutingHelper + + attributes :type, :media_type, :url + + def type + 'Image' + end + + def url + full_asset_url(object.url(:original)) + end + + def media_type + object.content_type + end +end diff --git a/app/serializers/activitypub/note_serializer.rb b/app/serializers/activitypub/note_serializer.rb index 4dbf6a444..24c39f3c9 100644 --- a/app/serializers/activitypub/note_serializer.rb +++ b/app/serializers/activitypub/note_serializer.rb @@ -142,21 +142,6 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer end end - class CustomEmojiSerializer < ActiveModel::Serializer - include RoutingHelper - - attributes :type, :href, :name - - def type - 'Emoji' - end - - def href - full_asset_url(object.image.url) - end - - def name - ":#{object.shortcode}:" - end + class CustomEmojiSerializer < ActivityPub::EmojiSerializer end end diff --git a/config/routes.rb b/config/routes.rb index cc1f66e52..bd7068b5c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -96,8 +96,9 @@ Rails.application.routes.draw do resources :sessions, only: [:destroy] end - resources :media, only: [:show] - resources :tags, only: [:show] + resources :media, only: [:show] + resources :tags, only: [:show] + resources :emojis, only: [:show] get '/media_proxy/:id/(*any)', to: 'media_proxy#show', as: :media_proxy diff --git a/db/migrate/20171006142024_add_uri_to_custom_emojis.rb b/db/migrate/20171006142024_add_uri_to_custom_emojis.rb new file mode 100644 index 000000000..04dfcf397 --- /dev/null +++ b/db/migrate/20171006142024_add_uri_to_custom_emojis.rb @@ -0,0 +1,6 @@ +class AddUriToCustomEmojis < ActiveRecord::Migration[5.1] + def change + add_column :custom_emojis, :uri, :string + add_column :custom_emojis, :image_remote_url, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 3358e2997..7180d3515 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171005171936) do +ActiveRecord::Schema.define(version: 20171006142024) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -99,6 +99,8 @@ ActiveRecord::Schema.define(version: 20171005171936) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.boolean "disabled", default: false, null: false + t.string "uri" + t.string "image_remote_url" t.index ["shortcode", "domain"], name: "index_custom_emojis_on_shortcode_and_domain", unique: true end diff --git a/spec/lib/activitypub/activity/create_spec.rb b/spec/lib/activitypub/activity/create_spec.rb index cdd499150..3c3991c13 100644 --- a/spec/lib/activitypub/activity/create_spec.rb +++ b/spec/lib/activitypub/activity/create_spec.rb @@ -290,7 +290,9 @@ RSpec.describe ActivityPub::Activity::Create do tag: [ { type: 'Emoji', - href: 'http://example.com/emoji.png', + icon: { + url: 'http://example.com/emoji.png', + }, name: 'tinking', }, ], @@ -314,7 +316,9 @@ RSpec.describe ActivityPub::Activity::Create do tag: [ { type: 'Emoji', - href: 'http://example.com/emoji.png', + icon: { + url: 'http://example.com/emoji.png', + }, }, ], } @@ -326,7 +330,7 @@ RSpec.describe ActivityPub::Activity::Create do end end - context 'with emojis missing href' do + context 'with emojis missing icon' do let(:object_json) do { id: 'bar', -- cgit From 967e70663fc694836e3b99595bea74485557cbd1 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 7 Oct 2017 18:55:48 +0200 Subject: In REST API, when URL can be missing, cast it to nil (#5259) --- app/serializers/rest/application_serializer.rb | 4 ++++ app/serializers/rest/media_attachment_serializer.rb | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'app/serializers') diff --git a/app/serializers/rest/application_serializer.rb b/app/serializers/rest/application_serializer.rb index a8945f66e..a9316cd4b 100644 --- a/app/serializers/rest/application_serializer.rb +++ b/app/serializers/rest/application_serializer.rb @@ -15,4 +15,8 @@ class REST::ApplicationSerializer < ActiveModel::Serializer def client_secret object.secret end + + def website + object.website.presence + end end diff --git a/app/serializers/rest/media_attachment_serializer.rb b/app/serializers/rest/media_attachment_serializer.rb index e6e9c8e82..51011788b 100644 --- a/app/serializers/rest/media_attachment_serializer.rb +++ b/app/serializers/rest/media_attachment_serializer.rb @@ -19,6 +19,10 @@ class REST::MediaAttachmentSerializer < ActiveModel::Serializer end end + def remote_url + object.remote_url.presence + end + def preview_url if object.needs_redownload? media_proxy_url(object.id, :small) -- cgit From 6e4046fc3f3973ba0b6994930a8b58726e507003 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 8 Oct 2017 14:41:59 +0200 Subject: Fix #5178 - Use object URI only in Announce, instead of embedding (#5266) --- app/serializers/activitypub/activity_serializer.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'app/serializers') diff --git a/app/serializers/activitypub/activity_serializer.rb b/app/serializers/activitypub/activity_serializer.rb index b252e008b..df399211c 100644 --- a/app/serializers/activitypub/activity_serializer.rb +++ b/app/serializers/activitypub/activity_serializer.rb @@ -3,10 +3,11 @@ class ActivityPub::ActivitySerializer < ActiveModel::Serializer attributes :id, :type, :actor, :published, :to, :cc - has_one :proper, key: :object, serializer: ActivityPub::NoteSerializer + has_one :proper, key: :object, serializer: ActivityPub::NoteSerializer, unless: :announce? + attribute :proper_uri, key: :object, if: :announce? def id - [ActivityPub::TagManager.instance.activity_uri_for(object)].join + ActivityPub::TagManager.instance.activity_uri_for(object) end def type @@ -29,6 +30,10 @@ class ActivityPub::ActivitySerializer < ActiveModel::Serializer ActivityPub::TagManager.instance.cc(object) end + def proper_uri + ActivityPub::TagManager.instance.uri_for(object.proper) + end + def announce? object.reblog? end -- cgit