Skip to content

Commit

Permalink
CustomAudience.emails= bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
martin sarsale committed May 21, 2015
1 parent 9a7db6d commit 26bf596
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/zuck/facebook/custom_audience.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ class CustomAudience < RawFbObject


def emails=(emails)
emails = Array(emails)
audience = emails.map{|email|
{email_hash: Digest::MD5.hexdigest(email)}
Digest::SHA256.hexdigest(email)
}
add_users(audience, "md5")
add_users(audience, "EMAIL_SHA256")
end

alias :<< :emails=

def add_users(audience, hash_type)
create_connection(graph, self.id, :users, {users: audience.to_json, hash_type: hash_type})
create_connection(graph, self.id, :users, payload: {data: audience, schema: hash_type}.to_json)
end

def share(custom_graph=nil, destination_account_ids:)
Expand Down

0 comments on commit 26bf596

Please sign in to comment.