Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Oqtane.Client/Modules/Admin/UserProfile/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,13 @@

@if (context.IsRead)
{
<td>@context.FromDisplayName</td>
<td>@(string.IsNullOrEmpty(context.FromDisplayName) ? SharedLocalizer["System"] : context.FromDisplayName)</td>
<td>@context.Subject</td>
<td>@string.Format("{0:dd-MMM-yyyy HH:mm:ss}", @context.CreatedOn)</td>
}
else
{
<td><b>@context.FromDisplayName</b></td>
<td><b>@(string.IsNullOrEmpty(context.FromDisplayName) ? SharedLocalizer["System"] : context.FromDisplayName)</b></td>
<td><b>@context.Subject</b></td>
<td><b>@string.Format("{0:dd-MMM-yyyy HH:mm:ss}", @context.CreatedOn)</b></td>
}
Expand Down
2 changes: 1 addition & 1 deletion Oqtane.Client/Modules/Admin/UserProfile/View.razor
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
createdon = notification.CreatedOn.ToString();
body = notification.Body;

if (title == "From")
if (title == "From" && !notification.IsRead)
{
notification.IsRead = true;
notification = await NotificationService.UpdateNotificationAsync(notification);
Expand Down
3 changes: 3 additions & 0 deletions Oqtane.Client/Resources/Modules/Admin/Site/Index.resx
Original file line number Diff line number Diff line change
Expand Up @@ -435,4 +435,7 @@
<data name="Functionality" xml:space="preserve">
<value>Functionality</value>
</data>
<data name="System" xml:space="preserve">
<value>System</value>
</data>
</root>
4 changes: 2 additions & 2 deletions Oqtane.Server/Controllers/NotificationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public Notification Put(int id, [FromBody] Notification notification)
{
if (ModelState.IsValid && notification.SiteId == _alias.SiteId && notification.NotificationId == id && _notifications.GetNotification(notification.NotificationId, false) != null && (IsAuthorized(notification.FromUserId) || IsAuthorized(notification.ToUserId)))
{
if (!User.IsInRole(RoleNames.Admin))
if (!User.IsInRole(RoleNames.Admin) && notification.FromUserId != null)
{
// content must be HTML encoded for non-admins to prevent HTML injection
notification.Subject = WebUtility.HtmlEncode(notification.Subject);
Expand Down Expand Up @@ -223,7 +223,7 @@ public void Delete(int id)

private bool IsAuthorized(int? userid)
{
bool authorized = true;
bool authorized = false;
if (userid != null)
{
authorized = (_userPermissions.GetUser(User).UserId == userid);
Expand Down
8 changes: 4 additions & 4 deletions Oqtane.Shared/Models/Notification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,25 +144,25 @@ private void ConstructNotification(int siteId, User from, string fromDisplayName
{
FromUserId = from.UserId;
FromDisplayName = from.DisplayName;
FromEmail = from.Email;
FromEmail = from.Email ?? "";
}
else
{
FromUserId = null;
FromDisplayName = fromDisplayName;
FromEmail = fromEmail;
FromEmail = fromEmail ?? "";
}
if (to != null)
{
ToUserId = to.UserId;
ToDisplayName = to.DisplayName;
ToEmail = to.Email;
ToEmail = to.Email ?? "";
}
else
{
ToUserId = null;
ToDisplayName = toDisplayName;
ToEmail = toEmail;
ToEmail = toEmail ?? "";
}
Subject = subject;
Body = body;
Expand Down