Skip to content

Commit 04fed9c

Browse files
committed
Add annotations.delete()
1 parent 23d5b68 commit 04fed9c

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

ably.d.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,19 +2091,40 @@ export declare interface RealtimeAnnotations {
20912091
* Publish a new annotation for a message.
20922092
*
20932093
* @param message - The message to annotate.
2094-
* @param annotation - The annotation to publish. (Must include at least the `type`.
2095-
* Assumed to be an annotation.create if no action is specified)
2094+
* @param annotation - The annotation to publish. (Must include at least the `type`;
2095+
* other required fields depend on the annotation type).
20962096
*/
20972097
publish(message: Message, annotation: OutboundAnnotation): Promise<void>;
20982098
/**
20992099
* Publish a new annotation for a message (alternative form where you only have the
21002100
* serial of the message, not a complete Message object)
21012101
*
21022102
* @param messageSerial - The serial field of the message to annotate.
2103-
* @param annotation - The annotation to publish. (Must include at least the `type`.
2104-
* Assumed to be an annotation.create if no action is specified)
2103+
* @param annotation - The annotation to publish. (Must include at least the `type`;
2104+
* other required fields depend on the annotation type).
21052105
*/
21062106
publish(messageSerial: string, annotation: OutboundAnnotation): Promise<void>;
2107+
/**
2108+
* Publish an annotation removal request for a message, to remove it from the summary
2109+
* summaries. The semantics of the delete (and what fields are required) are different
2110+
* for each annotation type; see annotation types documentation for more details.
2111+
*
2112+
* @param message - The message which has an annotation that you want to delete.
2113+
* @param annotation - The annotation deletion request. (Must include at least the
2114+
* `type`, other required fields depend on the type).
2115+
*/
2116+
delete(message: Message, annotation: OutboundAnnotation): Promise<void>;
2117+
/**
2118+
* Publish an annotation removal request for a message, to remove it from the summary
2119+
* summaries. The semantics of the delete (and what fields are required) are different
2120+
* for each annotation type; see annotation types documentation for more details.
2121+
*
2122+
* @param messageSerial - The serial field of the message which has an annotation that
2123+
* you want to delete.
2124+
* @param annotation - The annotation deletion request. (Must include at least the
2125+
* `type`, other required fields depend on the type).
2126+
*/
2127+
delete(messageSerial: string, annotation: OutboundAnnotation): Promise<void>;
21072128
/**
21082129
* Get all annotations for a given message (as a paginated result)
21092130
*

src/common/lib/client/realtimeannotations.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ class RealtimeAnnotations {
4848
return this.channel.sendMessage(pm);
4949
}
5050

51+
async delete(msgOrSerial: string | Message, annotationValues: Partial<Properties<Annotation>>): Promise<void> {
52+
annotationValues.action = 'annotation.delete';
53+
return this.publish(msgOrSerial, annotationValues);
54+
}
55+
5156
async subscribe(..._args: unknown[] /* [type], listener */): Promise<void> {
5257
const args = RealtimeChannel.processListenerArgs(_args);
5358
const event = args[0];

src/common/lib/client/restannotations.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ class RestAnnotations {
9191
);
9292
}
9393

94+
async delete(msgOrSerial: string | Message, annotationValues: Partial<Properties<Annotation>>): Promise<void> {
95+
annotationValues.action = 'annotation.delete';
96+
return this.publish(msgOrSerial, annotationValues);
97+
}
98+
9499
async get(
95100
msgOrSerial: string | Message,
96101
params: RestGetAnnotationsParams | null,

0 commit comments

Comments
 (0)