From 9df5a86786ac2dcb8bc0f34f69501abfffd0dc9c Mon Sep 17 00:00:00 2001 From: 杨宇千 Date: Mon, 4 Nov 2019 22:58:24 +0800 Subject: Add controller primarily and of course redesign the service accordingly. --- Timeline/Services/TimelineService.cs | 64 ++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 18 deletions(-) (limited to 'Timeline/Services/TimelineService.cs') diff --git a/Timeline/Services/TimelineService.cs b/Timeline/Services/TimelineService.cs index 9d309e7e..7fe32cac 100644 --- a/Timeline/Services/TimelineService.cs +++ b/Timeline/Services/TimelineService.cs @@ -61,7 +61,7 @@ namespace Timeline.Services /// /// Thrown if is of bad format. /// Thrown if does not exist. - Task Post(string name, string author, string content, DateTime? time); + Task CreatePost(string name, string author, string content, DateTime? time); /// /// Set the visibility permission of a timeline. @@ -104,11 +104,12 @@ namespace Timeline.Services Task SetDescription(string name, string description); /// - /// Add members to a timeline. + /// Remove members to a timeline. /// /// Username or the timeline name. See remarks of . - /// A list of new members' usernames - /// Thrown when or is null. + /// A list of usernames of members to add. May be null. + /// A list of usernames of members to remove. May be null. + /// Thrown when is null. /// /// Thrown when timeline name is of bad format. /// For normal timeline, it means name is an empty string. @@ -122,19 +123,26 @@ namespace Timeline.Services /// and the inner exception should be a . /// /// - /// Thrown when an exception occurs on users in the list. + /// Thrown when an exception occurs on the user list. /// The inner exception is - /// when one of the username is not valid. + /// when one of the username is invalid. /// The inner exception is - /// when one of the user does not exist. - /// - Task AddMember(string name, IList usernames); + /// when one of the user to add does not exist. + /// + /// + /// Operating on a username that is of bad format always throws. + /// Add a user that already is a member has no effects. + /// Remove a user that is not a member also has not effects. + /// Add a user that does not exist will throw . + /// But remove one does not throw. + /// + Task ChangeMember(string name, IList? add, IList? remove); /// - /// Remove members to a timeline. + /// Verify whether a visitor has the permission to read a timeline. /// /// Username or the timeline name. See remarks of . - /// A list of members' usernames + /// The user to check on. Null means visitor without account. /// Thrown when is null. /// /// Thrown when timeline name is of bad format. @@ -148,14 +156,34 @@ namespace Timeline.Services /// For personal timeline, it means the user of that username does not exist /// and the inner exception should be a . /// - /// - /// Thrown when an exception occurs on the user list. - /// The inner exception is - /// when one of the username is invalid. - /// The inner exception is - /// when one of the user is not a member of the timeline. + /// True if can read, false if can't read. + Task HasReadPermission(string name, string? username); + + /// + /// Verify whether a user is member of a timeline. + /// + /// Username or the timeline name. See remarks of . + /// The user to check on. + /// Thrown when or is null. + /// + /// Thrown when timeline name is of bad format. + /// For normal timeline, it means name is an empty string. + /// For personal timeline, it means the username is of bad format, + /// the inner exception should be a . + /// + /// + /// 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 . /// - Task RemoveMember(string name, IList usernames); + /// + /// Thrown when is not a valid username. + /// + /// + /// Thrown when user does not exist. + /// True if it is a member, false if not. + Task IsMemberOf(string name, string username); } /// -- cgit v1.2.3