diff options
author | crupest <crupest@outlook.com> | 2021-01-31 16:07:07 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-01-31 16:07:07 +0800 |
commit | 27e6b7be9bce006da6aae651d9903573cf3fd180 (patch) | |
tree | cd7fbb5ad97d16bf9d301fd55fe6bf4da6e25160 /BackEnd/Timeline/Controllers | |
parent | 8b244ef8ad5f7c333fee4c39e3041846b87f0740 (diff) | |
download | timeline-27e6b7be9bce006da6aae651d9903573cf3fd180.tar.gz timeline-27e6b7be9bce006da6aae651d9903573cf3fd180.tar.bz2 timeline-27e6b7be9bce006da6aae651d9903573cf3fd180.zip |
...
Diffstat (limited to 'BackEnd/Timeline/Controllers')
-rw-r--r-- | BackEnd/Timeline/Controllers/TimelineController.cs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/BackEnd/Timeline/Controllers/TimelineController.cs b/BackEnd/Timeline/Controllers/TimelineController.cs index 06ab8004..8479ca83 100644 --- a/BackEnd/Timeline/Controllers/TimelineController.cs +++ b/BackEnd/Timeline/Controllers/TimelineController.cs @@ -4,7 +4,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using Timeline.Filters;
using Timeline.Models;
@@ -54,7 +53,7 @@ namespace Timeline.Controllers [HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
- public async Task<ActionResult<List<HttpTimeline>>> TimelineList([FromQuery][Username] string? relate, [FromQuery][RegularExpression("(own)|(join)")] string? relateType, [FromQuery] string? visibility)
+ public async Task<ActionResult<List<HttpTimeline>>> TimelineList([FromQuery][Username] string? relate, [FromQuery][ValidationSet("own", "join", "default")] string? relateType, [FromQuery] string? visibility)
{
List<TimelineVisibility>? visibilityFilter = null;
if (visibility != null)
@@ -92,12 +91,9 @@ namespace Timeline.Controllers {
var relatedUserId = await _userService.GetUserIdByUsername(relate);
- relationship = new TimelineUserRelationship(relateType switch
- {
- "own" => TimelineUserRelationshipType.Own,
- "join" => TimelineUserRelationshipType.Join,
- _ => TimelineUserRelationshipType.Default
- }, relatedUserId);
+ var relationType = relateType is null ? TimelineUserRelationshipType.Default : Enum.Parse<TimelineUserRelationshipType>(relateType, true);
+
+ relationship = new TimelineUserRelationship(relationType, relatedUserId);
}
catch (UserNotExistException)
{
|