diff options
author | crupest <crupest@outlook.com> | 2020-03-16 19:07:13 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-03-16 19:07:13 +0800 |
commit | 7e393559d2883a37b1be0c82cccc06bc97c3d102 (patch) | |
tree | 07d96d3ab8ca909019cbb1225d533fe4aa2a57ac /Timeline/Services/TimelineService.cs | |
parent | b20c488a9b02807cfa117b10dd8906271af03614 (diff) | |
download | timeline-7e393559d2883a37b1be0c82cccc06bc97c3d102.tar.gz timeline-7e393559d2883a37b1be0c82cccc06bc97c3d102.tar.bz2 timeline-7e393559d2883a37b1be0c82cccc06bc97c3d102.zip |
Hotfix a bug in post data.
Diffstat (limited to 'Timeline/Services/TimelineService.cs')
-rw-r--r-- | Timeline/Services/TimelineService.cs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Timeline/Services/TimelineService.cs b/Timeline/Services/TimelineService.cs index b26016e5..aecfeeec 100644 --- a/Timeline/Services/TimelineService.cs +++ b/Timeline/Services/TimelineService.cs @@ -102,7 +102,7 @@ namespace Timeline.Services /// <exception cref="ArgumentException">See remarks of <see cref="IBaseTimelineService"/>.</exception>
/// <exception cref="TimelineNotExistException">See remarks of <see cref="IBaseTimelineService"/>.</exception>
/// <exception cref="TimelinePostNotExistException">Thrown when post of <paramref name="postId"/> does not exist or has been deleted.</exception>
- /// <exception cref="InvalidOperationException">Thrown when post has no data. See remarks.</exception>
+ /// <exception cref="BadPostTypeException">Thrown when post has no data. See remarks.</exception>
/// <seealso cref="GetPostData(string, long)"/>
Task<string> GetPostDataETag(string name, long postId);
@@ -116,7 +116,7 @@ namespace Timeline.Services /// <exception cref="ArgumentException">See remarks of <see cref="IBaseTimelineService"/>.</exception>
/// <exception cref="TimelineNotExistException">See remarks of <see cref="IBaseTimelineService"/>.</exception>
/// <exception cref="TimelinePostNotExistException">Thrown when post of <paramref name="postId"/> does not exist or has been deleted.</exception>
- /// <exception cref="InvalidOperationException">Thrown when post has no data. See remarks.</exception>
+ /// <exception cref="BadPostTypeException">Thrown when post has no data. See remarks.</exception>
/// <remarks>
/// Use this method to retrieve the image of image post.
/// </remarks>
@@ -425,7 +425,7 @@ namespace Timeline.Services throw new ArgumentNullException(nameof(name));
var timelineId = await FindTimelineId(name);
- var postEntity = await Database.TimelinePosts.Where(p => p.LocalId == postId).SingleOrDefaultAsync();
+ var postEntity = await Database.TimelinePosts.Where(p => p.TimelineId == timelineId && p.LocalId == postId).SingleOrDefaultAsync();
if (postEntity == null)
throw new TimelinePostNotExistException(name, postId);
@@ -434,7 +434,7 @@ namespace Timeline.Services throw new TimelinePostNotExistException(name, postId, true);
if (postEntity.ContentType != TimelinePostContentTypes.Image)
- throw new InvalidOperationException(ExceptionGetDataNonImagePost);
+ throw new BadPostTypeException(postEntity.ContentType, TimelinePostContentTypes.Image, ExceptionGetDataNonImagePost);
var tag = postEntity.Content;
@@ -447,7 +447,7 @@ namespace Timeline.Services throw new ArgumentNullException(nameof(name));
var timelineId = await FindTimelineId(name);
- var postEntity = await Database.TimelinePosts.Where(p => p.LocalId == postId).SingleOrDefaultAsync();
+ var postEntity = await Database.TimelinePosts.Where(p => p.TimelineId == timelineId && p.LocalId == postId).SingleOrDefaultAsync();
if (postEntity == null)
throw new TimelinePostNotExistException(name, postId);
@@ -456,7 +456,7 @@ namespace Timeline.Services throw new TimelinePostNotExistException(name, postId, true);
if (postEntity.ContentType != TimelinePostContentTypes.Image)
- throw new InvalidOperationException(ExceptionGetDataNonImagePost);
+ throw new BadPostTypeException(postEntity.ContentType, TimelinePostContentTypes.Image, ExceptionGetDataNonImagePost);
var tag = postEntity.Content;
|