diff --git a/app/presenters/avatar_presenter.rb b/app/presenters/avatar_presenter.rb index c3656cc69a5..5b1b71f3956 100644 --- a/app/presenters/avatar_presenter.rb +++ b/app/presenters/avatar_presenter.rb @@ -6,7 +6,8 @@ def base_hash(with_default=false) avatar = { small: small(with_default), medium: medium(with_default), - large: large(with_default) + large: large(with_default), + raw: raw(with_default) }.compact avatar unless avatar.empty? @@ -21,6 +22,11 @@ def medium(with_default=false) end def large(with_default=false) + image_url(size: :scaled_full, fallback_to_default: with_default) + end + + def raw(with_default=false) + # ToDo: Replace me with the actual raw photo. image_url(fallback_to_default: with_default) end end diff --git a/app/presenters/photo_presenter.rb b/app/presenters/photo_presenter.rb index 2d2659400e1..0fa7e9a87fe 100644 --- a/app/presenters/photo_presenter.rb +++ b/app/presenters/photo_presenter.rb @@ -12,7 +12,8 @@ def base_hash sizes: { small: url(:thumb_small), medium: url(:thumb_medium), - large: url(:scaled_full) + large: url(:scaled_full), + raw: url } } end @@ -26,7 +27,8 @@ def as_api_json(full=false) sizes: { small: url(:thumb_small), medium: url(:thumb_medium), - large: url(:scaled_full) + large: url(:scaled_full), + raw: url } } diff --git a/lib/schemas/api_v1.json b/lib/schemas/api_v1.json index 46342dd48be..84511bd4a8c 100644 --- a/lib/schemas/api_v1.json +++ b/lib/schemas/api_v1.json @@ -205,12 +205,13 @@ "photo_sizes": { "type": "object", "properties": { + "raw": { "$ref": "https://diaspora.software/api/v1/schema.json#/definitions/url" }, "large": { "$ref": "https://diaspora.software/api/v1/schema.json#/definitions/url" }, "medium": { "$ref": "https://diaspora.software/api/v1/schema.json#/definitions/url" }, "small": { "$ref": "https://diaspora.software/api/v1/schema.json#/definitions/url" } }, - "required": ["large", "medium", "small"], - "additionalProperties": true + "required": ["raw", "large", "medium", "small"], + "additionalProperties": false }, "photo_dimensions": { diff --git a/spec/presenters/photo_presenter_spec.rb b/spec/presenters/photo_presenter_spec.rb index e5bcb5677db..840a8ed71fd 100644 --- a/spec/presenters/photo_presenter_spec.rb +++ b/spec/presenters/photo_presenter_spec.rb @@ -34,6 +34,7 @@ def confirm_photo_format(photo, ref_photo) expect(photo[:sizes][:small]).to be_truthy expect(photo[:sizes][:medium]).to be_truthy expect(photo[:sizes][:large]).to be_truthy + expect(photo[:sizes][:raw]).to be_truthy end # rubocop:enable Metrics/AbcSize end