aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Services/UserAvatarService.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-08-31 22:49:57 +0800
committerGitHub <noreply@github.com>2020-08-31 22:49:57 +0800
commitedfefcf9bdbf5ba186a8f2c7d021acf04dbbb329 (patch)
treefdd69c951f68cda72ac1cbf017ca272ee1b783f5 /Timeline/Services/UserAvatarService.cs
parent1886b3411c69d8eb4fffbbfe29eb3a917d04e2f4 (diff)
parentff90e2819a1c0b7d1b605b45edaaaee7527c05b1 (diff)
downloadtimeline-edfefcf9bdbf5ba186a8f2c7d021acf04dbbb329.tar.gz
timeline-edfefcf9bdbf5ba186a8f2c7d021acf04dbbb329.tar.bz2
timeline-edfefcf9bdbf5ba186a8f2c7d021acf04dbbb329.zip
Merge pull request #158 from crupest/dev
Develop new features of back end.
Diffstat (limited to 'Timeline/Services/UserAvatarService.cs')
-rw-r--r--Timeline/Services/UserAvatarService.cs14
1 files changed, 7 insertions, 7 deletions
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
/// </summary>
/// <param name="id">The id of the user to set avatar for.</param>
/// <param name="avatar">The avatar. Can be null to delete the saved avatar.</param>
+ /// <returns>The etag of the avatar.</returns>
/// <exception cref="ArgumentException">Thrown if any field in <paramref name="avatar"/> is null when <paramref name="avatar"/> is not null.</exception>
/// <exception cref="ImageException">Thrown if avatar is of bad format.</exception>
- Task SetAvatar(long id, Avatar? avatar);
+ Task<string> 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<string> 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;
}
}
}