Skip to content
This repository has been archived by the owner on Jul 9, 2022. It is now read-only.

Message search #364

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Message search #364

wants to merge 4 commits into from

Conversation

TimSorbet
Copy link
Contributor

So this is not very polished or documented, but it does work. This adds the message search feature requested in issue #287.

@Schmavery
Copy link
Owner

Thanks for submitting this @Mini-Geek. It's a lot of functionality that seems a little complicated to use directly so I'm not sure how to properly expose it, but it's great to have this functionality explored like this and I'll leave the PR open in case anyone else wants to contribute their opinions.

@bsansouci
Copy link
Collaborator

Hey Thanks for that PR. What does searchContext do exactly? It is the same as getThreadHistory?

@TimSorbet
Copy link
Contributor Author

When you do a search and click on a result to see the context, search_context.php is called. Also when you click to see more context above or below the found message, it calls search_context.php.

Copy link
Collaborator

@bsansouci bsansouci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok that makes sense. Could you document both functions? I left a bunch of comments too :)
After that we can merge!
Thanks


module.exports = function(defaultFuncs, api, ctx) {
return function searchContext(messageID, threadID, isGroup, limit, direction, callback) {
if(!callback && utils.getType(threadID) === 'Function') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you do utils.getType(threadID) !== "String" instead?

limit: limit || 6,
direction: direction,
};
if (isGroup) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove isGroup and use the same trick we used in sendMessage

api.getUserInfo(threadID, function(err, res) {

We make a call to getUserInfo and do Object.keys(res).length > 0, if it's true then it's a 1-1 thread, if it's false then it's a group thread.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants