in apps/televisit-demo/backend/messagemoderator/ChimeMessagingAPI.js [96:134]
async function listChannelMessages(
channelArn,
userId,
notAfter = null,
notBefore = null,
nextToken = null
) {
console.log('listChannelMessages called');
const params = {
ChannelArn: channelArn,
NotAfter: notAfter,
NotBefore: notBefore,
NextToken: nextToken,
ChimeBearer: createMemberArn(userId),
};
try {
const request = (await chimeClient()).listChannelMessages(params);
request.on('build', function () {
request.httpRequest.headers[appInstanceUserArnHeader] =
createMemberArn(userId);
});
const response = await request.promise();
const messageList = response.ChannelMessages;
messageList.sort(function (a, b) {
return a.CreatedTimestamp < b.CreatedTimestamp
? -1
: a.CreatedTimestamp > b.CreatedTimestamp
? 1
: 0;
});
return { Messages: messageList, NextToken: response.NextToken };
} catch (e) {
console.log(JSON.stringify(e));
return null;
}
}