-
Notifications
You must be signed in to change notification settings - Fork 664
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
Implement view submission and view closed handling on @slack/interactive-messages #904
Conversation
… handlers, and misc spelling corrections.
Codecov Report
@@ Coverage Diff @@
## master #904 +/- ##
==========================================
- Coverage 95.63% 95.17% -0.47%
==========================================
Files 12 12
Lines 687 725 +38
Branches 147 164 +17
==========================================
+ Hits 657 690 +33
- Misses 11 13 +2
- Partials 19 22 +3
Continue to review full report at Codecov.
|
* | ||
* TODO: describe the payload and return values more specifically? | ||
*/ | ||
type ViewSubmissionHandler = (payload: any) => any | Promise<any> | undefined; |
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.
The types for these are in Bolt if you want them - https://github.com/slackapi/bolt/blob/master/src/types/view/index.ts
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.
Great idea!
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.
On second thought - the options are to depend on @slack/bolt
to get these types, to duplicate those types in @slack/interactive-messages
, or to move those types into @slack/types
(and then refactor Bolt and this package to grab those types from that package).
I think the ideal solution is the last one, but I don't think its wise to increase scope of this feature to get that done. In the meantime, I think we can proceed with this approach and revisit the refactoring of all payload types into @slack/types
at a later time. Many other packages might also benefit from this.
@@ -486,6 +543,52 @@ export class SlackMessageAdapter { | |||
} | |||
} | |||
|
|||
if (constraints.handlerType === StoredConstraintsType.ViewSubmission) { |
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 checks seem correct, but this and the ViewClosed constraints are the same. Is there a reason we can't combine them to reduce code duplication?
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.
There's a slight difference which is the first conditional within each section. The first checks for view_submission
and the second checks for view_closed
. But now that you point it out there's likely a way to reduce the code duplication - thanks!
*/ | ||
export interface ViewConstraints { | ||
callbackId?: string | RegExp; | ||
externalId?: string; |
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.
Should we allow RegExp
for externalId
too? Since they are unique on a per-user basis, it would be really hard to setup a handler for them with a type of string.
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.
Earlier I was trying not to expand scope so I didn't add RegExp matching to anything new - but now that you point it out that totally makes sense as a use case. It's not too much work to add that in now, so I might as well.
Hello,
Maybe I am doing something wrong? |
@pitininja you're totally right! thanks for catching that. |
@pitininja fixed the issue you pointed out (and the ones @shanedewael pointed out too). we're likely releasing this change tomorrow. |
Summary
Implements view submission handling as described in #288
Requirements (place an
x
in each[ ]
)