Full-text search within conversation
This commit is contained in:
@@ -655,9 +655,16 @@ async function searchConversations(query) {
|
||||
return conversations;
|
||||
}
|
||||
|
||||
function handleSearchMessageJSON(messages) {
|
||||
return messages.map(message => ({
|
||||
...JSON.parse(message.json),
|
||||
snippet: message.snippet,
|
||||
}));
|
||||
}
|
||||
|
||||
async function searchMessages(query, { limit } = {}) {
|
||||
const messages = await channels.searchMessages(query, { limit });
|
||||
return messages;
|
||||
return handleSearchMessageJSON(messages);
|
||||
}
|
||||
|
||||
async function searchMessagesInConversation(
|
||||
@@ -670,7 +677,7 @@ async function searchMessagesInConversation(
|
||||
conversationId,
|
||||
{ limit }
|
||||
);
|
||||
return messages;
|
||||
return handleSearchMessageJSON(messages);
|
||||
}
|
||||
|
||||
// Message
|
||||
@@ -784,6 +791,10 @@ async function getUnreadByConversation(conversationId, { MessageCollection }) {
|
||||
return new MessageCollection(messages);
|
||||
}
|
||||
|
||||
function handleMessageJSON(messages) {
|
||||
return messages.map(message => JSON.parse(message.json));
|
||||
}
|
||||
|
||||
async function getOlderMessagesByConversation(
|
||||
conversationId,
|
||||
{ limit = 100, receivedAt = Number.MAX_VALUE, MessageCollection }
|
||||
@@ -796,7 +807,7 @@ async function getOlderMessagesByConversation(
|
||||
}
|
||||
);
|
||||
|
||||
return new MessageCollection(messages);
|
||||
return new MessageCollection(handleMessageJSON(messages));
|
||||
}
|
||||
async function getNewerMessagesByConversation(
|
||||
conversationId,
|
||||
@@ -810,7 +821,7 @@ async function getNewerMessagesByConversation(
|
||||
}
|
||||
);
|
||||
|
||||
return new MessageCollection(messages);
|
||||
return new MessageCollection(handleMessageJSON(messages));
|
||||
}
|
||||
async function getMessageMetricsForConversation(conversationId) {
|
||||
const result = await channels.getMessageMetricsForConversation(
|
||||
|
Reference in New Issue
Block a user