aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Models/Http/UserInfo.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-03-12 19:56:20 +0800
committerGitHub <noreply@github.com>2020-03-12 19:56:20 +0800
commitd51954c2eaf07769e045270a02c19e46e01fe73f (patch)
tree70681348ddfc3bc8c3d9a92ae010a02020830573 /Timeline/Models/Http/UserInfo.cs
parenteb9554b4fe78eaced12329e7fd7d8d62a58a1c6c (diff)
parent45527eb0c836d14725019c3facdff6c8391531cf (diff)
downloadtimeline-d51954c2eaf07769e045270a02c19e46e01fe73f.tar.gz
timeline-d51954c2eaf07769e045270a02c19e46e01fe73f.tar.bz2
timeline-d51954c2eaf07769e045270a02c19e46e01fe73f.zip
Merge pull request #69 from crupest/image
Post image feature.
Diffstat (limited to 'Timeline/Models/Http/UserInfo.cs')
-rw-r--r--Timeline/Models/Http/UserInfo.cs16
1 files changed, 8 insertions, 8 deletions
diff --git a/Timeline/Models/Http/UserInfo.cs b/Timeline/Models/Http/UserInfo.cs
index 68c6d8bd..b4bf14c1 100644
--- a/Timeline/Models/Http/UserInfo.cs
+++ b/Timeline/Models/Http/UserInfo.cs
@@ -2,8 +2,8 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.Routing;
+using System;
using Timeline.Controllers;
-using Timeline.Services;
namespace Timeline.Models.Http
{
@@ -12,9 +12,9 @@ namespace Timeline.Models.Http
public string Username { get; set; } = default!;
public string Nickname { get; set; } = default!;
public bool? Administrator { get; set; } = default!;
-#pragma warning disable CA1707
- public UserInfoLinks? _links { get; set; }
-#pragma warning restore CA1707
+#pragma warning disable CA1707 // Identifiers should not contain underscores
+ public UserInfoLinks _links { get; set; } = default!;
+#pragma warning restore CA1707 // Identifiers should not contain underscores
}
public class UserInfoLinks
@@ -24,7 +24,7 @@ namespace Timeline.Models.Http
public string Timeline { get; set; } = default!;
}
- public class UserInfoLinksValueResolver : IValueResolver<User, UserInfo, UserInfoLinks?>
+ public class UserInfoLinksValueResolver : IValueResolver<User, UserInfo, UserInfoLinks>
{
private readonly IActionContextAccessor _actionContextAccessor;
private readonly IUrlHelperFactory _urlHelperFactory;
@@ -35,17 +35,17 @@ namespace Timeline.Models.Http
_urlHelperFactory = urlHelperFactory;
}
- public UserInfoLinks? Resolve(User source, UserInfo destination, UserInfoLinks? destMember, ResolutionContext context)
+ public UserInfoLinks Resolve(User source, UserInfo destination, UserInfoLinks destMember, ResolutionContext context)
{
if (_actionContextAccessor.ActionContext == null)
- return null;
+ throw new InvalidOperationException("No action context, can't fill urls.");
var urlHelper = _urlHelperFactory.GetUrlHelper(_actionContextAccessor.ActionContext);
var result = new UserInfoLinks
{
Self = urlHelper.ActionLink(nameof(UserController.Get), nameof(UserController)[0..^nameof(Controller).Length], new { destination.Username }),
Avatar = urlHelper.ActionLink(nameof(UserAvatarController.Get), nameof(UserAvatarController)[0..^nameof(Controller).Length], new { destination.Username }),
- Timeline = urlHelper.ActionLink(nameof(PersonalTimelineController.TimelineGet), nameof(PersonalTimelineController)[0..^nameof(Controller).Length], new { destination.Username })
+ Timeline = urlHelper.ActionLink(nameof(TimelineController.TimelineGet), nameof(TimelineController)[0..^nameof(Controller).Length], new { Name = "@" + destination.Username })
};
return result;
}