summaryrefslogtreecommitdiff
path: root/Project-Unite/NotificationDaemon.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-05-18 16:18:25 -0400
committerMichael <[email protected]>2017-05-18 16:18:25 -0400
commit1d8b307bb5790aa8c0040a76638f57f757cfb782 (patch)
tree0a5eccc30e386c926db471882c2cde9d4174c669 /Project-Unite/NotificationDaemon.cs
parent0571a9c8d98d3d01bc1a821577c181a0b722e6c7 (diff)
downloadproject-unite-1d8b307bb5790aa8c0040a76638f57f757cfb782.tar.gz
project-unite-1d8b307bb5790aa8c0040a76638f57f757cfb782.tar.bz2
project-unite-1d8b307bb5790aa8c0040a76638f57f757cfb782.zip
More notification updates
Diffstat (limited to 'Project-Unite/NotificationDaemon.cs')
-rw-r--r--Project-Unite/NotificationDaemon.cs27
1 files changed, 25 insertions, 2 deletions
diff --git a/Project-Unite/NotificationDaemon.cs b/Project-Unite/NotificationDaemon.cs
index 2e548ea..0512790 100644
--- a/Project-Unite/NotificationDaemon.cs
+++ b/Project-Unite/NotificationDaemon.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
+using Microsoft.AspNet.Identity.Owin;
using Microsoft.AspNet.SignalR;
using Project_Unite.Models;
@@ -70,18 +71,40 @@ namespace Project_Unite
var user = db.Users.FirstOrDefault(x => x.Id == uid);
if (user == null)
throw new Exception("Cannot find user with ID " + target + ".");
+ string id = Guid.NewGuid().ToString();
var note = new Notification
{
- Id = Guid.NewGuid().ToString(),
+ Id = id,
UserId = target,
Title = title,
Timestamp = DateTime.Now,
- ActionUrl = url,
+ ActionUrl = $"http://getshiftos.ml/Manage/Notification/{id}?url={Uri.EscapeDataString(url)}",
Description = desc,
AvatarUrl = user.AvatarUrl
};
db.Notifications.Add(note);
+ var t = db.Users.FirstOrDefault(x => x.Id == target);
+ if (t.EmailOnNotifications)
+ {
+ if (t.LastLogin <= DateTime.Now.AddDays(-7))
+ {
+ var man = HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>();
+ man.SendEmailAsync(target, "New notification", $@"<h1>New notification</h1>
+
+<h3>{note.Title}</h3>
+
+<img src=""{note.AvatarUrl}"" width=""128"" height=""128"" style=""border-radius:100%""/>
+<h4>{user.FullName}</h4>
+<h5>{user.DisplayName}</h5>
+
+<p>{note.Description}</p>
+
+<a href=""{note.ActionUrl}"">Click here to acknowledge this notification.</a>");
+
+ }
+ }
+
db.SaveChanges();
SendMessage(target, ComposeHtml(note));