Skip to content

Commit 7716fe8

Browse files
committed
Fixed validation checks for mutable-messages flag as per review comments
1 parent 6a7750f commit 7716fe8

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

src/commands/apps/channel-rules/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default class ChannelRulesIndexCommand extends BaseTopicCommand {
99
static examples = [
1010
"ably apps channel-rules list",
1111
'ably apps channel-rules create --name "chat" --persisted',
12-
'ably apps channel-rules update --name "chat" --mutable-messages',
12+
"ably apps channel-rules update chat --mutable-messages",
1313
"ably apps channel-rules update chat --push-enabled",
1414
"ably apps channel-rules delete chat",
1515
];

src/commands/apps/channel-rules/update.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,11 @@ export default class ChannelRulesUpdateCommand extends ControlBaseCommand {
139139
const updateData: Record<string, boolean | number | string | undefined> =
140140
{};
141141

142-
// Validation for mutable-messages flag
143-
if (flags.persisted === false && flags["mutable-messages"]) {
142+
// Validation for mutable-messages flag, checks with supplied/existing mutableMessages flag
143+
if (
144+
flags.persisted === false &&
145+
(flags["mutable-messages"] || namespace.mutableMessages)
146+
) {
144147
const errorMsg =
145148
"Cannot disable persistence when mutable messages is enabled. Mutable messages requires message persistence.";
146149
if (this.shouldOutputJson(flags)) {
@@ -164,14 +167,18 @@ export default class ChannelRulesUpdateCommand extends ControlBaseCommand {
164167
updateData.persisted = flags.persisted;
165168
}
166169

167-
if (flags["mutable-messages"]) {
170+
if (flags["mutable-messages"] !== undefined) {
168171
updateData.mutableMessages = flags["mutable-messages"];
169-
updateData.persisted = true;
170-
this.logToStderr(
171-
chalk.yellow(
172-
"Warning: Message persistence is automatically enabled when mutable messages is enabled.",
173-
),
174-
);
172+
if (flags["mutable-messages"]) {
173+
updateData.persisted = true;
174+
if (!this.shouldOutputJson(flags)) {
175+
this.logToStderr(
176+
chalk.yellow(
177+
"Warning: Message persistence is automatically enabled when mutable messages is enabled.",
178+
),
179+
);
180+
}
181+
}
175182
}
176183

177184
if (flags["push-enabled"] !== undefined) {

0 commit comments

Comments
 (0)