mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-08 06:00:50 -07:00
Added gravitar image
This commit is contained in:
parent
f6bf6493b2
commit
7d8848a69c
17 changed files with 137 additions and 25 deletions
|
@ -29,10 +29,12 @@ using System;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Nancy;
|
||||
using Nancy.Responses;
|
||||
using NLog;
|
||||
using Ombi.Core;
|
||||
using Ombi.Core.SettingModels;
|
||||
using Ombi.Core.StatusChecker;
|
||||
using Ombi.Core.Users;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Services.Interfaces;
|
||||
using Ombi.Services.Jobs;
|
||||
|
@ -43,14 +45,16 @@ namespace Ombi.UI.Modules
|
|||
{
|
||||
public class LayoutModule : BaseAuthModule
|
||||
{
|
||||
public LayoutModule(ICacheProvider provider, ISettingsService<PlexRequestSettings> pr, ISettingsService<SystemSettings> settings, IJobRecord rec, ISecurityExtensions security) : base("layout", pr, security)
|
||||
public LayoutModule(ICacheProvider provider, ISettingsService<PlexRequestSettings> pr, ISettingsService<SystemSettings> settings, IJobRecord rec, ISecurityExtensions security, IUserHelper helper) : base("layout", pr, security)
|
||||
{
|
||||
Cache = provider;
|
||||
SystemSettings = settings;
|
||||
Job = rec;
|
||||
UserHelper = helper;
|
||||
|
||||
Get["/", true] = async (x,ct) => await CheckLatestVersion();
|
||||
Get["/cacher", true] = async (x,ct) => await CacherRunning();
|
||||
Get["/gravatar"] = x => GetGravatarImage();
|
||||
}
|
||||
|
||||
private ICacheProvider Cache { get; }
|
||||
|
@ -58,6 +62,7 @@ namespace Ombi.UI.Modules
|
|||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private ISettingsService<SystemSettings> SystemSettings { get; }
|
||||
private IJobRecord Job { get; }
|
||||
private IUserHelper UserHelper { get; }
|
||||
|
||||
private async Task<Response> CheckLatestVersion()
|
||||
{
|
||||
|
@ -116,5 +121,24 @@ namespace Ombi.UI.Modules
|
|||
return Response.AsJson(new { CurrentlyRunning = false, IsAdmin });
|
||||
}
|
||||
}
|
||||
|
||||
private Response GetGravatarImage()
|
||||
{
|
||||
if (LoggedIn)
|
||||
{
|
||||
var user = UserHelper.GetUser(Username);
|
||||
var hashed = StringHasher.CalcuateMd5Hash(user.EmailAddress);
|
||||
return
|
||||
Response.AsJson(new JsonResponseModel
|
||||
{
|
||||
Result = true,
|
||||
Message = $"https://www.gravatar.com/avatar/{hashed}"
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return Response.AsJson(new JsonResponseModel {Result = false});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue