-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add Instagram Direct Message handling #21
Conversation
IG needs to be sent to the messaging parent (FB) page ID instead of the IG ID, but the webhook contains the IG ID, so for now we default to sending to me/messages which infers the right page from the Access Token
@@ -44,6 +44,7 @@ public class FBMessageHandler implements MessageHandler<FBMessage> { | |||
private final String appSecret; | |||
|
|||
private final String accessToken; | |||
private final Boolean isInstagram; |
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.
in general you want to use primitives bool
where possible because it is not possible for them to be null
@@ -44,6 +44,7 @@ public class FBMessageHandler implements MessageHandler<FBMessage> { | |||
private final String appSecret; | |||
|
|||
private final String accessToken; | |||
@Nullable private final String connectedFacebookPageForInstagram; |
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.
@Nullable private final String connectedFacebookPageForInstagram; | |
private final @Nullable String connectedFacebookPageForInstagram; |
This just keeps the reformatting from adding a newline
@@ -10,60 +10,77 @@ | |||
|
|||
import com.fasterxml.jackson.annotation.JsonProperty; | |||
import com.google.common.base.Preconditions; | |||
import org.jetbrains.annotations.Nullable; |
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.
wrong Nullable, you want the Nullable from the checker framework
public String connectedFacebookPageForInstagram() { | ||
return connectedFacebookPageForInstagram; |
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.
public String connectedFacebookPageForInstagram() { | |
return connectedFacebookPageForInstagram; | |
public Optional<String> connectedFacebookPageForInstagram() { | |
return Optional.ofNullable(connectedFacebookPageForInstagram); |
pretty sure this the right code, but you want a return an Optional where possible for nullable values from functions
@Nullable | ||
private final String connectedFacebookPageForInstagram; |
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.
@Nullable | |
private final String connectedFacebookPageForInstagram; | |
private final @Nullable String connectedFacebookPageForInstagram; |
:)
return pageAccessToken; | ||
} | ||
|
||
public @Nullable Optional<String> connectedFacebookPageForInstagram() { |
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.
public @Nullable Optional<String> connectedFacebookPageForInstagram() { | |
public Optional<String> connectedFacebookPageForInstagram() { |
Adding the ability to handle instagram webhooks into the Facebook Message Handler - major differences are the FB page ID must be used for the call and message echos (notifs when the page sends a message) are sent along with messages, not a separate webhook subscription