-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
109 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ module Bot | |
policy_enforcement | ||
pass_thread_control | ||
game_play | ||
reaction | ||
].freeze | ||
|
||
class << self | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Facebook | ||
module Messenger | ||
module Incoming | ||
# The Message echo class represents an incoming Facebook Messenger message | ||
# @see https://developers.facebook.com/docs/messenger-platform/reference/webhook-events/message-reactions | ||
class MessageReaction | ||
include Facebook::Messenger::Incoming::Common | ||
|
||
def action | ||
@messaging['reaction']['action'] | ||
end | ||
|
||
def emoji | ||
@messaging['reaction']['emoji'] | ||
end | ||
|
||
def reaction | ||
@messaging['reaction']['reaction'] | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require 'spec_helper' | ||
|
||
describe Facebook::Messenger::Incoming::MessageReaction do | ||
let :payload do | ||
{ | ||
'sender' => { | ||
'id' => '3' | ||
}, | ||
'recipient' => { | ||
'id' => '3' | ||
}, | ||
'timestamp' => 145_776_419_762_7, | ||
'reaction' => { | ||
'action' => 'react', | ||
'emoji' => '👍', | ||
'reaction' => 'like' | ||
} | ||
} | ||
end | ||
|
||
subject { Facebook::Messenger::Incoming::MessageReaction.new(payload) } | ||
|
||
describe '.messaging' do | ||
it 'returns the original payload' do | ||
expect(subject.messaging).to eq(payload) | ||
end | ||
end | ||
|
||
describe '.sender' do | ||
it 'returns the sender' do | ||
expect(subject.sender).to eq(payload['sender']) | ||
end | ||
end | ||
|
||
describe '.recipient' do | ||
it 'returns the recipient' do | ||
expect(subject.recipient).to eq(payload['recipient']) | ||
end | ||
end | ||
|
||
describe '.action' do | ||
it 'returns the reaction action' do | ||
expect(subject.action).to eq(payload['reaction']['action']) | ||
end | ||
end | ||
|
||
describe '.emoji' do | ||
it 'returns the reaction emoji' do | ||
expect(subject.emoji).to eq(payload['reaction']['emoji']) | ||
end | ||
end | ||
|
||
describe '.reaction' do | ||
it 'returns the reaction reaction' do | ||
expect(subject.reaction).to eq(payload['reaction']['reaction']) | ||
end | ||
end | ||
end |