mattermost-plugin-gitlab icon indicating copy to clipboard operation
mattermost-plugin-gitlab copied to clipboard

Webhooks MM userId not GitlabUserId

Open manland opened this issue 5 years ago • 5 comments

WebHooks received GitlabId bu we use an internal method which look for MMUserID. Change this behavior by storing gitlabId in kvStore or use loginGitlab wich is already stored in kvStore.


I also see some strange behaviour related to webhooks and I may have found the reason, but need an extra pair of eyes here, maybe I'm missing something.

@manland, please correct me if I'm wrong,

In https://github.com/mattermost/mattermost-plugin-gitlab/blob/master/server/plugin.go#L152

p.API.KVSet(userID + GITLAB_IDUSERNAME_KEY, []byte(gitlabUsername) // userID is Mattermost user ID

But in https://github.com/mattermost/mattermost-plugin-gitlab/blob/master/server/plugin.go#L167

p.API.KVGet(gitlabUserID + GITLAB_IDUSERNAME_KEY) // gitlabUserID is GitLab user ID

This mismatch makes GITLAB_IDUSERNAME_KEY useless and ToUsers will never be filled by webhooks.

Originally posted by @kop in https://github.com/mattermost/mattermost-plugin-gitlab/issues/121#issuecomment-565140183

manland avatar Dec 16 '19 11:12 manland

@hanzei please feel free to update description and/or labels.

manland avatar Dec 16 '19 11:12 manland

@manland @hanzei @kop

This mismatch makes GITLAB_IDUSERNAME_KEY useless and ToUsers will never be filled by webhooks.

If this is true then it seems that the functions handleDMMergeRequest and handleMention achieve nothing? – e.g. line 43 in server/webhook/merge_request.go But the handleChannelMergeRequest function would still work – as it seems to be in my case! (see my comment at #147)

Doesn't this issue imply that one of the core functionalities of this plugin does not work? Namely:

Notifications - get a direct message in Mattermost when someone mentions you, requests your review, comments on or modifies one of your merge requests/issues, or assigns you on GitLab

It would fit my experience... but I find it strange: I guess that anyone stumbling upon this plugin does so because he/she is looking for the "Notifications" functionality – the project subscription feature is already covered by Gitlab iirc. And it seems that relevant lines of code weren't changed since the first commit.

olafik avatar May 26 '20 19:05 olafik

Indeed, From look at the code it seams like some parts of the notification system are broken.

@olafik Would you be interested in submitting a fix?

hanzei avatar May 27 '20 10:05 hanzei

Hi @hanzei, I'd like to fix this. Can you help me on how to get started. Additionally, if you can help me on how the flow of editing will go, that'd be great as well :)

haardikdharma10 avatar Oct 05 '20 17:10 haardikdharma10

Hey @haardikdharma10, Thanks for taking a shot. :+1: Do the docs at https://github.com/mattermost/mattermost-plugin-gitlab#development help you with getting started?

hanzei avatar Oct 07 '20 10:10 hanzei