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

ping user group only in the channel #1228

Merged
merged 3 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions deploy-board/deploy_board/templates/configs/env_config.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@
maxlength="128"/>
</div>

<label for="mentionRecipients" class="deployToolTip control-label col-xs-2"
<label for="groupMentionRecipients" class="deployToolTip control-label col-xs-2"
data-toggle="tooltip"
title="Ping slack user or slack user group in the chat rooms (slack channels), such as user1,userGroup2">
Ping User or User Group
title="Ping slack user group in the chat rooms (slack channels), such as userGroupID1,userGroupID2.">
Ping User Group
</label>

<div class="col-xs-4">
<input class="form-control" name="mention_recipients" required="false"
type="text" value="{{ env.mentionRecipients |default_if_none:'' }}"/>
<input class="form-control" name="group_mention_recipients" required="false"
type="text" value="{{ env.groupMentionRecipients |default_if_none:'' }}"/>
</div>
</div>
<div class="form-group">
Expand Down
2 changes: 1 addition & 1 deletion deploy-board/deploy_board/webapp/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def clone_from_stage_name(request, env_name, stage_name, from_env_name, from_sta
new_data['emailRecipients'] = from_stage['emailRecipients']
new_data['notifyAuthors'] = from_stage['notifyAuthors']
new_data['watchRecipients'] = from_stage['watchRecipients']
new_data['mentionRecipients'] = from_stage['mentionRecipients']
new_data['groupMentionRecipients'] = from_stage['groupMentionRecipients']
new_data['maxDeployNum'] = from_stage['maxDeployNum']
new_data['maxDeployDay'] = from_stage['maxDeployDay']
new_data['overridePolicy'] = from_stage['overridePolicy']
Expand Down
2 changes: 1 addition & 1 deletion deploy-board/deploy_board/webapp/env_config_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def post(self, request, name, stage):
data["branch"] = query_dict["branch"]
data["emailRecipients"] = query_dict["email_recipients"]
data["watchRecipients"] = query_dict["watch_recipients"]
data["mentionRecipients"] = query_dict["mention_recipients"]
data["groupMentionRecipients"] = query_dict["group_mention_recipients"]
data["maxDeployNum"] = int(query_dict["maxDeployNum"])
data["maxDeployDay"] = int(query_dict["maxDeployDay"])
data["maxParallelRp"] = int(query_dict["maxParallelRp"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ public class EnvironBean implements Updatable, Serializable {
@JsonProperty("watchRecipients")
private String watch_recipients;

@JsonProperty("mentionRecipients")
private String mention_recipients;
@JsonProperty("groupMentionRecipients")
private String group_mention_recipients;

@JsonProperty("metricsConfigId")
private String metrics_config_id;
Expand Down Expand Up @@ -423,12 +423,12 @@ public void setWatch_recipients(String watch_recipients) {
this.watch_recipients = watch_recipients;
}

public String getMention_recipients() {
return mention_recipients;
public String getGroup_mention_recipients() {
return group_mention_recipients;
}

public void setMention_recipients(String mention_recipients) {
this.mention_recipients = mention_recipients;
public void setGroup_mention_recipients(String group_mention_recipients) {
this.group_mention_recipients = group_mention_recipients;
}

public String getMetrics_config_id() {
Expand Down Expand Up @@ -601,7 +601,7 @@ public SetClause genSetClause() {
clause.addColumn("email_recipients", email_recipients);
clause.addColumn("notify_authors", notify_authors);
clause.addColumn("watch_recipients", watch_recipients);
clause.addColumn("mention_recipients", mention_recipients);
clause.addColumn("group_mention_recipients", group_mention_recipients);
clause.addColumn("metrics_config_id", metrics_config_id);
clause.addColumn("alarm_config_id", alarm_config_id);
clause.addColumn("webhooks_config_id", webhooks_config_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private void sendMessage() {
}

sendWatcherMessage(operator, envBean.getWatch_recipients(), message, color);
sendChatMessage(operator, envBean.getChatroom(), message, color, envBean.getMention_recipients());
sendChatMessage(operator, envBean.getChatroom(), message, color, envBean.getGroup_mention_recipients());

if (state == DeployState.FAILING) {
String recipients = envBean.getEmail_recipients();
Expand Down Expand Up @@ -207,7 +207,7 @@ public void sendChatMessage(String from, String rooms, String message, String co
if (!StringUtils.isEmpty(recipients)) {
List<String> targets = Arrays.asList(recipients.split(","));
for (String target : targets) {
message = "<@" + target + "> " + message;
message = "<!subteam^" + target + "> " + message;
}
}
chatManager.send(from, chatroom.trim(), message, color);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ void sendStartDeployMessage(String additionalMessage) {
buildBean.getScm_commit_7(),
WebLink);

commonHandler.sendChatMessage(operator, envBean.getChatroom(), message, "yellow", envBean.getMention_recipients());
commonHandler.sendChatMessage(operator, envBean.getChatroom(), message, "yellow", envBean.getGroup_mention_recipients());
if (StringUtils.isNotEmpty(additionalMessage)) {
LOG.debug(String.format("Sending additional message: %s to chat", additionalMessage));
commonHandler.sendChatMessage(operator, envBean.getChatroom(), additionalMessage, "yellow", envBean.getMention_recipients());
commonHandler.sendChatMessage(operator, envBean.getChatroom(), additionalMessage, "yellow", envBean.getGroup_mention_recipients());
}
} catch (Exception e) {
LOG.error("Failed to send start notification!", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,21 +230,21 @@ void transition(HotfixBean hotBean) throws Exception {
// Send chat message
List<EnvironBean> environBeans = environDAO.getByName(hotBean.getEnv_name());
Set<String> chatroomSet = new HashSet<String>();
Set<String> mentionRecipientSet = new HashSet<String>();
Set<String> groupMentionRecipientSet = new HashSet<String>();
for (EnvironBean environBean : environBeans) {
chatroomSet.add(environBean.getChatroom());
mentionRecipientSet.add(environBean.getMention_recipients());
groupMentionRecipientSet.add(environBean.getGroup_mention_recipients());
}
String chatrooms = StringUtils.join(chatroomSet, ",");
String mentionRecipients = StringUtils.join(mentionRecipientSet, ",");
String groupMentionRecipients = StringUtils.join(groupMentionRecipientSet, ",");
DeployBean deployBean = deployDAO.getById(hotBean.getBase_deploy());
BuildBean buildBean = buildDAO.getById(deployBean.getBuild_id());
String commit = buildBean.getScm_commit();
String name = hotBean.getOperator();
String branch = "hotfix_" + name;
String message = name + " just created a hotfix in " + branch + " branch, and including commit(s) " +
hotBean.getCommits() + " on top of commit " + commit;
commonHandler.sendChatMessage(Constants.SYSTEM_OPERATOR, chatrooms, message, "yellow", mentionRecipients);
commonHandler.sendChatMessage(Constants.SYSTEM_OPERATOR, chatrooms, message, "yellow", groupMentionRecipients);

LOG.info("Hotfix Id {} is finished and now in the SUCCEEDED state.", hotfixId);
} else {
Expand Down
Loading