aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-04-18 22:34:06 +0800
committercrupest <crupest@outlook.com>2021-04-18 22:34:06 +0800
commit909bfdd6a48d57fc713fca6612dfd994e7721533 (patch)
tree6f9400ef65352146d9c2d61e755ea191defcb7f1
parentd69046007df244ea380ed29e7ca25a87ba9c03d7 (diff)
downloadtimeline-909bfdd6a48d57fc713fca6612dfd994e7721533.tar.gz
timeline-909bfdd6a48d57fc713fca6612dfd994e7721533.tar.bz2
timeline-909bfdd6a48d57fc713fca6612dfd994e7721533.zip
fix: Fix a bug in HasPostModifyPermission.
-rw-r--r--BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs17
-rw-r--r--BackEnd/Timeline/Services/TimelinePostService.cs2
2 files changed, 18 insertions, 1 deletions
diff --git a/BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs b/BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs
index f00d9b13..68a75898 100644
--- a/BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs
+++ b/BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs
@@ -618,5 +618,22 @@ namespace Timeline.Tests.IntegratedTests
markdown.Should().MatchRegex(@$"\[aaa\]\(https?://.*/timelines/{generator(1)}/posts/{post.Id}/data/1\)");
markdown.Should().MatchRegex(@$"\[bbb\]\(https?://.*/timelines/{generator(1)}/posts/{post.Id}/data/2\)");
}
+
+ [Theory]
+ [MemberData(nameof(TimelineNameGeneratorTestData))]
+ public async Task Post_Markdown_Delete_Test(TimelineNameGenerator generator)
+ {
+ {
+ using var client = await CreateClientAs(2);
+ var post = await client.TestPostAsync<HttpTimelinePost>($"timelines/{generator(2)}/posts", CreateMarkdownPostRequest("[aaa](https://crupest.life)"));
+ await client.TestDeleteAsync($"timelines/{generator(2)}/posts/{post.Id}");
+ }
+
+ {
+ using var client = await CreateClientAsUser();
+ var post = await client.TestPostAsync<HttpTimelinePost>($"timelines/{generator(1)}/posts", CreateMarkdownPostRequest("[aaa](https://crupest.life)"));
+ await client.TestDeleteAsync($"timelines/{generator(1)}/posts/{post.Id}");
+ }
+ }
}
}
diff --git a/BackEnd/Timeline/Services/TimelinePostService.cs b/BackEnd/Timeline/Services/TimelinePostService.cs
index 88a93710..f64c4c22 100644
--- a/BackEnd/Timeline/Services/TimelinePostService.cs
+++ b/BackEnd/Timeline/Services/TimelinePostService.cs
@@ -462,7 +462,7 @@ namespace Timeline.Services
var timelineEntity = await _database.Timelines.Where(t => t.Id == timelineId).Select(t => new { t.OwnerId }).SingleAsync();
- var postEntity = await _database.TimelinePosts.Where(p => p.Id == postId).Select(p => new { p.Deleted, p.AuthorId }).SingleOrDefaultAsync();
+ var postEntity = await _database.TimelinePosts.Where(p => p.TimelineId == timelineId && p.LocalId == postId).Select(p => new { p.Deleted, p.AuthorId }).SingleOrDefaultAsync();
if (postEntity is null)
{