-
Notifications
You must be signed in to change notification settings - Fork 85
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
Adding APP_UNINSTALLED webhook #19
Conversation
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.
Awesome work 👏
$response = Registry::register( | ||
path: '/webhooks', | ||
topic: Topics::APP_UNINSTALLED, | ||
shop: $shop, | ||
accessToken: $session->getAccessToken(), | ||
); | ||
if ($response->isSuccess()) { | ||
Log::debug("Registered APP_UNINSTALLED webhook for shop $shop"); | ||
} else { | ||
Log::error( | ||
"Failed to register APP_UNINSTALLED webhook for shop $shop with response body: " . | ||
print_r($response->getBody(), true) | ||
); | ||
} |
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.
Maybe we can think of a way to pull this code into the library. Webhooks path could be a configuration. We already know the topics from the Registery::addHandler
. Not part of this PR though
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.
What I mean, we don't need to explicitly pass arguments to register
. Maybe we can have a method registerAll
that would register all webhooks.
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.
Hm, interesting, that's a really good idea. I just wonder if it wouldn't 'hide' the topics a little bit (and not sure if that's even a problem). We could also just make that an app method, though it's probably generic enough that it can go into the lib.
f0162db
to
148d64b
Compare
af6a78f
to
84216cb
Compare
WHY are these changes introduced?
Now that we have OAuth working, we can add a webhook handler for the
APP_UNINSTALLED
event, which will delete all of a shop's sessions in the database to make sure that shop goes through OAuth again if it ever reinstalls the app.WHAT is this pull request doing?
Using the library to handle the uninstallation webhook, and wiping all sessions for the shop when that happens, to ensure it is not considered installed in the future.
Type of change
Checklist