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

[MM-232]: Fixed the issue of same message being received while creating and deleting tags #524

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions server/webhook/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,23 @@ func (w *webhook) handleDMTag(event *gitlab.TagEvent) ([]*HandleWebhook, error)
}

func (w *webhook) handleChannelTag(ctx context.Context, event *gitlab.TagEvent) ([]*HandleWebhook, error) {
senderGitlabUsername := w.gitlabRetreiver.GetUsernameByID(event.UserID)
senderGitlabUsername := event.UserUsername
repo := event.Project
tagNames := strings.Split(event.Ref, "/")
tagName := tagNames[len(tagNames)-1]
URL := fmt.Sprintf("%s/-/tags/%s", repo.WebURL, tagName)
res := []*HandleWebhook{}

message := fmt.Sprintf("[%s](%s) New tag [%s](%s) by [%s](%s): %s", repo.PathWithNamespace, repo.WebURL, tagName, URL, senderGitlabUsername, w.gitlabRetreiver.GetUserURL(senderGitlabUsername), event.Message)
if len(event.Message) > 0 {
event.Message = fmt.Sprintf(": %s", event.Message)
}

var message string
if len(event.Commits) > 0 {
message = fmt.Sprintf("[%s](%s) New tag [%s](%s) by [%s](%s)%s", repo.PathWithNamespace, repo.WebURL, tagName, URL, senderGitlabUsername, w.gitlabRetreiver.GetUserURL(senderGitlabUsername), event.Message)
} else {
message = fmt.Sprintf("[%s](%s): [%s](%s) Tag deleted by [%s](%s)%s", repo.PathWithNamespace, repo.WebURL, tagName, URL, senderGitlabUsername, w.gitlabRetreiver.GetUserURL(senderGitlabUsername), event.Message)
}

toChannels := make([]string, 0)
namespace, project := normalizeNamespacedProject(repo.PathWithNamespace)
Expand Down
Loading