diff options
Diffstat (limited to 'BackEnd/Timeline/Services')
6 files changed, 234 insertions, 11 deletions
diff --git a/BackEnd/Timeline/Services/User/Avatar/IUserAvatarService.cs b/BackEnd/Timeline/Services/User/Avatar/IUserAvatarService.cs index fda35aac..7ec855aa 100644 --- a/BackEnd/Timeline/Services/User/Avatar/IUserAvatarService.cs +++ b/BackEnd/Timeline/Services/User/Avatar/IUserAvatarService.cs @@ -14,7 +14,7 @@ namespace Timeline.Services.User.Avatar /// <param name="userId">User id.</param>
/// <returns>The avatar digest.</returns>
/// <exception cref="UserNotExistException">Thrown when user does not exist.</exception>
- Task<ICacheableDataDigest> GetAvatarDigest(long userId);
+ Task<ICacheableDataDigest> GetAvatarDigestAsync(long userId);
/// <summary>
/// Get avatar of a user. If the user has no avatar set, a default one is returned.
@@ -22,7 +22,7 @@ namespace Timeline.Services.User.Avatar /// <param name="userId">User id.</param>
/// <returns>The avatar.</returns>
/// <exception cref="UserNotExistException">Thrown when user does not exist.</exception>
- Task<ByteData> GetAvatar(long userId);
+ Task<ByteData> GetAvatarAsync(long userId);
/// <summary>
/// Set avatar for a user.
@@ -33,13 +33,13 @@ namespace Timeline.Services.User.Avatar /// <exception cref="ArgumentNullException">Thrown if <paramref name="avatar"/> is null.</exception>
/// <exception cref="UserNotExistException">Thrown when user does not exist.</exception>
/// <exception cref="ImageException">Thrown if avatar is of bad format.</exception>
- Task<ICacheableDataDigest> SetAvatar(long userId, ByteData avatar);
+ Task<ICacheableDataDigest> SetAvatarAsync(long userId, ByteData avatar);
/// <summary>
/// Remove avatar of a user.
/// </summary>
/// <param name="userId">User id.</param>
/// <exception cref="UserNotExistException">Thrown when user does not exist.</exception>
- Task DeleteAvatar(long userId);
+ Task DeleteAvatarAsync(long userId);
}
}
diff --git a/BackEnd/Timeline/Services/User/Avatar/Resource.Designer.cs b/BackEnd/Timeline/Services/User/Avatar/Resource.Designer.cs new file mode 100644 index 00000000..1c233a02 --- /dev/null +++ b/BackEnd/Timeline/Services/User/Avatar/Resource.Designer.cs @@ -0,0 +1,90 @@ +//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Timeline.Services.User.Avatar {
+ using System;
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resource {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resource() {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Services.User.Avatar.Resource", typeof(Resource).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Avatar data entry of user {0} does not exist..
+ /// </summary>
+ internal static string AvatarDataEntryNotExist {
+ get {
+ return ResourceManager.GetString("AvatarDataEntryNotExist", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Avatar of a user with id={0} is removed..
+ /// </summary>
+ internal static string LogRemoveAvatar {
+ get {
+ return ResourceManager.GetString("LogRemoveAvatar", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Avatar of a user with id={0} is updated..
+ /// </summary>
+ internal static string LogSetAvatar {
+ get {
+ return ResourceManager.GetString("LogSetAvatar", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/BackEnd/Timeline/Services/User/Avatar/Resource.resx b/BackEnd/Timeline/Services/User/Avatar/Resource.resx new file mode 100644 index 00000000..7cc919e3 --- /dev/null +++ b/BackEnd/Timeline/Services/User/Avatar/Resource.resx @@ -0,0 +1,129 @@ +<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="AvatarDataEntryNotExist" xml:space="preserve">
+ <value>Avatar data entry of user {0} does not exist.</value>
+ </data>
+ <data name="LogRemoveAvatar" xml:space="preserve">
+ <value>Avatar of a user with id={0} is removed.</value>
+ </data>
+ <data name="LogSetAvatar" xml:space="preserve">
+ <value>Avatar of a user with id={0} is updated.</value>
+ </data>
+</root>
\ No newline at end of file diff --git a/BackEnd/Timeline/Services/User/Avatar/UserAvatarService.cs b/BackEnd/Timeline/Services/User/Avatar/UserAvatarService.cs index 4f943e3a..92979a68 100644 --- a/BackEnd/Timeline/Services/User/Avatar/UserAvatarService.cs +++ b/BackEnd/Timeline/Services/User/Avatar/UserAvatarService.cs @@ -39,7 +39,7 @@ namespace Timeline.Services.User.Avatar _clock = clock;
}
- public async Task<ICacheableDataDigest> GetAvatarDigest(long userId)
+ public async Task<ICacheableDataDigest> GetAvatarDigestAsync(long userId)
{
var usernameChangeTime = await _basicUserService.GetUsernameLastModifiedTimeAsync(userId);
@@ -61,7 +61,7 @@ namespace Timeline.Services.User.Avatar }
}
- public async Task<ByteData> GetAvatar(long userId)
+ public async Task<ByteData> GetAvatarAsync(long userId)
{
await _basicUserService.ThrowIfUserNotExist(userId);
@@ -72,7 +72,7 @@ namespace Timeline.Services.User.Avatar return await _defaultUserAvatarProvider.GetDefaultAvatar();
}
- var data = await _dataManager.GetEntryAndCheck(entity.DataTag, $"This is required by avatar of {userId}.");
+ var data = await _dataManager.GetEntryAndCheck(entity.DataTag, string.Format(Resource.AvatarDataEntryNotExist, userId));
if (entity.Type is null)
{
@@ -84,7 +84,7 @@ namespace Timeline.Services.User.Avatar return new ByteData(data, entity.Type);
}
- public async Task<ICacheableDataDigest> SetAvatar(long userId, ByteData avatar)
+ public async Task<ICacheableDataDigest> SetAvatarAsync(long userId, ByteData avatar)
{
if (avatar is null)
throw new ArgumentNullException(nameof(avatar));
@@ -126,10 +126,12 @@ namespace Timeline.Services.User.Avatar await transaction.CommitAsync();
+ _logger.LogInformation(Resource.LogSetAvatar, userId);
+
return new CacheableDataDigest(tag, now);
}
- public async Task DeleteAvatar(long userId)
+ public async Task DeleteAvatarAsync(long userId)
{
await _basicUserService.ThrowIfUserNotExist(userId);
@@ -149,6 +151,8 @@ namespace Timeline.Services.User.Avatar await _database.SaveChangesAsync();
await transaction.CommitAsync();
+
+ _logger.LogInformation(Resource.LogRemoveAvatar, userId);
}
}
}
diff --git a/BackEnd/Timeline/Services/User/IUserDeleteService.cs b/BackEnd/Timeline/Services/User/IUserDeleteService.cs index ce9448ac..992a565c 100644 --- a/BackEnd/Timeline/Services/User/IUserDeleteService.cs +++ b/BackEnd/Timeline/Services/User/IUserDeleteService.cs @@ -13,6 +13,6 @@ namespace Timeline.Services.User /// <exception cref="ArgumentNullException">Thrown if <paramref name="username"/> is null.</exception>
/// <exception cref="ArgumentException">Thrown when <paramref name="username"/> is of bad format.</exception>
/// <exception cref="InvalidOperationOnRootUserException">Thrown when deleting root user.</exception>
- Task<bool> DeleteUser(string username);
+ Task<bool> DeleteUserAsync(string username);
}
}
diff --git a/BackEnd/Timeline/Services/User/UserDeleteService.cs b/BackEnd/Timeline/Services/User/UserDeleteService.cs index 94b15d33..e0391841 100644 --- a/BackEnd/Timeline/Services/User/UserDeleteService.cs +++ b/BackEnd/Timeline/Services/User/UserDeleteService.cs @@ -27,7 +27,7 @@ namespace Timeline.Services.User _timelinePostService = timelinePostService;
}
- public async Task<bool> DeleteUser(string username)
+ public async Task<bool> DeleteUserAsync(string username)
{
if (username == null)
throw new ArgumentNullException(nameof(username));
|