Skip to content

Commit 474ed1b

Browse files
committed
💡 Add Cloud.onIMConversationRemove
1 parent 29d8641 commit 474ed1b

4 files changed

Lines changed: 12 additions & 9 deletions

File tree

API.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,18 @@ LeanEngine 中间件会为这些 Hook 函数检查「Hook 签名」,确保调
134134

135135
包括:
136136

137-
* `_messageReceived`
138-
* `_receiversOffline`
139-
* `_messageSent`
140-
* `_conversationStart`
141-
* `_conversationAdd`
142-
* `_conversationRemove`
143-
* `_conversationUpdate`
137+
* `onIMMessageReceived`
138+
* `onIMReceiversOffline`
139+
* `onIMMessageSent`
140+
* `onIMConversationStart`
141+
* `onIMConversationStarted`
142+
* `onIMConversationAdd`
143+
* `onIMConversationRemove`
144+
* `onIMConversationUpdate`
144145

145146
LeanEngine 中间件会为这些 Hook 函数检查「Hook 签名」,确保调用者的确是 LeanCloud 或本地调试时的命令行工具。
146147

147-
这些 Hook 需要用 `AV.Cloud.define` 来定义,详见文档 [实时通信概览:云引擎 Hook](https://leancloud.cn/docs/realtime_v2.html#云引擎_Hook)
148+
这些 Hook 函数签名是 `function(func: function)`,其中 `func` 是接受一个 Request 对象作为参数,返回 Promise 的函数,详见文档 [实时通信概览:云引擎 Hook](https://leancloud.cn/docs/realtime_v2.html#云引擎_Hook)
148149

149150
## Middlewares
150151

leanengine.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ declare module 'leanengine' {
121121
export function onIMConversationStart(handler: CloudFunction): void;
122122
export function onIMConversationStarted(handler: CloudFunction): void;
123123
export function onIMConversationAdd(handler: CloudFunction): void;
124+
export function onIMConversationRemove(handler: CloudFunction): void;
124125
export function onIMConversationUpdate(handler: CloudFunction): void;
125126

126127
export function LeanCloudHeaders(options?: MiddlewareOptions): RequestHandler;

lib/leanengine.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ function createCloudFunctionRouter(options) {
139139

140140
cloudFunctions.use(function(err, req, res, next) { // jshint ignore:line
141141
if(req.timedout) {
142-
console.error('LeanEngine function timeout, url=%s, timeout=%d', req.originalUrl, err.timeout);
142+
console.error(`LeanEngine: ${req.originalUrl}: function timeout (${err.timeout}ms)`);
143143
err.code = 124; // https://leancloud.cn/docs/error_code.html#_124
144144
err.message = 'The request timed out on the server.';
145145
}

lib/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ exports.realtimeHookMapping = {
2020
onIMConversationStart: '_conversationStart',
2121
onIMConversationStarted: '_conversationStarted',
2222
onIMConversationAdd: '_conversationAdd',
23+
onIMConversationRemove: '_conversationRemove',
2324
onIMConversationUpdate: '_conversationUpdate'
2425
};
2526

0 commit comments

Comments
 (0)