about summary refs log tree commit diff
path: root/app/serializers
diff options
context:
space:
mode:
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/manifest_serializer.rb57
-rw-r--r--app/serializers/rest/admin/report_serializer.rb3
-rw-r--r--app/serializers/rest/admin/webhook_event_serializer.rb26
-rw-r--r--app/serializers/rest/instance_serializer.rb2
4 files changed, 49 insertions, 39 deletions
diff --git a/app/serializers/manifest_serializer.rb b/app/serializers/manifest_serializer.rb
index ad05fdf6b..9827323a8 100644
--- a/app/serializers/manifest_serializer.rb
+++ b/app/serializers/manifest_serializer.rb
@@ -4,7 +4,19 @@ class ManifestSerializer < ActiveModel::Serializer
   include RoutingHelper
   include ActionView::Helpers::TextHelper
 
-  attributes :name, :short_name, :description,
+  ICON_SIZES = %w(
+    36
+    48
+    72
+    96
+    144
+    192
+    256
+    384
+    512
+  ).freeze
+
+  attributes :name, :short_name,
              :icons, :theme_color, :background_color,
              :display, :start_url, :scope,
              :share_target, :shortcuts
@@ -17,22 +29,18 @@ class ManifestSerializer < ActiveModel::Serializer
     object.site_title
   end
 
-  def description
-    strip_tags(object.site_short_description.presence || I18n.t('about.about_mastodon_html'))
-  end
-
   def icons
-    [
+    ICON_SIZES.map do |size|
       {
-        src: '/android-chrome-192x192.png',
-        sizes: '192x192',
+        src: full_pack_url("media/icons/android-chrome-#{size}x#{size}.png"),
+        sizes: "#{size}x#{size}",
         type: 'image/png',
-      },
-    ]
+      }
+    end
   end
 
   def theme_color
-    '#282c37'
+    '#6364FF'
   end
 
   def background_color
@@ -68,37 +76,12 @@ class ManifestSerializer < ActiveModel::Serializer
   def shortcuts
     [
       {
-        name: 'New toot',
+        name: 'Compose new post',
         url: '/web/publish',
-        icons: [
-          {
-            src: '/shortcuts/new-status.png',
-            type: 'image/png',
-            sizes: '192x192',
-          },
-        ],
       },
       {
         name: 'Notifications',
         url: '/web/notifications',
-        icons: [
-          {
-            src: '/shortcuts/notifications.png',
-            type: 'image/png',
-            sizes: '192x192',
-          },
-        ],
-      },
-      {
-        name: 'Direct messages',
-        url: '/web/conversations',
-        icons: [
-          {
-            src: '/shortcuts/direct.png',
-            type: 'image/png',
-            sizes: '192x192',
-          },
-        ],
       },
     ]
   end
diff --git a/app/serializers/rest/admin/report_serializer.rb b/app/serializers/rest/admin/report_serializer.rb
index 74bc0c520..237f41d8e 100644
--- a/app/serializers/rest/admin/report_serializer.rb
+++ b/app/serializers/rest/admin/report_serializer.rb
@@ -1,7 +1,8 @@
 # frozen_string_literal: true
 
 class REST::Admin::ReportSerializer < ActiveModel::Serializer
-  attributes :id, :action_taken, :category, :comment, :created_at, :updated_at
+  attributes :id, :action_taken, :action_taken_at, :category, :comment,
+             :created_at, :updated_at
 
   has_one :account, serializer: REST::Admin::AccountSerializer
   has_one :target_account, serializer: REST::Admin::AccountSerializer
diff --git a/app/serializers/rest/admin/webhook_event_serializer.rb b/app/serializers/rest/admin/webhook_event_serializer.rb
new file mode 100644
index 000000000..fe0ac23f9
--- /dev/null
+++ b/app/serializers/rest/admin/webhook_event_serializer.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class REST::Admin::WebhookEventSerializer < ActiveModel::Serializer
+  def self.serializer_for(model, options)
+    case model.class.name
+    when 'Account'
+      REST::Admin::AccountSerializer
+    when 'Report'
+      REST::Admin::ReportSerializer
+    else
+      super
+    end
+  end
+
+  attributes :event, :created_at
+
+  has_one :virtual_object, key: :object
+
+  def virtual_object
+    object.object
+  end
+
+  def event
+    object.type
+  end
+end
diff --git a/app/serializers/rest/instance_serializer.rb b/app/serializers/rest/instance_serializer.rb
index 48bbb55c8..2c8cd7734 100644
--- a/app/serializers/rest/instance_serializer.rb
+++ b/app/serializers/rest/instance_serializer.rb
@@ -39,7 +39,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
   end
 
   def thumbnail
-    instance_presenter.thumbnail ? full_asset_url(instance_presenter.thumbnail.file.url) : full_pack_url('media/images/preview.jpg')
+    instance_presenter.thumbnail ? full_asset_url(instance_presenter.thumbnail.file.url) : full_pack_url('media/images/preview.png')
   end
 
   def max_toot_chars