mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-30 20:06:19 +00:00
Fix owner notification (#16629)
* - Fix Task notification not getting sent to owners * - Fix Task notification not getting sent to owners
This commit is contained in:
parent
b7ef13bc95
commit
cc2d581eb0
@ -154,15 +154,19 @@ public class SubscriptionUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Set<String> getTaskAssignees(
|
private static Set<String> getTaskAssignees(
|
||||||
SubscriptionDestination.SubscriptionType type, ChangeEvent event) {
|
SubscriptionDestination.SubscriptionCategory category,
|
||||||
|
SubscriptionDestination.SubscriptionType type,
|
||||||
|
ChangeEvent event) {
|
||||||
Thread thread = AlertsRuleEvaluator.getThread(event);
|
Thread thread = AlertsRuleEvaluator.getThread(event);
|
||||||
List<EntityReference> assignees = thread.getTask().getAssignees();
|
|
||||||
Set<String> receiversList = new HashSet<>();
|
Set<String> receiversList = new HashSet<>();
|
||||||
Map<UUID, Team> teams = new HashMap<>();
|
Map<UUID, Team> teams = new HashMap<>();
|
||||||
Map<UUID, User> users = new HashMap<>();
|
Map<UUID, User> users = new HashMap<>();
|
||||||
|
|
||||||
Team tempTeamVar = null;
|
Team tempTeamVar = null;
|
||||||
User tempUserVar = null;
|
User tempUserVar = null;
|
||||||
|
|
||||||
|
if (category.equals(SubscriptionDestination.SubscriptionCategory.ASSIGNEES)) {
|
||||||
|
List<EntityReference> assignees = thread.getTask().getAssignees();
|
||||||
if (!nullOrEmpty(assignees)) {
|
if (!nullOrEmpty(assignees)) {
|
||||||
for (EntityReference reference : assignees) {
|
for (EntityReference reference : assignees) {
|
||||||
if (Entity.USER.equals(reference.getType())) {
|
if (Entity.USER.equals(reference.getType())) {
|
||||||
@ -189,6 +193,17 @@ public class SubscriptionUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (category.equals(SubscriptionDestination.SubscriptionCategory.OWNERS)) {
|
||||||
|
try {
|
||||||
|
tempUserVar =
|
||||||
|
Entity.getEntityByName(USER, thread.getCreatedBy(), "profile", Include.NON_DELETED);
|
||||||
|
users.put(tempUserVar.getId(), tempUserVar);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
LOG.warn("Thread created by unknown user: {}", thread.getCreatedBy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Users
|
// Users
|
||||||
receiversList.addAll(getEmailOrWebhookEndpointForUsers(users.values().stream().toList(), type));
|
receiversList.addAll(getEmailOrWebhookEndpointForUsers(users.values().stream().toList(), type));
|
||||||
@ -200,7 +215,9 @@ public class SubscriptionUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Set<String> handleConversationNotification(
|
public static Set<String> handleConversationNotification(
|
||||||
SubscriptionDestination.SubscriptionType type, ChangeEvent event) {
|
SubscriptionDestination.SubscriptionCategory category,
|
||||||
|
SubscriptionDestination.SubscriptionType type,
|
||||||
|
ChangeEvent event) {
|
||||||
Thread thread = AlertsRuleEvaluator.getThread(event);
|
Thread thread = AlertsRuleEvaluator.getThread(event);
|
||||||
Set<String> receiversList = new HashSet<>();
|
Set<String> receiversList = new HashSet<>();
|
||||||
Map<UUID, Team> teams = new HashMap<>();
|
Map<UUID, Team> teams = new HashMap<>();
|
||||||
@ -208,9 +225,8 @@ public class SubscriptionUtil {
|
|||||||
|
|
||||||
Team tempTeamVar = null;
|
Team tempTeamVar = null;
|
||||||
User tempUserVar = null;
|
User tempUserVar = null;
|
||||||
tempUserVar =
|
|
||||||
Entity.getEntityByName(USER, thread.getCreatedBy(), "profile", Include.NON_DELETED);
|
if (category.equals(SubscriptionDestination.SubscriptionCategory.MENTIONS)) {
|
||||||
users.put(tempUserVar.getId(), tempUserVar);
|
|
||||||
List<MessageParser.EntityLink> mentions = MessageParser.getEntityLinks(thread.getMessage());
|
List<MessageParser.EntityLink> mentions = MessageParser.getEntityLinks(thread.getMessage());
|
||||||
for (MessageParser.EntityLink link : mentions) {
|
for (MessageParser.EntityLink link : mentions) {
|
||||||
if (USER.equals(link.getEntityType())) {
|
if (USER.equals(link.getEntityType())) {
|
||||||
@ -236,6 +252,17 @@ public class SubscriptionUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (category.equals(SubscriptionDestination.SubscriptionCategory.OWNERS)) {
|
||||||
|
try {
|
||||||
|
tempUserVar =
|
||||||
|
Entity.getEntityByName(USER, thread.getCreatedBy(), "profile", Include.NON_DELETED);
|
||||||
|
users.put(tempUserVar.getId(), tempUserVar);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
LOG.warn("Thread created by unknown user: {}", thread.getCreatedBy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Users
|
// Users
|
||||||
receiversList.addAll(getEmailOrWebhookEndpointForUsers(users.values().stream().toList(), type));
|
receiversList.addAll(getEmailOrWebhookEndpointForUsers(users.values().stream().toList(), type));
|
||||||
@ -340,8 +367,9 @@ public class SubscriptionUtil {
|
|||||||
if (event.getEntityType().equals(THREAD)) {
|
if (event.getEntityType().equals(THREAD)) {
|
||||||
Thread thread = AlertsRuleEvaluator.getThread(event);
|
Thread thread = AlertsRuleEvaluator.getThread(event);
|
||||||
switch (thread.getType()) {
|
switch (thread.getType()) {
|
||||||
case Task -> receiverUrls.addAll(getTaskAssignees(type, event));
|
case Task -> receiverUrls.addAll(getTaskAssignees(category, type, event));
|
||||||
case Conversation -> receiverUrls.addAll(handleConversationNotification(type, event));
|
case Conversation -> receiverUrls.addAll(
|
||||||
|
handleConversationNotification(category, type, event));
|
||||||
// TODO: For Announcement, Immediate Consumer needs to be Notified (find information from
|
// TODO: For Announcement, Immediate Consumer needs to be Notified (find information from
|
||||||
// Lineage)
|
// Lineage)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user