From 968140e8aaba398e10585e978aff33d7b32e824a Mon Sep 17 00:00:00 2001 From: crupest Date: Fri, 6 Mar 2020 22:28:32 +0800 Subject: Init development of post image feature. --- Timeline/Services/TimelineService.cs | 39 +++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'Timeline/Services/TimelineService.cs') diff --git a/Timeline/Services/TimelineService.cs b/Timeline/Services/TimelineService.cs index 379ec8f5..d999587a 100644 --- a/Timeline/Services/TimelineService.cs +++ b/Timeline/Services/TimelineService.cs @@ -90,14 +90,14 @@ namespace Timeline.Services Task> GetPosts(string name); /// - /// Create a new post in timeline. + /// Create a new text post in timeline. /// /// Username or the timeline name. See remarks of . /// The author's id. - /// The content. + /// The content text. /// The time of the post. If null, then use current time. /// The info of the created post. - /// Thrown when or is null. + /// Thrown when or is null. /// Thrown when is illegal. It is not a valid timeline name (for normal timeline service) or a valid username (for personal timeline service). /// /// Thrown when timeline does not exist. @@ -106,7 +106,27 @@ namespace Timeline.Services /// and the inner exception should be a . /// /// Thrown if user with does not exist. - Task CreatePost(string name, long authorId, string content, DateTime? time); + Task CreateTextPost(string name, long authorId, string text, DateTime? time); + + /// + /// Create a new image post in timeline. + /// + /// Username or the timeline name. See remarks of . + /// The author's id. + /// The image data. + /// The time of the post. If null, then use current time. + /// The info of the created post. + /// Thrown when or is null. + /// Thrown when is illegal. It is not a valid timeline name (for normal timeline service) or a valid username (for personal timeline service). + /// + /// Thrown when timeline does not exist. + /// For normal timeline, it means the name does not exist. + /// For personal timeline, it means the user of that username does not exist + /// and the inner exception should be a . + /// + /// Thrown if user with does not exist. + /// Thrown if data is not a image. Validated by . + Task CreateImagePost(string name, long authorId, byte[] data, DateTime? time); /// /// Delete a post @@ -398,12 +418,12 @@ namespace Timeline.Services return posts; } - public async Task CreatePost(string name, long authorId, string content, DateTime? time) + public async Task CreateTextPost(string name, long authorId, string text, DateTime? time) { if (name == null) throw new ArgumentNullException(nameof(name)); - if (content == null) - throw new ArgumentNullException(nameof(content)); + if (text == null) + throw new ArgumentNullException(nameof(text)); var timelineId = await FindTimelineId(name); var timelineEntity = await Database.Timelines.Where(t => t.Id == timelineId).SingleAsync(); @@ -418,7 +438,8 @@ namespace Timeline.Services var postEntity = new TimelinePostEntity { LocalId = timelineEntity.CurrentPostLocalId, - Content = content, + ContentType = TimelinePostContentTypes.Text, + Content = text, AuthorId = authorId, TimelineId = timelineId, Time = finalTime, @@ -430,7 +451,7 @@ namespace Timeline.Services return new TimelinePostInfo { Id = postEntity.LocalId, - Content = content, + Content = text, Author = author, Time = finalTime, LastUpdated = currentTime -- cgit v1.2.3