-
Notifications
You must be signed in to change notification settings - Fork 289
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
Interactive Message Response Size Handling #1263
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7e3276f
Add: Interactive Message Response Size Handling
sadath-12 6c0a1b4
Add: Interactive Message Response Size Handling
sadath-12 84ff204
Fix: removed redeclared of variable
sadath-12 a470bf4
Fix: go linting
sadath-12 b9a2242
go lint fix
sadath-12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,10 @@ import ( | |
// - split to multiple files in a separate package, | ||
// - review all the methods and see if they can be simplified. | ||
|
||
const ( | ||
MaxListingLimit = 45 | ||
) | ||
|
||
var _ Bot = &SocketSlack{} | ||
|
||
// SocketSlack listens for user's message, execute commands and sends back the response. | ||
|
@@ -407,14 +411,33 @@ func (b *SocketSlack) send(ctx context.Context, event slackMessage, resp interac | |
var file *slack.File | ||
var err error | ||
if len(markdown) >= slackMaxMessageSize { | ||
file, err = uploadFileToSlack(ctx, event.Channel, resp, b.client, event.ThreadTimeStamp) | ||
if err != nil { | ||
return err | ||
} | ||
resp = interactive.CoreMessage{ | ||
Message: api.Message{ | ||
PlaintextInputs: resp.PlaintextInputs, | ||
}, | ||
if strings.Contains(resp.Description, "logs") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
file, err = uploadFileToSlack(ctx, event.Channel, resp, b.client, event.ThreadTimeStamp) | ||
if err != nil { | ||
return err | ||
} | ||
resp = interactive.CoreMessage{ | ||
Message: api.Message{ | ||
PlaintextInputs: resp.PlaintextInputs, | ||
}, | ||
} | ||
} else { | ||
newBlocks := strings.Split(resp.BaseBody.CodeBlock, "\n") | ||
|
||
newBlocks = newBlocks[:MaxListingLimit] | ||
|
||
result := strings.Join(newBlocks, "\n") | ||
|
||
resp = interactive.CoreMessage{ | ||
Description: resp.Description, | ||
Message: api.Message{ | ||
PlaintextInputs: resp.PlaintextInputs, | ||
|
||
BaseBody: api.Body{ | ||
CodeBlock: result, | ||
}, | ||
}, | ||
} | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why there is a condition for logs? I might be executing
kubectl describe ...
and still I will need pods dropdown, and that means ,describe
also should be included. Could you please take a look at this part again?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.
You mean
describe
should also give file instead ?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.
No, maybe there is a misunderstanding. The primary motivation is to not send an attachment for the interactive blocks. Those blocks are the interactive dropdown elements e.g. namespace, name, verb . So, once you execute
kubectl
it will show you interactive elements, so that elements should be limited so there wont be an attachment. More concrete example is, once you select namespace, it will return resources (e.g. pods), if those pods > 100 you will see an attachment in the slack UI, you need to prevent that.