Skip to content

Commit

Permalink
Update Photo object according to latest API
Browse files Browse the repository at this point in the history
  • Loading branch information
L-Eugene committed Sep 13, 2021
1 parent f94ce3c commit 73c26ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 1 addition & 2 deletions lib/vk/vk_informer_attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ def domain_prefix(domain, type = :markdown)
end

def get_album_image(obj)
k = %w[1280 807 604 130 75].find { |x| obj.key? "photo_#{x}".to_sym }
k.nil? ? nil : obj["photo_#{k}".to_sym]
obj[:sizes].max { |a, b| a[:height] <=> b[:height] }[:url]
end
end
end
14 changes: 8 additions & 6 deletions spec/fixtures/vk_informer_attachment/album/hash.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
"id": 23456,
"album_id": 12456,
"owner_id": 123,
"photo_75": "http://example.com/photo75.jpg",
"photo_130": "http://example.com/photo75.jpg",
"photo_604": "http://example.com/photo75.jpg",
"photo_807": "http://example.com/photo75.jpg",
"photo_1280": "http://example.com/photo75.jpg"
"sizes": [
{ "height": 75, "url": "http://example.com/photo75.jpg" },
{ "height": 130, "url": "http://example.com/photo130.jpg" },
{ "height": 604, "url": "http://example.com/photo604.jpg" },
{ "height": 807, "url": "http://example.com/photo807.jpg" },
{ "height": 1280, "url": "http://example.com/photo1280.jpg" }
]
},
"title": "Album title",
"description": "Album description"
}
}
}

0 comments on commit 73c26ed

Please sign in to comment.