Skip to content

Commit

Permalink
Merge bcbcee1 into 2e7526b
Browse files Browse the repository at this point in the history
  • Loading branch information
denschub committed Feb 4, 2020
2 parents 2e7526b + bcbcee1 commit 4b8a2f1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
8 changes: 7 additions & 1 deletion app/presenters/avatar_presenter.rb
Expand Up @@ -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?
Expand All @@ -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
6 changes: 4 additions & 2 deletions app/presenters/photo_presenter.rb
Expand Up @@ -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
Expand All @@ -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
}
}

Expand Down
5 changes: 3 additions & 2 deletions lib/schemas/api_v1.json
Expand Up @@ -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": {
Expand Down
1 change: 1 addition & 0 deletions spec/presenters/photo_presenter_spec.rb
Expand Up @@ -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

0 comments on commit 4b8a2f1

Please sign in to comment.