Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Various search provider fixes #10591

Merged

Conversation

tkurz
Copy link
Contributor

@tkurz tkurz commented Apr 26, 2018

This PR provides smaller fixes for the new search provider concept + chatpal (its reference implementation), which are:

  • suggestions are now closed when a search is already issues. This was a bug.
  • add a link from the chatpal admin page (./admin/chatpal) to the chatpal website. This gives the admins more information about the types of backends, etc.
  • fixes sizing issue for the chatpal search icon, this was an issue in firefox, the image was to large (Kudos to @wernerharing) + an unused icon in lightblue is removed

Would be great if you can approve the PR and merge it, @sampaiodiego @rodrigok @graywolf336

@sampaiodiego sampaiodiego added this to the 0.64.0 milestone Apr 26, 2018
@graywolf336
Copy link
Contributor

@tkurz any idea about this exception? We keep seeing it on our Open Community server (open.rocket.chat):

TypeError: Cannot read property '_id' of undefined
    at /app/bundle/programs/server/packages/rocketchat_search.js:102:49
    at /app/bundle/programs/server/packages/rocketchat_lib.js:1188:30
    at Array.reduce (<anonymous>:null:null)
    at Object.RocketChat.callbacks.run (/app/bundle/programs/server/packages/rocketchat_lib.js:1181:8)
    at /app/bundle/programs/server/packages/rocketchat_lib.js:4509:28
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:12)
    at packages/meteor.js:502:25
    at runWithEnvironment (packages/meteor.js:1238:24)

@graywolf336 graywolf336 changed the title [FIX] search provider fixes for 0.64 Regression: Various search provider fixes Apr 26, 2018
@graywolf336
Copy link
Contributor

I've also updated the name since the feature was added in v0.64, so any additional fixes are just regressions.

@tkurz
Copy link
Contributor Author

tkurz commented Apr 26, 2018

Hi @graywolf336, regarding the error. It happens when deleting a message, in this function:

RocketChat.callbacks.add('afterDeleteMessage', function(m) {
	eventService.promoteEvent('message.delete', m._id);
});

This can only happen, if m is set (and a message), which I took as given. If this is not the case, we have a problem here (as the search index does not know which message is deleted. If this can happen (and a quick lookup of the /packages/rocketchat-lib/server/functions/deleteMessage.js function makes me feel that it can, we have to trigger it in another way. As Message class is a subclass of RocketChat.models._Base we could use Emitters (like we do it for Rooms and Users). What do you think?

The code will then look like this:

RocketChat.models.Messages.on('changed', (type, message)=>{
	if (type === 'inserted' || type === 'updated') {
		eventService.promoteEvent('message.save', message._id, message);
	}
	if (type === 'removed') {
		eventService.promoteEvent('message.delete', message._id);
	}
});

@tkurz
Copy link
Contributor Author

tkurz commented Apr 26, 2018

@graywolf336 No, Message class doesn not emit event (I think because cache is not true).. Any other ideas?

@sampaiodiego
Copy link
Member

sampaiodiego commented Apr 26, 2018

I guess we should fix it by calling the callback this way

RocketChat.callbacks.run('afterDeleteMessage', deletedMsg || { _id: message.id });

I mean, it doesn't make any sense calling afterDeleteMessage with an empty variable just because Message_KeepHistory is set to false and Message_ShowDeletedStatus is set to true

@graywolf336
Copy link
Contributor

@sampaiodiego sounds like a solid plan to me. Should we go ahead and make this commit to his branch?

@sampaiodiego
Copy link
Member

@graywolf336 I think so.. It can part of this pull request

Copy link
Member

@sampaiodiego sampaiodiego left a comment

Choose a reason for hiding this comment

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

just so nobody merges this accidentally:

please add the fix to the afterDeleteMessage callback

@tkurz
Copy link
Contributor Author

tkurz commented Apr 27, 2018

Just to get it right, you do the change right?

@graywolf336
Copy link
Contributor

If you have time, feel free to

@tkurz
Copy link
Contributor Author

tkurz commented Apr 27, 2018

Hi @graywolf336
I did the fix that was recommended by @sampaiodiego. The error should not happen anymore.

sampaiodiego
sampaiodiego previously approved these changes Apr 27, 2018
@@ -25,7 +25,7 @@ RocketChat.deleteMessage = function(message, user) {
}

Meteor.defer(function() {
RocketChat.callbacks.run('afterDeleteMessage', deletedMsg);
RocketChat.callbacks.run('afterDeleteMessage', deletedMsg || { _id: message._id });
Copy link
Contributor

@graywolf336 graywolf336 Apr 27, 2018

Choose a reason for hiding this comment

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

@sampaiodiego should this call to the callbacks be ran outside the if (keepHistory)? Because if that setting is true, the message is being deleted to the user's perspective even though we aren't technically deleting it.

Copy link
Member

Choose a reason for hiding this comment

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

right.. since the message will be suppressed from any endpoint, we should call the callback. I'll change it to reflect that.

@sampaiodiego sampaiodiego merged commit b5a8e2b into RocketChat:develop Apr 27, 2018
@rodrigok rodrigok mentioned this pull request Apr 28, 2018
trongthanh added a commit to goalifyplus/Goalify.Chat that referenced this pull request May 2, 2018
* develop:
  Regression: Various search provider fixes (RocketChat#10591)
  Fix /api/v1/settings.oauth not sending needed info for SAML & CAS (RocketChat#10596)
  Fix the Apps and Livechats not getting along well with each other (RocketChat#10598)
  [FIX] Missing "Administration" menu for users with some administration permissions (RocketChat#10551)
  [FIX] Member list search with no results (RocketChat#10599)
  Adds Visual Studio Code debugging configuration (RocketChat#10586)
  [FIX] Integrations with room data not having the usernames filled in (RocketChat#10576)
trongthanh added a commit to goalifyplus/Goalify.Chat that referenced this pull request May 2, 2018
* goalify: (104 commits)
  Regression: Various search provider fixes (RocketChat#10591)
  Supplement TOS and privacy policy texts for use within server instances
  Fix /api/v1/settings.oauth not sending needed info for SAML & CAS (RocketChat#10596)
  Fix the Apps and Livechats not getting along well with each other (RocketChat#10598)
  [FIX] Missing "Administration" menu for users with some administration permissions (RocketChat#10551)
  [FIX] Member list search with no results (RocketChat#10599)
  merge vi-VN and vi json
  Add and enhance translations
  Update gitlab, npm package lock, include current server update script
  Adds Visual Studio Code debugging configuration (RocketChat#10586)
  [FIX] Integrations with room data not having the usernames filled in (RocketChat#10576)
  fixed problems with margin negative (RocketChat#10558)
  Add some information regarding Zapier and Bots to the integrations page (RocketChat#10574)
  Added target="_blank" to homepage and support link. (RocketChat#10575)
  [FIX] Stop Firefox announcement overflowing viewport (RocketChat#10503)
  [FIX] Wordpress oAuth authentication wasn't behaving correctly (RocketChat#10550)
  Fix inconsistent response of settings.oauth endpoint (RocketChat#10553)
  Regression: Remove added mentions on quote/reply (RocketChat#10571)
  Fix the attachments and fields incorrectly failing on validation (RocketChat#10573)
  Deps update (RocketChat#10549)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants