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

Wrong notification saying "X assigned you to merge request" when the issue is updated (e.g., new commits pushed) #321

Closed
wkentaro opened this issue Oct 19, 2022 · 9 comments · Fixed by #395
Assignees
Labels
Good First Issue Suitable for first-time contributors Hacktoberfest Help Wanted Community help wanted Tech/Go Type/Enhancement New feature or improvement of existing feature

Comments

@wkentaro
Copy link

This seems to be a known issue, but can anyone guide me to resolve this?
It is a bit annoying to get notification every time someone pushes a new commit.
image

@mickmister mickmister added Help Wanted Community help wanted Up For Grabs Ready for help from the community. Removed when someone volunteers Hacktoberfest Good First Issue Suitable for first-time contributors Tech/Go Type/Enhancement New feature or improvement of existing feature labels Oct 20, 2022
@mickmister
Copy link
Contributor

Hi @wkentaro! It looks like this may be possible via event.Changes.Assignee.Previous and event.Changes.Assignee.Current. We can diff these two arrays to find if there is a new assignee. Then we can DM the new assignee(s) if there is one. Would you be interested in implementing this?

https://github.com/xanzy/go-gitlab/blob/6da2d13f2241eab2edf52f881b28a31595780a7e/event_webhook_types.go#L557-L561

@wkentaro
Copy link
Author

wkentaro commented Oct 22, 2022

Yes, I'm happy to.

One thing that is blocking me to do so is that it is not very clear to me if xxxUsername variables point the username of Gitlab or Mattermost, and I'm not sure how I can easily test that. (Do you know these?)

authorGitlabUsername := w.gitlabRetreiver.GetUsernameByID(event.ObjectAttributes.AuthorID)
senderGitlabUsername := event.User.Username

Looking at the messages, it looks like they are the username of Gitlab.

message = fmt.Sprintf("[%s](%s) requested your review on [%s!%v](%s)", senderGitlabUsername, w.gitlabRetreiver.GetUserURL(senderGitlabUsername), event.ObjectAttributes.Target.PathWithNamespace, event.ObjectAttributes.IID, event.ObjectAttributes.URL)
case actionReopen:
message = fmt.Sprintf("[%s](%s) reopen your merge request [%s!%v](%s)", senderGitlabUsername, w.gitlabRetreiver.GetUserURL(senderGitlabUsername), event.ObjectAttributes.Target.PathWithNamespace, event.ObjectAttributes.IID, event.ObjectAttributes.URL)
case actionUpdate:
// TODO not enough check (opened/update) to say assigned to you...
message = fmt.Sprintf("[%s](%s) assigned you to merge request [%s!%v](%s)", senderGitlabUsername, w.gitlabRetreiver.GetUserURL(senderGitlabUsername), event.ObjectAttributes.Target.PathWithNamespace, event.ObjectAttributes.IID, event.ObjectAttributes.URL)

But these variables are used for sending messages to ToUsers

handlers := []*HandleWebhook{{
Message: message,
ToUsers: []string{w.gitlabRetreiver.GetUsernameByID(event.ObjectAttributes.AssigneeID), authorGitlabUsername},
ToChannels: []string{},
From: senderGitlabUsername,
}}

so I wonder if it is also somehow related to the one for Mattermost?


It seems most likely they are the username of Gitlab, so I can do something like below:

if authorGitlabUsername in event.Changes.Assignee.Current and \
       authorGitlabUsername not in event.Changes.Assignee.Previous:
   toUsers.append(authorGitlabUsername)

@ashutosh887
Copy link

Let me work on this @wkentaro

@mickmister
Copy link
Contributor

Hi @ashutosh887, sorry for the late response here. Are you still interested in working on this?

@mickmister
Copy link
Contributor

@mkdbns Heads up that a customer has pointed this out, so I'm adding to the plugin maintenance board. Also here's a thread with some discussion on this https://community.mattermost.com/core/pl/bk4z76cqm3dxprcpf536jb3gwr

@mickmister
Copy link
Contributor

mickmister commented Jul 19, 2023

Note the open PR that seems that it's no longer being worked on here #324

@tschuyebuhl
Copy link
Contributor

is this still up for grabs?

@mickmister
Copy link
Contributor

Indeed it is @tschuyebuhl. Let me know if you'd like to work on it, and I can assign it to you 👍

@tschuyebuhl
Copy link
Contributor

yeah, I would love to work on it if it's not a problem

@mickmister mickmister removed the Up For Grabs Ready for help from the community. Removed when someone volunteers label Aug 3, 2023
Kshitij-Katiyar added a commit to Brightscout/mattermost-plugin-gitlab that referenced this issue Aug 22, 2023
Kshitij-Katiyar added a commit to Brightscout/mattermost-plugin-gitlab that referenced this issue Aug 23, 2023
…ssigned prs' (#40)

* [MI-3424]:Fixed issue mattermost#321 'Wrong notification in case of assigned prs'

* [MI-3424]:Fixed review comments

* [MI-3424]:Fixed review comments

* [MI-3424]:Fixed test cases
@Kshitij-Katiyar Kshitij-Katiyar moved this from Todo to Submitted in Brightscout Plugin Maintenance Aug 28, 2023
hanzei pushed a commit that referenced this issue Jan 24, 2024
#395)

Co-authored-by: Abhishek Verma <abhishek.verma@brightscout.com>
Co-authored-by: ayusht2810 <ayush.thakur@brightscout.com>
@github-project-automation github-project-automation bot moved this from Submitted / In Review to Done in Brightscout Plugin Maintenance Jan 24, 2024
raghavaggarwal2308 pushed a commit to Brightscout/mattermost-plugin-gitlab that referenced this issue Feb 14, 2024
…case of assigned prs' (mattermost#395)

Co-authored-by: Abhishek Verma <abhishek.verma@brightscout.com>
Co-authored-by: ayusht2810 <ayush.thakur@brightscout.com>
mickmister added a commit that referenced this issue Feb 20, 2024
* Remove check for client secret length (#419)

* support client secrets longer than 64 chars

* remove length check

* change client secret length check to assume at least 64 chars

* change wording of error message

* [GH-321]:Fixed issue #321 'Wrong notification in case of assigned prs' (#395)

Co-authored-by: Abhishek Verma <abhishek.verma@brightscout.com>
Co-authored-by: ayusht2810 <ayush.thakur@brightscout.com>

* [MI-3405] Fix issues #271: Sidebar header MR count should show assigned MRs instead of opened MRs (#39) (#394)

* [MI-3405] Get proper data in sidebar buttons:
1. Get assigned PRs instead of the user's PRs.
2. Updated the name of sidebar buttons.
3. Updated API path.
4. Updated the name of API functions.
5. Updated the name of unreads to todos in the code.

* [MI-3405] Updated name of variables and functions

* [MI-3405] Updated icons in sidebar

* [MI-3405] Updated documentation

* [MI-3405] Reverted package-lock file changes

* [MI-3405] Review fixes

* [MM-42] Fix CI error: implicit memory aliasing (#429)

* [MI-3588] Fix issue: Image attachment breaking in comment notification (#406)

* [MI-3719] Send the users an ephemeral message if they try to connect their account via MM desktop app (#416)

* [MI-3719] Send the users an ephemeral message if they try to connect their account via MM desktop app

* [MI-3713] Handles the following cases as well for desktop app:
1. Connecting using the button from the teams sidebar.
2. Connecting using the button from RHS.

* [MI-3719] Review fixes

* [MI-3719] Review fixes

Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com>

* [MI-3719] Fix lint error

---------

Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com>

* Fix lint errors

* Update plugin version

---------

Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com>
Co-authored-by: kshitij katiyar <90389917+Kshitij-Katiyar@users.noreply.github.com>
Co-authored-by: Abhishek Verma <abhishek.verma@brightscout.com>
Co-authored-by: ayusht2810 <ayush.thakur@brightscout.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment