mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
- Notifications will no longer be send to the admins if they request something.
- Looks like we missed out adding the notifications to Music requests, so I added that in
This commit is contained in:
parent
96a40a2aaa
commit
d44612217a
1 changed files with 67 additions and 21 deletions
|
@ -499,15 +499,16 @@ namespace PlexRequests.UI.Modules
|
||||||
Log.Info("Adding movie to database (No approval required)");
|
Log.Info("Adding movie to database (No approval required)");
|
||||||
RequestService.AddRequest(model);
|
RequestService.AddRequest(model);
|
||||||
|
|
||||||
var notificationModel = new NotificationModel
|
|
||||||
{
|
if (ShouldSendNotification) {
|
||||||
|
var notificationModel = new NotificationModel {
|
||||||
Title = model.Title,
|
Title = model.Title,
|
||||||
User = Username,
|
User = Username,
|
||||||
DateTime = DateTime.Now,
|
DateTime = DateTime.Now,
|
||||||
NotificationType = NotificationType.NewRequest
|
NotificationType = NotificationType.NewRequest
|
||||||
};
|
};
|
||||||
NotificationService.Publish(notificationModel);
|
NotificationService.Publish (notificationModel);
|
||||||
|
}
|
||||||
return Response.AsJson(new JsonResponseModel { Result = true, Message = $"{fullMovieName} was successfully added!" });
|
return Response.AsJson(new JsonResponseModel { Result = true, Message = $"{fullMovieName} was successfully added!" });
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -524,14 +525,15 @@ namespace PlexRequests.UI.Modules
|
||||||
Log.Info("Adding movie to database (No approval required)");
|
Log.Info("Adding movie to database (No approval required)");
|
||||||
RequestService.AddRequest(model);
|
RequestService.AddRequest(model);
|
||||||
|
|
||||||
var notificationModel = new NotificationModel
|
if (ShouldSendNotification) {
|
||||||
{
|
var notificationModel = new NotificationModel {
|
||||||
Title = model.Title,
|
Title = model.Title,
|
||||||
User = Username,
|
User = Username,
|
||||||
DateTime = DateTime.Now,
|
DateTime = DateTime.Now,
|
||||||
NotificationType = NotificationType.NewRequest
|
NotificationType = NotificationType.NewRequest
|
||||||
};
|
};
|
||||||
NotificationService.Publish(notificationModel);
|
NotificationService.Publish (notificationModel);
|
||||||
|
}
|
||||||
|
|
||||||
return Response.AsJson(new JsonResponseModel { Result = true, Message = $"{fullMovieName} was successfully added!" });
|
return Response.AsJson(new JsonResponseModel { Result = true, Message = $"{fullMovieName} was successfully added!" });
|
||||||
}
|
}
|
||||||
|
@ -657,9 +659,16 @@ namespace PlexRequests.UI.Modules
|
||||||
model.Approved = true;
|
model.Approved = true;
|
||||||
Log.Debug("Adding tv to database requests (No approval required & Sonarr)");
|
Log.Debug("Adding tv to database requests (No approval required & Sonarr)");
|
||||||
RequestService.AddRequest(model);
|
RequestService.AddRequest(model);
|
||||||
var notify1 = new NotificationModel { Title = model.Title, User = Username, DateTime = DateTime.Now, NotificationType = NotificationType.NewRequest };
|
|
||||||
NotificationService.Publish(notify1);
|
|
||||||
|
|
||||||
|
if (ShouldSendNotification) {
|
||||||
|
var notify1 = new NotificationModel {
|
||||||
|
Title = model.Title,
|
||||||
|
User = Username,
|
||||||
|
DateTime = DateTime.Now,
|
||||||
|
NotificationType = NotificationType.NewRequest
|
||||||
|
};
|
||||||
|
NotificationService.Publish (notify1);
|
||||||
|
}
|
||||||
return Response.AsJson(new JsonResponseModel { Result = true, Message = $"{fullShowName} was successfully added!" });
|
return Response.AsJson(new JsonResponseModel { Result = true, Message = $"{fullShowName} was successfully added!" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -677,9 +686,15 @@ namespace PlexRequests.UI.Modules
|
||||||
model.Approved = true;
|
model.Approved = true;
|
||||||
Log.Debug("Adding tv to database requests (No approval required & SickRage)");
|
Log.Debug("Adding tv to database requests (No approval required & SickRage)");
|
||||||
RequestService.AddRequest(model);
|
RequestService.AddRequest(model);
|
||||||
|
if (ShouldSendNotification) {
|
||||||
var notify2 = new NotificationModel { Title = model.Title, User = Username, DateTime = DateTime.Now, NotificationType = NotificationType.NewRequest };
|
var notify2 = new NotificationModel {
|
||||||
NotificationService.Publish(notify2);
|
Title = model.Title,
|
||||||
|
User = Username,
|
||||||
|
DateTime = DateTime.Now,
|
||||||
|
NotificationType = NotificationType.NewRequest
|
||||||
|
};
|
||||||
|
NotificationService.Publish (notify2);
|
||||||
|
}
|
||||||
|
|
||||||
return Response.AsJson(new JsonResponseModel { Result = true, Message = $"{fullShowName} was successfully added!" });
|
return Response.AsJson(new JsonResponseModel { Result = true, Message = $"{fullShowName} was successfully added!" });
|
||||||
}
|
}
|
||||||
|
@ -698,6 +713,18 @@ namespace PlexRequests.UI.Modules
|
||||||
return Response.AsJson(new JsonResponseModel { Result = true, Message = $"{fullShowName} was successfully added!" });
|
return Response.AsJson(new JsonResponseModel { Result = true, Message = $"{fullShowName} was successfully added!" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool ShouldSendNotification(){
|
||||||
|
var sendNotification = true;
|
||||||
|
var claims = Context.CurrentUser?.Claims;
|
||||||
|
if (claims != null) {
|
||||||
|
if (claims.Contains (UserClaims.Admin) || claims.Contains (UserClaims.PowerUser)) {
|
||||||
|
sendNotification = false; // Don't bother sending a notification if the user is an admin
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sendNotification;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private Response RequestAlbum(string releaseId, bool notify)
|
private Response RequestAlbum(string releaseId, bool notify)
|
||||||
{
|
{
|
||||||
var settings = PrService.GetSettings();
|
var settings = PrService.GetSettings();
|
||||||
|
@ -798,6 +825,16 @@ namespace PlexRequests.UI.Modules
|
||||||
model.Approved = true;
|
model.Approved = true;
|
||||||
RequestService.AddRequest(model);
|
RequestService.AddRequest(model);
|
||||||
|
|
||||||
|
if (ShouldSendNotification ()) {
|
||||||
|
var notify2 = new NotificationModel {
|
||||||
|
Title = model.Title,
|
||||||
|
User = Username,
|
||||||
|
DateTime = DateTime.Now,
|
||||||
|
NotificationType = NotificationType.NewRequest
|
||||||
|
};
|
||||||
|
NotificationService.Publish (notify2);
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
Response.AsJson(new JsonResponseModel
|
Response.AsJson(new JsonResponseModel
|
||||||
{
|
{
|
||||||
|
@ -806,6 +843,15 @@ namespace PlexRequests.UI.Modules
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ShouldSendNotification ()) {
|
||||||
|
var notify2 = new NotificationModel {
|
||||||
|
Title = model.Title,
|
||||||
|
User = Username,
|
||||||
|
DateTime = DateTime.Now,
|
||||||
|
NotificationType = NotificationType.NewRequest
|
||||||
|
};
|
||||||
|
NotificationService.Publish (notify2);
|
||||||
|
}
|
||||||
var result = RequestService.AddRequest(model);
|
var result = RequestService.AddRequest(model);
|
||||||
return Response.AsJson(new JsonResponseModel
|
return Response.AsJson(new JsonResponseModel
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue