32 lines
1.3 KiB
JavaScript
32 lines
1.3 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../../common/vendor.js");
|
|
const getHistoryMsg = async (chatType, targetId, cursor) => {
|
|
console.log(chatType, targetId, cursor);
|
|
let options = {
|
|
// 对方的用户 ID 或者群组 ID 或聊天室 ID。
|
|
targetId,
|
|
// 每页期望获取的消息条数。取值范围为 [1,50],默认值为 20。
|
|
pageSize: 20,
|
|
// 查询的起始消息 ID。若该参数设置为 `-1`、`null` 或空字符串,从最新消息开始。
|
|
cursor,
|
|
// 会话类型:(默认) `singleChat`:单聊;`groupChat`:群聊;`chatRoom`:聊天室
|
|
chatType: "groupChat",
|
|
// 消息搜索方向:(默认)`up`:按服务器收到消息的时间的逆序获取;`down`:按服务器收到消息的时间的正序获取。
|
|
searchDirection: "up"
|
|
};
|
|
console.log("====================================");
|
|
console.log(options);
|
|
console.log("====================================");
|
|
return new Promise((resolve, reject) => {
|
|
common_vendor.index.WebIM.conn.getHistoryMessages(options).then((res) => {
|
|
resolve(res);
|
|
}).catch((e) => {
|
|
console.log("===错误========================");
|
|
console.log(e);
|
|
console.log("====================================");
|
|
reject(e);
|
|
});
|
|
});
|
|
};
|
|
exports.getHistoryMsg = getHistoryMsg;
|