mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-30 03:46:10 +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,39 +154,54 @@ public class SubscriptionUtil {
|
||||
}
|
||||
|
||||
private static Set<String> getTaskAssignees(
|
||||
SubscriptionDestination.SubscriptionType type, ChangeEvent event) {
|
||||
SubscriptionDestination.SubscriptionCategory category,
|
||||
SubscriptionDestination.SubscriptionType type,
|
||||
ChangeEvent event) {
|
||||
Thread thread = AlertsRuleEvaluator.getThread(event);
|
||||
List<EntityReference> assignees = thread.getTask().getAssignees();
|
||||
Set<String> receiversList = new HashSet<>();
|
||||
Map<UUID, Team> teams = new HashMap<>();
|
||||
Map<UUID, User> users = new HashMap<>();
|
||||
|
||||
Team tempTeamVar = null;
|
||||
User tempUserVar = null;
|
||||
if (!nullOrEmpty(assignees)) {
|
||||
for (EntityReference reference : assignees) {
|
||||
if (Entity.USER.equals(reference.getType())) {
|
||||
tempUserVar = Entity.getEntity(USER, reference.getId(), "profile", Include.NON_DELETED);
|
||||
users.put(tempUserVar.getId(), tempUserVar);
|
||||
} else if (TEAM.equals(reference.getType())) {
|
||||
tempTeamVar = Entity.getEntity(TEAM, reference.getId(), "profile", Include.NON_DELETED);
|
||||
teams.put(tempTeamVar.getId(), tempTeamVar);
|
||||
|
||||
if (category.equals(SubscriptionDestination.SubscriptionCategory.ASSIGNEES)) {
|
||||
List<EntityReference> assignees = thread.getTask().getAssignees();
|
||||
if (!nullOrEmpty(assignees)) {
|
||||
for (EntityReference reference : assignees) {
|
||||
if (Entity.USER.equals(reference.getType())) {
|
||||
tempUserVar = Entity.getEntity(USER, reference.getId(), "profile", Include.NON_DELETED);
|
||||
users.put(tempUserVar.getId(), tempUserVar);
|
||||
} else if (TEAM.equals(reference.getType())) {
|
||||
tempTeamVar = Entity.getEntity(TEAM, reference.getId(), "profile", Include.NON_DELETED);
|
||||
teams.put(tempTeamVar.getId(), tempTeamVar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Post post : thread.getPosts()) {
|
||||
tempUserVar = Entity.getEntityByName(USER, post.getFrom(), "profile", Include.NON_DELETED);
|
||||
users.put(tempUserVar.getId(), tempUserVar);
|
||||
List<MessageParser.EntityLink> mentions = MessageParser.getEntityLinks(post.getMessage());
|
||||
for (MessageParser.EntityLink link : mentions) {
|
||||
if (USER.equals(link.getEntityType())) {
|
||||
tempUserVar = Entity.getEntity(link, "profile", Include.NON_DELETED);
|
||||
users.put(tempUserVar.getId(), tempUserVar);
|
||||
} else if (TEAM.equals(link.getEntityType())) {
|
||||
tempTeamVar = Entity.getEntity(link, "profile", Include.NON_DELETED);
|
||||
teams.put(tempTeamVar.getId(), tempTeamVar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Post post : thread.getPosts()) {
|
||||
tempUserVar = Entity.getEntityByName(USER, post.getFrom(), "profile", Include.NON_DELETED);
|
||||
users.put(tempUserVar.getId(), tempUserVar);
|
||||
List<MessageParser.EntityLink> mentions = MessageParser.getEntityLinks(post.getMessage());
|
||||
for (MessageParser.EntityLink link : mentions) {
|
||||
if (USER.equals(link.getEntityType())) {
|
||||
tempUserVar = Entity.getEntity(link, "profile", Include.NON_DELETED);
|
||||
users.put(tempUserVar.getId(), tempUserVar);
|
||||
} else if (TEAM.equals(link.getEntityType())) {
|
||||
tempTeamVar = Entity.getEntity(link, "profile", Include.NON_DELETED);
|
||||
teams.put(tempTeamVar.getId(), tempTeamVar);
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,7 +215,9 @@ public class SubscriptionUtil {
|
||||
}
|
||||
|
||||
public static Set<String> handleConversationNotification(
|
||||
SubscriptionDestination.SubscriptionType type, ChangeEvent event) {
|
||||
SubscriptionDestination.SubscriptionCategory category,
|
||||
SubscriptionDestination.SubscriptionType type,
|
||||
ChangeEvent event) {
|
||||
Thread thread = AlertsRuleEvaluator.getThread(event);
|
||||
Set<String> receiversList = new HashSet<>();
|
||||
Map<UUID, Team> teams = new HashMap<>();
|
||||
@ -208,33 +225,43 @@ public class SubscriptionUtil {
|
||||
|
||||
Team tempTeamVar = null;
|
||||
User tempUserVar = null;
|
||||
tempUserVar =
|
||||
Entity.getEntityByName(USER, thread.getCreatedBy(), "profile", Include.NON_DELETED);
|
||||
users.put(tempUserVar.getId(), tempUserVar);
|
||||
List<MessageParser.EntityLink> mentions = MessageParser.getEntityLinks(thread.getMessage());
|
||||
for (MessageParser.EntityLink link : mentions) {
|
||||
if (USER.equals(link.getEntityType())) {
|
||||
tempUserVar = Entity.getEntity(link, "profile", Include.NON_DELETED);
|
||||
users.put(tempUserVar.getId(), tempUserVar);
|
||||
} else if (TEAM.equals(link.getEntityType())) {
|
||||
tempTeamVar = Entity.getEntity(link, "", Include.NON_DELETED);
|
||||
teams.put(tempTeamVar.getId(), tempTeamVar);
|
||||
}
|
||||
}
|
||||
|
||||
for (Post post : thread.getPosts()) {
|
||||
tempUserVar = Entity.getEntityByName(USER, post.getFrom(), "profile", Include.NON_DELETED);
|
||||
users.put(tempUserVar.getId(), tempUserVar);
|
||||
mentions = MessageParser.getEntityLinks(post.getMessage());
|
||||
if (category.equals(SubscriptionDestination.SubscriptionCategory.MENTIONS)) {
|
||||
List<MessageParser.EntityLink> mentions = MessageParser.getEntityLinks(thread.getMessage());
|
||||
for (MessageParser.EntityLink link : mentions) {
|
||||
if (USER.equals(link.getEntityType())) {
|
||||
tempUserVar = Entity.getEntity(link, "profile", Include.NON_DELETED);
|
||||
users.put(tempUserVar.getId(), tempUserVar);
|
||||
} else if (TEAM.equals(link.getEntityType())) {
|
||||
tempTeamVar = Entity.getEntity(link, "profile", Include.NON_DELETED);
|
||||
tempTeamVar = Entity.getEntity(link, "", Include.NON_DELETED);
|
||||
teams.put(tempTeamVar.getId(), tempTeamVar);
|
||||
}
|
||||
}
|
||||
|
||||
for (Post post : thread.getPosts()) {
|
||||
tempUserVar = Entity.getEntityByName(USER, post.getFrom(), "profile", Include.NON_DELETED);
|
||||
users.put(tempUserVar.getId(), tempUserVar);
|
||||
mentions = MessageParser.getEntityLinks(post.getMessage());
|
||||
for (MessageParser.EntityLink link : mentions) {
|
||||
if (USER.equals(link.getEntityType())) {
|
||||
tempUserVar = Entity.getEntity(link, "profile", Include.NON_DELETED);
|
||||
users.put(tempUserVar.getId(), tempUserVar);
|
||||
} else if (TEAM.equals(link.getEntityType())) {
|
||||
tempTeamVar = Entity.getEntity(link, "profile", Include.NON_DELETED);
|
||||
teams.put(tempTeamVar.getId(), tempTeamVar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
@ -340,8 +367,9 @@ public class SubscriptionUtil {
|
||||
if (event.getEntityType().equals(THREAD)) {
|
||||
Thread thread = AlertsRuleEvaluator.getThread(event);
|
||||
switch (thread.getType()) {
|
||||
case Task -> receiverUrls.addAll(getTaskAssignees(type, event));
|
||||
case Conversation -> receiverUrls.addAll(handleConversationNotification(type, event));
|
||||
case Task -> receiverUrls.addAll(getTaskAssignees(category, type, event));
|
||||
case Conversation -> receiverUrls.addAll(
|
||||
handleConversationNotification(category, type, event));
|
||||
// TODO: For Announcement, Immediate Consumer needs to be Notified (find information from
|
||||
// Lineage)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user