Skip to content

Commit

Permalink
Merge pull request #429 from KamToHung/master
Browse files Browse the repository at this point in the history
fix issue 428
  • Loading branch information
yanhom1314 committed Jul 1, 2024
2 parents db8a7fe + 2ce6ed6 commit f139de0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private LarkNotifyConst() { }
* lark at format. username
* 当配置username时,只能蓝色字体展示@username,被@人无@提醒
*/
public static final String LARK_AT_FORMAT_USERNAME = "<at id=''>%s</at>";
public static final String LARK_AT_FORMAT_USERNAME = "<at id='%s'>%s</at>";

/**
* lark openid prefix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected Pair<String, String> getColors() {
protected String formatReceivers(String receives) {
return Arrays.stream(receives.split(","))
.map(r -> StringUtils.startsWith(r, LARK_OPENID_PREFIX) ?
String.format(LARK_AT_FORMAT_OPENID, r) : String.format(LARK_AT_FORMAT_USERNAME, r))
String.format(LARK_AT_FORMAT_OPENID, r) : String.format(LARK_AT_FORMAT_USERNAME, r, r))
.collect(Collectors.joining(" "));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.dromara.dynamictp.test.core.notify;

import com.google.common.collect.Lists;
import org.dromara.dynamictp.common.notifier.LarkNotifier;
import org.dromara.dynamictp.common.spring.ApplicationContextHolder;
import org.dromara.dynamictp.common.em.NotifyItemEnum;
import org.dromara.dynamictp.common.entity.NotifyItem;
Expand All @@ -28,6 +29,8 @@
import org.dromara.dynamictp.core.notifier.AbstractDtpNotifier;
import org.dromara.dynamictp.core.notifier.DtpDingNotifier;
import org.dromara.dynamictp.common.notifier.Notifier;
import org.dromara.dynamictp.core.notifier.DtpLarkNotifier;
import org.dromara.dynamictp.core.notifier.DtpNotifier;
import org.dromara.dynamictp.core.notifier.context.AlarmCtx;
import org.dromara.dynamictp.core.notifier.context.DtpNotifyCtxHolder;
import org.dromara.dynamictp.core.notifier.context.NoticeCtx;
Expand Down Expand Up @@ -118,4 +121,16 @@ public void testSendAlarmMsg() {
public void testGetQueueName2() {
Assert.assertEquals(dtpExecutor.getQueueType(), VARIABLE_LINKED_BLOCKING_QUEUE.getName());
}

@Test
public void testLarkSendChangeMsg() {
DtpNotifier larkNotifier = new DtpLarkNotifier(new LarkNotifier());
NotifyPlatform notifyPlatform = new NotifyPlatform();
notifyPlatform.setWebhook("");
notifyPlatform.setReceivers("");
TpMainFields oldFields = new TpMainFields();
List<String> diffs = Lists.newArrayList("corePoolSize");
DtpNotifyCtxHolder.set(new NoticeCtx(ExecutorWrapper.of(dtpExecutor), new NotifyItem(), oldFields, diffs));
larkNotifier.sendChangeMsg(notifyPlatform, oldFields, diffs);
}
}

0 comments on commit f139de0

Please sign in to comment.