Skip to content

Commit 4abdd8c

Browse files
aiskleeyeh
authored andcommitted
feat: support toClientIds option in AV.Conversation#send
1 parent 39bf2cd commit 4abdd8c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/conversation.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,28 +102,32 @@ module.exports = AV.Object.extend('_Conversation', {
102102
/**
103103
* Send realtime message to this conversation, using HTTP request.
104104
*
105-
* @param {String} clientId Sender's client id.
105+
* @param {String} fromClient Sender's client id.
106106
* @param {(String|Object)} message The message which will send to conversation.
107107
* It could be a raw string, or an object with a `toJSON` method, like a
108108
* realtime SDK's Message object. See more: {@link https://leancloud.cn/docs/realtime_guide-js.html#消息}
109109
* @param {Boolean} [options.transient] Whether send this message as transient message or not.
110+
* @param {String[]} [options.toClients] Ids of clients to send to. This option can be used only in system conversation.
110111
* @param {Object} [options.pushData] Push data to this message. See more: {@link https://url.leanapp.cn/pushData 推送消息内容}
111112
* @param {AuthOptions} [authOptions]
112113
* @return {Promise}
113114
*/
114-
send: function(clientId, message, options, authOptions) {
115+
send: function(fromClient, message, options={}, authOptions={}) {
115116
if (typeof message.toJSON === 'function') {
116117
message = message.toJSON();
117118
}
118119
if (typeof message !== 'string') {
119120
message = JSON.stringify(message);
120121
}
121122
const data = {
122-
from_peer: clientId,
123+
from_peer: fromClient,
123124
conv_id: this.id,
124125
transient: false,
125126
message: message,
126127
};
128+
if (options.toClientIds !== undefined) {
129+
data.to_peers = toClients;
130+
}
127131
if (options.transient !== undefined) {
128132
data.transient = options.transient ? true : false;
129133
}

storage.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ declare namespace AV {
570570
getName(): string;
571571
isTransient(): boolean;
572572
isSystem(): boolean;
573-
send(clintId: string, message: string|object, options?: { transient?: boolean, pushData?: object }, authOptions?: AuthOptions): Promise<void>;
573+
send(fromClient: string, message: string|object, options?: { transient?: boolean, pushData?: object, toClients?: string[] }, authOptions?: AuthOptions): Promise<void>;
574574
}
575575

576576
export class Error {

0 commit comments

Comments
 (0)