mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 00:06:05 -07:00
Fixed the issue comment issue #1914 also added another variable for issues {IssueUser} which is the user that reported the issue
This commit is contained in:
parent
2df80913c4
commit
2fbde15c40
4 changed files with 34 additions and 16 deletions
|
@ -150,6 +150,10 @@ namespace Ombi.Notifications.Agents
|
||||||
var isAdmin = bool.Parse(isAdminString);
|
var isAdmin = bool.Parse(isAdminString);
|
||||||
message.To = isAdmin ? model.Recipient : settings.AdminEmail;
|
message.To = isAdmin ? model.Recipient : settings.AdminEmail;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message.To = model.Recipient;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
await Send(message, settings);
|
await Send(message, settings);
|
||||||
|
|
|
@ -81,6 +81,7 @@ namespace Ombi.Notifications
|
||||||
IssueStatus = opts.Substitutes.TryGetValue("IssueStatus", out val) ? val : string.Empty;
|
IssueStatus = opts.Substitutes.TryGetValue("IssueStatus", out val) ? val : string.Empty;
|
||||||
IssueSubject = opts.Substitutes.TryGetValue("IssueSubject", out val) ? val : string.Empty;
|
IssueSubject = opts.Substitutes.TryGetValue("IssueSubject", out val) ? val : string.Empty;
|
||||||
NewIssueComment = opts.Substitutes.TryGetValue("NewIssueComment", out val) ? val : string.Empty;
|
NewIssueComment = opts.Substitutes.TryGetValue("NewIssueComment", out val) ? val : string.Empty;
|
||||||
|
IssueUser = opts.Substitutes.TryGetValue("IssueUser", out val) ? val : string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
// User Defined
|
// User Defined
|
||||||
|
@ -101,6 +102,7 @@ namespace Ombi.Notifications
|
||||||
public string IssueStatus { get; set; }
|
public string IssueStatus { get; set; }
|
||||||
public string IssueSubject { get; set; }
|
public string IssueSubject { get; set; }
|
||||||
public string NewIssueComment { get; set; }
|
public string NewIssueComment { get; set; }
|
||||||
|
public string IssueUser { get; set; }
|
||||||
|
|
||||||
// System Defined
|
// System Defined
|
||||||
private string LongDate => DateTime.Now.ToString("D");
|
private string LongDate => DateTime.Now.ToString("D");
|
||||||
|
@ -131,6 +133,7 @@ namespace Ombi.Notifications
|
||||||
{nameof(IssueStatus),IssueStatus},
|
{nameof(IssueStatus),IssueStatus},
|
||||||
{nameof(IssueSubject),IssueSubject},
|
{nameof(IssueSubject),IssueSubject},
|
||||||
{nameof(NewIssueComment),NewIssueComment},
|
{nameof(NewIssueComment),NewIssueComment},
|
||||||
|
{nameof(IssueUser),IssueUser},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -35,16 +35,17 @@ export enum NotificationAgent {
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum NotificationType {
|
export enum NotificationType {
|
||||||
NewRequest,
|
NewRequest = 0,
|
||||||
Issue,
|
Issue = 1,
|
||||||
RequestAvailable,
|
RequestAvailable = 2,
|
||||||
RequestApproved,
|
RequestApproved = 3,
|
||||||
AdminNote,
|
AdminNote = 4,
|
||||||
Test,
|
Test = 5,
|
||||||
RequestDeclined,
|
RequestDeclined = 6,
|
||||||
ItemAddedToFaultQueue,
|
ItemAddedToFaultQueue = 7,
|
||||||
WelcomeEmail,
|
WelcomeEmail = 8,
|
||||||
IssueResolved,
|
IssueResolved = 9,
|
||||||
|
IssueComment = 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IDiscordNotifcationSettings extends INotificationSettings {
|
export interface IDiscordNotifcationSettings extends INotificationSettings {
|
||||||
|
|
|
@ -145,7 +145,7 @@ namespace Ombi.Controllers
|
||||||
UserId = i.UserReportedId
|
UserId = i.UserReportedId
|
||||||
};
|
};
|
||||||
|
|
||||||
AddIssueNotificationSubstitutes(notificationModel, i);
|
AddIssueNotificationSubstitutes(notificationModel, i, User.Identity.Name);
|
||||||
|
|
||||||
BackgroundJob.Enqueue(() => _notification.Publish(notificationModel));
|
BackgroundJob.Enqueue(() => _notification.Publish(notificationModel));
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ namespace Ombi.Controllers
|
||||||
{
|
{
|
||||||
var user = await _userManager.Users.Where(x => User.Identity.Name == x.UserName)
|
var user = await _userManager.Users.Where(x => User.Identity.Name == x.UserName)
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
var issue = await _issues.Find(comment.IssueId ?? 0);
|
var issue = await _issues.GetAll().Include(x => x.UserReported).FirstOrDefaultAsync(x => x.Id == comment.IssueId);
|
||||||
if (issue == null)
|
if (issue == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@ -214,15 +214,24 @@ namespace Ombi.Controllers
|
||||||
DateTime = DateTime.Now,
|
DateTime = DateTime.Now,
|
||||||
NotificationType = NotificationType.IssueComment,
|
NotificationType = NotificationType.IssueComment,
|
||||||
RequestType = issue.RequestType,
|
RequestType = issue.RequestType,
|
||||||
Recipient = user.Email,
|
|
||||||
UserId = user.Id
|
UserId = user.Id
|
||||||
};
|
};
|
||||||
|
|
||||||
var isAdmin = await _userManager.IsInRoleAsync(user, OmbiRoles.Admin);
|
var isAdmin = await _userManager.IsInRoleAsync(user, OmbiRoles.Admin);
|
||||||
AddIssueNotificationSubstitutes(notificationModel, issue);
|
AddIssueNotificationSubstitutes(notificationModel, issue, issue.UserReported.UserAlias);
|
||||||
notificationModel.Substitutes.Add("NewIssueComment", comment.Comment);
|
notificationModel.Substitutes.Add("NewIssueComment", comment.Comment);
|
||||||
notificationModel.Substitutes.Add("AdminComment", isAdmin.ToString());
|
notificationModel.Substitutes.Add("AdminComment", isAdmin.ToString());
|
||||||
|
|
||||||
|
if (isAdmin)
|
||||||
|
{
|
||||||
|
// Send to user
|
||||||
|
notificationModel.Recipient = issue.UserReported.Email;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
notificationModel.Recipient = user.Email;
|
||||||
|
}
|
||||||
|
|
||||||
BackgroundJob.Enqueue(() => _notification.Publish(notificationModel));
|
BackgroundJob.Enqueue(() => _notification.Publish(notificationModel));
|
||||||
|
|
||||||
return await _issueComments.Add(newComment);
|
return await _issueComments.Add(newComment);
|
||||||
|
@ -257,7 +266,7 @@ namespace Ombi.Controllers
|
||||||
UserId = user.Id,
|
UserId = user.Id,
|
||||||
|
|
||||||
};
|
};
|
||||||
AddIssueNotificationSubstitutes(notificationModel, issue);
|
AddIssueNotificationSubstitutes(notificationModel, issue, issue.UserReported?.UserAlias ?? string.Empty);
|
||||||
|
|
||||||
BackgroundJob.Enqueue(() => _notification.Publish(notificationModel));
|
BackgroundJob.Enqueue(() => _notification.Publish(notificationModel));
|
||||||
}
|
}
|
||||||
|
@ -266,13 +275,14 @@ namespace Ombi.Controllers
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddIssueNotificationSubstitutes(NotificationOptions notificationModel, Issues issue)
|
private static void AddIssueNotificationSubstitutes(NotificationOptions notificationModel, Issues issue, string issueReportedUsername)
|
||||||
{
|
{
|
||||||
notificationModel.Substitutes.Add("Title", issue.Title);
|
notificationModel.Substitutes.Add("Title", issue.Title);
|
||||||
notificationModel.Substitutes.Add("IssueDescription", issue.Description);
|
notificationModel.Substitutes.Add("IssueDescription", issue.Description);
|
||||||
notificationModel.Substitutes.Add("IssueCategory", issue.IssueCategory?.Value);
|
notificationModel.Substitutes.Add("IssueCategory", issue.IssueCategory?.Value);
|
||||||
notificationModel.Substitutes.Add("IssueStatus", issue.Status.ToString());
|
notificationModel.Substitutes.Add("IssueStatus", issue.Status.ToString());
|
||||||
notificationModel.Substitutes.Add("IssueSubject", issue.Subject);
|
notificationModel.Substitutes.Add("IssueSubject", issue.Subject);
|
||||||
|
notificationModel.Substitutes.Add("IssueUser", issueReportedUsername);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue