added follower count
This commit is contained in:
parent
71a2e327b6
commit
6bd289b291
3 changed files with 20 additions and 1 deletions
|
@ -11,6 +11,8 @@ using BirdsiteLive.ActivityPub;
|
||||||
using BirdsiteLive.ActivityPub.Models;
|
using BirdsiteLive.ActivityPub.Models;
|
||||||
using BirdsiteLive.Common.Regexes;
|
using BirdsiteLive.Common.Regexes;
|
||||||
using BirdsiteLive.Common.Settings;
|
using BirdsiteLive.Common.Settings;
|
||||||
|
using BirdsiteLive.DAL.Contracts;
|
||||||
|
using BirdsiteLive.DAL.Models;
|
||||||
using BirdsiteLive.Domain;
|
using BirdsiteLive.Domain;
|
||||||
using BirdsiteLive.Models;
|
using BirdsiteLive.Models;
|
||||||
using BirdsiteLive.Tools;
|
using BirdsiteLive.Tools;
|
||||||
|
@ -30,16 +32,20 @@ namespace BirdsiteLive.Controllers
|
||||||
private readonly IUserService _userService;
|
private readonly IUserService _userService;
|
||||||
private readonly IStatusService _statusService;
|
private readonly IStatusService _statusService;
|
||||||
private readonly InstanceSettings _instanceSettings;
|
private readonly InstanceSettings _instanceSettings;
|
||||||
|
private readonly IFollowersDal _followersDal;
|
||||||
|
private readonly ITwitterUserDal _twitterUserDal;
|
||||||
private readonly ILogger<UsersController> _logger;
|
private readonly ILogger<UsersController> _logger;
|
||||||
|
|
||||||
#region Ctor
|
#region Ctor
|
||||||
public UsersController(ICachedTwitterUserService twitterUserService, IUserService userService, IStatusService statusService, InstanceSettings instanceSettings, ICachedTwitterTweetsService twitterTweetService, ILogger<UsersController> logger)
|
public UsersController(ICachedTwitterUserService twitterUserService, IUserService userService, IStatusService statusService, InstanceSettings instanceSettings, ICachedTwitterTweetsService twitterTweetService, IFollowersDal followersDal, ITwitterUserDal twitterUserDal, ILogger<UsersController> logger)
|
||||||
{
|
{
|
||||||
_twitterUserService = twitterUserService;
|
_twitterUserService = twitterUserService;
|
||||||
_userService = userService;
|
_userService = userService;
|
||||||
_statusService = statusService;
|
_statusService = statusService;
|
||||||
_instanceSettings = instanceSettings;
|
_instanceSettings = instanceSettings;
|
||||||
_twitterTweetService = twitterTweetService;
|
_twitterTweetService = twitterTweetService;
|
||||||
|
_followersDal = followersDal;
|
||||||
|
_twitterUserDal = twitterUserDal;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -119,6 +125,12 @@ namespace BirdsiteLive.Controllers
|
||||||
if (isSaturated) return View("ApiSaturated");
|
if (isSaturated) return View("ApiSaturated");
|
||||||
if (notFound) return View("UserNotFound");
|
if (notFound) return View("UserNotFound");
|
||||||
|
|
||||||
|
Follower[] followers = new Follower[] { };
|
||||||
|
|
||||||
|
var userDal = await _twitterUserDal.GetTwitterUserAsync(user.Acct);
|
||||||
|
if (userDal != null)
|
||||||
|
followers = await _followersDal.GetFollowersAsync(userDal.Id);
|
||||||
|
|
||||||
var displayableUser = new DisplayTwitterUser
|
var displayableUser = new DisplayTwitterUser
|
||||||
{
|
{
|
||||||
Name = user.Name,
|
Name = user.Name,
|
||||||
|
@ -127,6 +139,8 @@ namespace BirdsiteLive.Controllers
|
||||||
Url = user.Url,
|
Url = user.Url,
|
||||||
ProfileImageUrl = user.ProfileImageUrl,
|
ProfileImageUrl = user.ProfileImageUrl,
|
||||||
Protected = user.Protected,
|
Protected = user.Protected,
|
||||||
|
FollowerCount = followers.Length,
|
||||||
|
MostPopularServer = followers.GroupBy(x => x.Host).OrderByDescending(x => x.Count()).Select(x => x.Key).FirstOrDefault("N/A"),
|
||||||
|
|
||||||
InstanceHandle = $"@{user.Acct.ToLowerInvariant()}@{_instanceSettings.Domain}"
|
InstanceHandle = $"@{user.Acct.ToLowerInvariant()}@{_instanceSettings.Domain}"
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
public string Url { get; set; }
|
public string Url { get; set; }
|
||||||
public string ProfileImageUrl { get; set; }
|
public string ProfileImageUrl { get; set; }
|
||||||
public bool Protected { get; set; }
|
public bool Protected { get; set; }
|
||||||
|
public int FollowerCount { get; set; }
|
||||||
|
public string MostPopularServer { get; set; }
|
||||||
|
|
||||||
public string InstanceHandle { get; set; }
|
public string InstanceHandle { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,9 @@
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<br />
|
<br />
|
||||||
|
<div>
|
||||||
|
This account has @ViewData.Model.FollowerCount followers on the fediverse. The server with the most followers for this account is: @ViewData.Model.MostPopularServer
|
||||||
|
</div>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
@if (ViewData.Model.Protected)
|
@if (ViewData.Model.Protected)
|
||||||
|
|
Loading…
Add table
Reference in a new issue