Skip to content

Commit 34619d5

Browse files
committed
fix(slack_cli): make sure messages without blocks but with message param get sent
1 parent 56f4b4d commit 34619d5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

slack_cli/lib/src/commands/post_command.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class PostCommand extends Command<int> {
116116
final parsedBlocks = parseBlocks(blocks, logger: _logger);
117117

118118
// need to split into multiple messages of up to 50 blocks
119-
final numberOfMessages = (parsedBlocks.length / 50).ceil();
119+
final numberOfMessages = math.max(1, (parsedBlocks.length / 50).ceil());
120120

121121
final responses = <PostCommandResponse>[];
122122
for (var messageIndex = 0;
@@ -136,7 +136,7 @@ class PostCommand extends Command<int> {
136136
'text': message,
137137
'unfurl_media': unfurlMedia.toString(),
138138
'unfurl_links': unfurlLinks.toString(),
139-
'blocks': jsonEncode(blocksSublist),
139+
if (blocksSublist.isNotEmpty) 'blocks': jsonEncode(blocksSublist),
140140
},
141141
);
142142
if (response.statusCode == 200) {

0 commit comments

Comments
 (0)