ntfy
This commit is contained in:
@@ -1,13 +1,19 @@
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using StatiKosev.Services;
|
||||
|
||||
namespace StatiKosev.Pages;
|
||||
|
||||
public class IndexModel : PageModel
|
||||
public class IndexModel(NtfyNotifier ntfy) : PageModel
|
||||
{
|
||||
public string VisitorName { get; private set; } = "";
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
VisitorName = User.Identity?.IsAuthenticated == true ? User.Identity.Name! : "";
|
||||
|
||||
var userAgent = Request.Headers.UserAgent.ToString();
|
||||
ntfy.Notify("Home page visit",
|
||||
$"{(VisitorName == "" ? "Guest" : VisitorName)}\n{userAgent[..Math.Min(userAgent.Length, 160)]}",
|
||||
"eyes");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user