Skip to content

Commit 5947caa

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

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-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: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ 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 (flags.persisted === false && (flags["mutable-messages"] || namespace.mutableMessages)) {
144144
const errorMsg =
145145
"Cannot disable persistence when mutable messages is enabled. Mutable messages requires message persistence.";
146146
if (this.shouldOutputJson(flags)) {
@@ -164,14 +164,18 @@ export default class ChannelRulesUpdateCommand extends ControlBaseCommand {
164164
updateData.persisted = flags.persisted;
165165
}
166166

167-
if (flags["mutable-messages"]) {
167+
if (flags["mutable-messages"] !== undefined) {
168168
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-
);
169+
if (flags["mutable-messages"]) {
170+
updateData.persisted = true;
171+
if (!this.shouldOutputJson(flags)) {
172+
this.logToStderr(
173+
chalk.yellow(
174+
"Warning: Message persistence is automatically enabled when mutable messages is enabled.",
175+
),
176+
);
177+
}
178+
}
175179
}
176180

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

0 commit comments

Comments
 (0)