diff options
Diffstat (limited to 'Timeline')
-rw-r--r-- | Timeline/Controllers/TimelineController.cs | 4 | ||||
-rw-r--r-- | Timeline/Filters/Timeline.cs | 2 | ||||
-rw-r--r-- | Timeline/Models/Http/ErrorResponse.cs | 29 | ||||
-rw-r--r-- | Timeline/Resources/Messages.Designer.cs | 51 | ||||
-rw-r--r-- | Timeline/Resources/Messages.resx | 21 | ||||
-rw-r--r-- | Timeline/Services/TimelineService.cs | 14 |
6 files changed, 69 insertions, 52 deletions
diff --git a/Timeline/Controllers/TimelineController.cs b/Timeline/Controllers/TimelineController.cs index d21603cd..0628937d 100644 --- a/Timeline/Controllers/TimelineController.cs +++ b/Timeline/Controllers/TimelineController.cs @@ -234,7 +234,7 @@ namespace Timeline.Controllers }
catch (UserNotExistException)
{
- return BadRequest(ErrorResponse.TimelineCommon.MemberPut_NotExist());
+ return BadRequest(ErrorResponse.TimelineController.MemberPut_NotExist());
}
}
@@ -272,7 +272,7 @@ namespace Timeline.Controllers }
catch (ConflictException)
{
- return BadRequest(ErrorResponse.TimelineCommon.NameConflict());
+ return BadRequest(ErrorResponse.TimelineController.NameConflict());
}
}
diff --git a/Timeline/Filters/Timeline.cs b/Timeline/Filters/Timeline.cs index e133c9d6..76e8d751 100644 --- a/Timeline/Filters/Timeline.cs +++ b/Timeline/Filters/Timeline.cs @@ -17,7 +17,7 @@ namespace Timeline.Filters }
else
{
- context.Result = new NotFoundObjectResult(ErrorResponse.TimelineCommon.NotExist());
+ context.Result = new NotFoundObjectResult(ErrorResponse.TimelineController.NotExist());
}
}
}
diff --git a/Timeline/Models/Http/ErrorResponse.cs b/Timeline/Models/Http/ErrorResponse.cs index 9f7e70e1..9c5a7cfe 100644 --- a/Timeline/Models/Http/ErrorResponse.cs +++ b/Timeline/Models/Http/ErrorResponse.cs @@ -242,44 +242,39 @@ namespace Timeline.Models.Http }
- public static class TimelineCommon
+ public static class TimelineController
{
public static CommonResponse NameConflict(params object?[] formatArgs)
{
- return new CommonResponse(ErrorCodes.TimelineCommon.NameConflict, string.Format(TimelineCommon_NameConflict, formatArgs));
+ return new CommonResponse(ErrorCodes.TimelineController.NameConflict, string.Format(TimelineController_NameConflict, formatArgs));
}
public static CommonResponse CustomMessage_NameConflict(string message, params object?[] formatArgs)
{
- return new CommonResponse(ErrorCodes.TimelineCommon.NameConflict, string.Format(message, formatArgs));
+ return new CommonResponse(ErrorCodes.TimelineController.NameConflict, string.Format(message, formatArgs));
}
public static CommonResponse NotExist(params object?[] formatArgs)
{
- return new CommonResponse(ErrorCodes.TimelineCommon.NotExist, string.Format(TimelineCommon_NotExist, formatArgs));
+ return new CommonResponse(ErrorCodes.TimelineController.NotExist, string.Format(TimelineController_NotExist, formatArgs));
}
public static CommonResponse CustomMessage_NotExist(string message, params object?[] formatArgs)
{
- return new CommonResponse(ErrorCodes.TimelineCommon.NotExist, string.Format(message, formatArgs));
+ return new CommonResponse(ErrorCodes.TimelineController.NotExist, string.Format(message, formatArgs));
}
public static CommonResponse MemberPut_NotExist(params object?[] formatArgs)
{
- return new CommonResponse(ErrorCodes.TimelineCommon.MemberPut_NotExist, string.Format(TimelineCommon_MemberPut_NotExist, formatArgs));
+ return new CommonResponse(ErrorCodes.TimelineController.MemberPut_NotExist, string.Format(TimelineController_MemberPut_NotExist, formatArgs));
}
public static CommonResponse CustomMessage_MemberPut_NotExist(string message, params object?[] formatArgs)
{
- return new CommonResponse(ErrorCodes.TimelineCommon.MemberPut_NotExist, string.Format(message, formatArgs));
+ return new CommonResponse(ErrorCodes.TimelineController.MemberPut_NotExist, string.Format(message, formatArgs));
}
- }
-
- public static class TimelineController
- {
-
public static CommonResponse QueryRelateNotExist(params object?[] formatArgs)
{
return new CommonResponse(ErrorCodes.TimelineController.QueryRelateNotExist, string.Format(TimelineController_QueryRelateNotExist, formatArgs));
@@ -290,6 +285,16 @@ namespace Timeline.Models.Http return new CommonResponse(ErrorCodes.TimelineController.QueryRelateNotExist, string.Format(message, formatArgs));
}
+ public static CommonResponse PostNoData(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.TimelineController.PostNoData, string.Format(TimelineController_PostNoData, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_PostNoData(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.TimelineController.PostNoData, string.Format(message, formatArgs));
+ }
+
}
}
diff --git a/Timeline/Resources/Messages.Designer.cs b/Timeline/Resources/Messages.Designer.cs index fb093f07..cae91093 100644 --- a/Timeline/Resources/Messages.Designer.cs +++ b/Timeline/Resources/Messages.Designer.cs @@ -151,65 +151,74 @@ namespace Timeline.Resources { }
/// <summary>
- /// Looks up a localized string similar to The user to set as member does not exist..
+ /// Looks up a localized string similar to Unknown type of post content..
/// </summary>
- internal static string TimelineCommon_MemberPut_NotExist {
+ internal static string TimelineController_ContentUnknownType {
get {
- return ResourceManager.GetString("TimelineCommon_MemberPut_NotExist", resourceCulture);
+ return ResourceManager.GetString("TimelineController_ContentUnknownType", resourceCulture);
}
}
/// <summary>
- /// Looks up a localized string similar to A timeline with given name already exists..
+ /// Looks up a localized string similar to Data field is not a valid base64 string in image content..
/// </summary>
- internal static string TimelineCommon_NameConflict {
+ internal static string TimelineController_ImageContentDataNotBase64 {
get {
- return ResourceManager.GetString("TimelineCommon_NameConflict", resourceCulture);
+ return ResourceManager.GetString("TimelineController_ImageContentDataNotBase64", resourceCulture);
}
}
/// <summary>
- /// Looks up a localized string similar to The timeline with given name does not exist..
+ /// Looks up a localized string similar to Data field is not a valid image after base64 decoding in image content..
/// </summary>
- internal static string TimelineCommon_NotExist {
+ internal static string TimelineController_ImageContentDataNotImage {
get {
- return ResourceManager.GetString("TimelineCommon_NotExist", resourceCulture);
+ return ResourceManager.GetString("TimelineController_ImageContentDataNotImage", resourceCulture);
}
}
/// <summary>
- /// Looks up a localized string similar to Unknown type of post content..
+ /// Looks up a localized string similar to Data field is required for image content..
/// </summary>
- internal static string TimelineController_ContentUnknownType {
+ internal static string TimelineController_ImageContentDataRequired {
get {
- return ResourceManager.GetString("TimelineController_ContentUnknownType", resourceCulture);
+ return ResourceManager.GetString("TimelineController_ImageContentDataRequired", resourceCulture);
}
}
/// <summary>
- /// Looks up a localized string similar to Data field is not a valid base64 string in image content..
+ /// Looks up a localized string similar to The user to set as member does not exist..
/// </summary>
- internal static string TimelineController_ImageContentDataNotBase64 {
+ internal static string TimelineController_MemberPut_NotExist {
get {
- return ResourceManager.GetString("TimelineController_ImageContentDataNotBase64", resourceCulture);
+ return ResourceManager.GetString("TimelineController_MemberPut_NotExist", resourceCulture);
}
}
/// <summary>
- /// Looks up a localized string similar to Data field is not a valid image after base64 decoding in image content..
+ /// Looks up a localized string similar to A timeline with given name already exists..
/// </summary>
- internal static string TimelineController_ImageContentDataNotImage {
+ internal static string TimelineController_NameConflict {
get {
- return ResourceManager.GetString("TimelineController_ImageContentDataNotImage", resourceCulture);
+ return ResourceManager.GetString("TimelineController_NameConflict", resourceCulture);
}
}
/// <summary>
- /// Looks up a localized string similar to Data field is required for image content..
+ /// Looks up a localized string similar to The timeline with given name does not exist..
/// </summary>
- internal static string TimelineController_ImageContentDataRequired {
+ internal static string TimelineController_NotExist {
get {
- return ResourceManager.GetString("TimelineController_ImageContentDataRequired", resourceCulture);
+ return ResourceManager.GetString("TimelineController_NotExist", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to The post of that type has no data..
+ /// </summary>
+ internal static string TimelineController_PostNoData {
+ get {
+ return ResourceManager.GetString("TimelineController_PostNoData", resourceCulture);
}
}
diff --git a/Timeline/Resources/Messages.resx b/Timeline/Resources/Messages.resx index 6a4cb1b6..631bd749 100644 --- a/Timeline/Resources/Messages.resx +++ b/Timeline/Resources/Messages.resx @@ -147,15 +147,6 @@ <data name="Common_InvalidModel" xml:space="preserve">
<value>Model is of bad format.</value>
</data>
- <data name="TimelineCommon_MemberPut_NotExist" xml:space="preserve">
- <value>The user to set as member does not exist.</value>
- </data>
- <data name="TimelineCommon_NameConflict" xml:space="preserve">
- <value>A timeline with given name already exists.</value>
- </data>
- <data name="TimelineCommon_NotExist" xml:space="preserve">
- <value>The timeline with given name does not exist.</value>
- </data>
<data name="TimelineController_ContentUnknownType" xml:space="preserve">
<value>Unknown type of post content.</value>
</data>
@@ -168,6 +159,18 @@ <data name="TimelineController_ImageContentDataRequired" xml:space="preserve">
<value>Data field is required for image content.</value>
</data>
+ <data name="TimelineController_MemberPut_NotExist" xml:space="preserve">
+ <value>The user to set as member does not exist.</value>
+ </data>
+ <data name="TimelineController_NameConflict" xml:space="preserve">
+ <value>A timeline with given name already exists.</value>
+ </data>
+ <data name="TimelineController_NotExist" xml:space="preserve">
+ <value>The timeline with given name does not exist.</value>
+ </data>
+ <data name="TimelineController_PostNoData" xml:space="preserve">
+ <value>The post of that type has no data.</value>
+ </data>
<data name="TimelineController_QueryRelateNotExist" xml:space="preserve">
<value>The user specified by query param "relate" does not exist.</value>
</data>
diff --git a/Timeline/Services/TimelineService.cs b/Timeline/Services/TimelineService.cs index 97280728..301a1d97 100644 --- a/Timeline/Services/TimelineService.cs +++ b/Timeline/Services/TimelineService.cs @@ -287,11 +287,11 @@ namespace Timeline.Services }
- public abstract class BaseTimelineManager : IBaseTimelineService
+ public abstract class BaseTimelineService : IBaseTimelineService
{
- protected BaseTimelineManager(ILoggerFactory loggerFactory, DatabaseContext database, IImageValidator imageValidator, IDataManager dataManager, IUserService userService, IClock clock)
+ protected BaseTimelineService(ILoggerFactory loggerFactory, DatabaseContext database, IImageValidator imageValidator, IDataManager dataManager, IUserService userService, IClock clock)
{
- _logger = loggerFactory.CreateLogger<BaseTimelineManager>();
+ _logger = loggerFactory.CreateLogger<BaseTimelineService>();
Clock = clock;
Database = database;
ImageValidator = imageValidator;
@@ -299,7 +299,7 @@ namespace Timeline.Services UserService = userService;
}
- private ILogger<BaseTimelineManager> _logger;
+ private ILogger<BaseTimelineService> _logger;
protected IClock Clock { get; }
@@ -546,7 +546,7 @@ namespace Timeline.Services var post = await Database.TimelinePosts.Where(p => p.TimelineId == timelineId && p.LocalId == id).SingleOrDefaultAsync();
- if (post == null)
+ if (post == null || post.Content == null)
throw new TimelinePostNotExistException(name, id);
string? dataTag = null;
@@ -739,7 +739,7 @@ namespace Timeline.Services }
}
- public class OrdinaryTimelineService : BaseTimelineManager, IOrdinaryTimelineService
+ public class OrdinaryTimelineService : BaseTimelineService, IOrdinaryTimelineService
{
private readonly TimelineNameValidator _timelineNameValidator = new TimelineNameValidator();
@@ -782,7 +782,7 @@ namespace Timeline.Services }
}
- public class PersonalTimelineService : BaseTimelineManager, IPersonalTimelineService
+ public class PersonalTimelineService : BaseTimelineService, IPersonalTimelineService
{
public PersonalTimelineService(ILoggerFactory loggerFactory, DatabaseContext database, IImageValidator imageValidator, IDataManager dataManager, IUserService userService, IClock clock)
: base(loggerFactory, database, imageValidator, dataManager, userService, clock)
|