Merge pull request #125 from bryanbrunetti/fix-message-tags-format

Fix message tags format
This commit is contained in:
Nov Matake 2020-06-25 01:06:09 +09:00 committed by GitHub
commit a2dd44328e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 10 deletions

View File

@ -24,9 +24,11 @@ module FbGraph2
def initialize(id, attributes = {})
super
if attributes.include? :message_tags
self.message_tags = attributes[:message_tags].collect do |message_tag|
TaggedProfile.new message_tag[:id], message_tag
end
self.message_tags = attributes[:message_tags].values.collect do |message_tags|
message_tags.collect do |tag|
TaggedProfile.new tag[:id], tag
end
end.flatten
end
if attributes.include? :privacy
self.privacy = Struct::Privacy.new attributes[:privacy]

View File

@ -12,6 +12,7 @@ describe FbGraph2::Edge::Posts do
posts.should_not be_blank
posts.each do |post|
post.should be_instance_of FbGraph2::Post
post.message_tags.count.should == 2
end
end
end

View File

@ -12,13 +12,26 @@
}]
},
"message": "Nov Matake test",
"message_tags": [{
"id": "579612276",
"name": "Nov Matake",
"type": "user",
"offset": 0,
"length": 10
}],
"message_tags": {
"0": [
{
"id": "579612276",
"name": "Nov Matake",
"type": "user",
"offset": 0,
"length": 10
}
],
"11": [
{
"id": "10153177366617368",
"name": "Bryan Brunetti",
"type": "user",
"offset": 11,
"length": 14
}
]
},
"actions": [{
"name": "Comment",
"link": "https://www.facebook.com/579612276/posts/10152483324277277"