api: add support for {{Email}} placeholder in announcements

This commit is contained in:
Abdullah Atta
2025-11-28 13:01:28 +05:00
parent e489ce7376
commit 8dd9d0dc62

View File

@@ -25,6 +25,9 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using MongoDB.Driver;
using Notesnook.API.Models;
using Streetwriters.Common;
using Streetwriters.Common.Interfaces;
using Streetwriters.Common.Models;
using Streetwriters.Data.Repositories;
namespace Notesnook.API.Controllers
@@ -59,7 +62,13 @@ namespace Notesnook.API.Controllers
{
if (action.Type != "link" || action.Data == null) continue;
action.Data = action.Data.Replace("{{UserId}}", userId ?? "0");
action.Data = action.Data.Replace("{{UserId}}", userId ?? "");
if (action.Data.Contains("{{Email}}"))
{
var user = string.IsNullOrEmpty(userId) ? null : await (await WampServers.IdentityServer.GetServiceAsync<IUserAccountService>(IdentityServerTopics.UserAccountServiceTopic)).GetUserAsync(Clients.Notesnook.Id, userId);
action.Data = action.Data.Replace("{{Email}}", user?.Email ?? "");
}
}
}
}