From 253b06dfaa091d986a8714c081fd1e01679f538a Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 10 Feb 2021 02:03:06 +0800 Subject: ... --- BackEnd/Timeline/Services/UserAvatarService.cs | 37 +++++++------------------- 1 file changed, 9 insertions(+), 28 deletions(-) (limited to 'BackEnd/Timeline/Services/UserAvatarService.cs') diff --git a/BackEnd/Timeline/Services/UserAvatarService.cs b/BackEnd/Timeline/Services/UserAvatarService.cs index b41c45fd..afd6cf0a 100644 --- a/BackEnd/Timeline/Services/UserAvatarService.cs +++ b/BackEnd/Timeline/Services/UserAvatarService.cs @@ -8,28 +8,12 @@ using System.Linq; using System.Threading.Tasks; using Timeline.Entities; using Timeline.Helpers; +using Timeline.Helpers.Cache; +using Timeline.Models; using Timeline.Services.Exceptions; namespace Timeline.Services { - public class Avatar - { - public string Type { get; set; } = default!; - [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1819:Properties should not return arrays", Justification = "DTO Object")] - public byte[] Data { get; set; } = default!; - } - - public class AvatarInfo - { - public Avatar Avatar { get; set; } = default!; - public DateTime LastModified { get; set; } - - public CacheableData ToCacheableData() - { - return new CacheableData(Avatar.Type, Avatar.Data, LastModified); - } - } - /// /// Provider for default user avatar. /// @@ -42,29 +26,24 @@ namespace Timeline.Services /// Get the etag of default avatar. /// /// - Task GetDefaultAvatarETag(); + Task GetDefaultAvatarETag(); /// /// Get the default avatar. /// - Task GetDefaultAvatar(); + Task GetDefaultAvatar(); } public interface IUserAvatarService { - /// - /// Get the etag of a user's avatar. Warning: This method does not check the user existence. - /// - /// The id of the user to get avatar etag of. - /// The etag. - Task GetAvatarETag(long id); + Task GetAvatarDigest(long id); /// /// Get avatar of a user. If the user has no avatar set, a default one is returned. Warning: This method does not check the user existence. /// /// The id of the user to get avatar of. /// The avatar info. - Task GetAvatar(long id); + Task GetAvatar(long id); /// /// Set avatar for a user. Warning: This method does not check the user existence. @@ -74,7 +53,9 @@ namespace Timeline.Services /// The etag of the avatar. /// Thrown if any field in is null when is not null. /// Thrown if avatar is of bad format. - Task SetAvatar(long id, Avatar? avatar); + Task SetAvatar(long id, ByteData avatar); + + Task DeleteAvatar(long id); } // TODO! : Make this configurable. -- cgit v1.2.3