Skip to content

Commit 0c16f03

Browse files
committed
api: Add prevContentSha256 param to updateMessage route
1 parent f1c0e0f commit 0c16f03

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/api/route/messages.dart

+2
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ Future<UpdateMessageResult> updateMessage(
275275
bool? sendNotificationToOldThread,
276276
bool? sendNotificationToNewThread,
277277
String? content,
278+
String? prevContentSha256,
278279
int? streamId,
279280
}) {
280281
return connection.patch('updateMessage', UpdateMessageResult.fromJson, 'messages/$messageId', {
@@ -283,6 +284,7 @@ Future<UpdateMessageResult> updateMessage(
283284
if (sendNotificationToOldThread != null) 'send_notification_to_old_thread': sendNotificationToOldThread,
284285
if (sendNotificationToNewThread != null) 'send_notification_to_new_thread': sendNotificationToNewThread,
285286
if (content != null) 'content': RawParameter(content),
287+
if (prevContentSha256 != null) 'prev_content_sha256': RawParameter(prevContentSha256),
286288
if (streamId != null) 'stream_id': streamId,
287289
});
288290
}

test/api/route/messages_test.dart

+16
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ void main() {
454454
bool? sendNotificationToOldThread,
455455
bool? sendNotificationToNewThread,
456456
String? content,
457+
String? prevContentSha256,
457458
int? streamId,
458459
required Map<String, String> expected,
459460
}) async {
@@ -464,6 +465,7 @@ void main() {
464465
sendNotificationToOldThread: sendNotificationToOldThread,
465466
sendNotificationToNewThread: sendNotificationToNewThread,
466467
content: content,
468+
prevContentSha256: prevContentSha256,
467469
streamId: streamId,
468470
);
469471
check(connection.lastRequest).isA<http.Request>()
@@ -473,6 +475,20 @@ void main() {
473475
return result;
474476
}
475477

478+
test('pure content change', () {
479+
return FakeApiConnection.with_((connection) async {
480+
connection.prepare(json: UpdateMessageResult().toJson());
481+
await checkUpdateMessage(connection,
482+
messageId: eg.streamMessage().id,
483+
content: 'asdf',
484+
prevContentSha256: '34a780ad578b997db55b260beb60b501f3e04d30ba1a51fcf43cd8dd1241780d',
485+
expected: {
486+
'content': 'asdf',
487+
'prev_content_sha256': '34a780ad578b997db55b260beb60b501f3e04d30ba1a51fcf43cd8dd1241780d',
488+
});
489+
});
490+
});
491+
476492
test('topic/content change', () {
477493
// A separate test exercises `streamId`;
478494
// the API doesn't allow changing channel and content at the same time.

0 commit comments

Comments
 (0)