-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Instagram handler #392
Instagram handler #392
Conversation
@matmsa27 I see most codes are copied from the Facebook app channel type? Could that simplify the Instagram handler and possible make a few adjustment to the facebook app one to accommodate that as well? |
Refactor response field to external ID
Yes, most of the code is very similar to Facebook. I don't see that it would have a problem to use the same application, it would just leave us stuck in having to use the same for both, we can have rapidpro hosts that are only interested in one of the channels so it would be interesting to have this application distinction.
In case it is just one app for both types, it would be necessary to have all permissions for Facebook and Instagram, but if it is just an app for Instagram, it would not need to have all permissions, it would only be some that the Facebook channel uses and Instagram permissions.
Could you explain better what you thought about simplifying the Instagram handler if the same app is used for both? |
@Robi9 I think an approach as the way we handle Twilio types that share a lot of code so the Facebookapp type will be the one with the handler but we can initiate the IG channel type are well in the file all incoming messages will be receive on That way I think we remain with less code so easier to maintain |
@norkans7 Understood, I will adapt the Facebookapp handler to support the IG type. |
@norkans7 I decided to separate receiving messages, so Facebook's keep arriving at |
Hi, @norkans7 We are already ready to receive the feedbacks about this PR. |
@Robi9 good to have two webhooks configured, now I think we need to have the signature validation and webhook validation work for both. |
Codecov Report
@@ Coverage Diff @@
## main #392 +/- ##
==========================================
+ Coverage 71.70% 71.74% +0.03%
==========================================
Files 95 95
Lines 8257 8268 +11
==========================================
+ Hits 5921 5932 +11
Misses 1747 1747
Partials 589 589
Continue to review full report at Codecov.
|
|
||
var SendTestCasesIG = []ChannelSendTestCase{ | ||
{Label: "Plain Send", | ||
Text: "Simple Message", URN: "facebook:12345", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests should use instagram
URNs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not facebook
URNs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjust the instagram tests
handlers/facebookapp/facebookapp.go
Outdated
@@ -56,18 +56,20 @@ const ( | |||
payloadKey = "payload" | |||
) | |||
|
|||
func newHandler(channelType courier.ChannelType, name string, validateSignatures bool) courier.ChannelHandler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validateSignatures
is misleading as that parameter is for using channel UUIDs routes or not
urn urns.URN | ||
metadata map[string]string | ||
}{ | ||
{"facebook:1337", map[string]string{"name": "John Doe"}}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instagram
URN
return | ||
} | ||
|
||
// no name | ||
w.Write([]byte(`{ "first_name": "", "last_name": ""}`)) | ||
w.Write([]byte(`{ "name": ""}`)) | ||
})) | ||
graphURL = server.URL | ||
|
||
return server | ||
} | ||
|
||
func TestDescribe(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is best to have 2 separate tests one for FBA and the other for IG instead of the for loop on a slice of slices and the if condition
handlers/facebookapp/facebookapp.go
Outdated
} | ||
|
||
// no entries? ignore this request | ||
if len(payload.Entry) == 0 { | ||
return nil, fmt.Errorf("no entries found") | ||
} | ||
|
||
pageID := payload.Entry[0].ID | ||
EntryID := payload.Entry[0].ID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
entryID
}] | ||
}` | ||
|
||
var unkownMessagingEntry = `{ | ||
var unkownMessagingEntryFBA = `{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unknown.. not your typo but you can fix while you're here
According to issue and PR opened on Rapidpro repository.