1
0
Fork 0
mirror of https://github.com/nov/fb_graph2 synced 2023-03-27 23:22:15 -04:00

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 = {}) def initialize(id, attributes = {})
super super
if attributes.include? :message_tags if attributes.include? :message_tags
self.message_tags = attributes[:message_tags].collect do |message_tag| self.message_tags = attributes[:message_tags].values.collect do |message_tags|
TaggedProfile.new message_tag[:id], message_tag message_tags.collect do |tag|
TaggedProfile.new tag[:id], tag
end end
end.flatten
end end
if attributes.include? :privacy if attributes.include? :privacy
self.privacy = Struct::Privacy.new attributes[: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.should_not be_blank
posts.each do |post| posts.each do |post|
post.should be_instance_of FbGraph2::Post post.should be_instance_of FbGraph2::Post
post.message_tags.count.should == 2
end end
end end
end end

View file

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