From c73388256aad039239cf3977d7b079e3f9323258 Mon Sep 17 00:00:00 2001 From: crupest Date: Mon, 31 Aug 2020 22:22:57 +0800 Subject: Now uesr avatar put api returns etag. --- Timeline/Services/UserAvatarService.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'Timeline/Services/UserAvatarService.cs') diff --git a/Timeline/Services/UserAvatarService.cs b/Timeline/Services/UserAvatarService.cs index 2bf8bddc..b41c45fd 100644 --- a/Timeline/Services/UserAvatarService.cs +++ b/Timeline/Services/UserAvatarService.cs @@ -71,9 +71,10 @@ namespace Timeline.Services /// /// The id of the user to set avatar for. /// The avatar. Can be null to delete the saved avatar. + /// 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, Avatar? avatar); } // TODO! : Make this configurable. @@ -199,7 +200,7 @@ namespace Timeline.Services return defaultAvatar; } - public async Task SetAvatar(long id, Avatar? avatar) + public async Task SetAvatar(long id, Avatar? avatar) { if (avatar != null) { @@ -213,11 +214,7 @@ namespace Timeline.Services if (avatar == null) { - if (avatarEntity == null || avatarEntity.DataTag == null) - { - return; - } - else + if (avatarEntity != null && avatarEntity.DataTag != null) { await _dataManager.FreeEntry(avatarEntity.DataTag); avatarEntity.DataTag = null; @@ -226,6 +223,7 @@ namespace Timeline.Services await _database.SaveChangesAsync(); _logger.LogInformation(Resources.Services.UserAvatarService.LogUpdateEntity); } + return await _defaultUserAvatarProvider.GetDefaultAvatarETag(); } else { @@ -250,6 +248,8 @@ namespace Timeline.Services { await _dataManager.FreeEntry(oldTag); } + + return avatarEntity.DataTag; } } } -- cgit v1.2.3