using DysonNetwork.Shared.Models; using MagicOnion; using System.Collections.Generic; using System.Threading.Tasks; using System; namespace DysonNetwork.Shared.Services; public interface IAccountService : IService { /// /// Removes all cached data for the specified account /// Task PurgeAccountCache(Account account); /// /// Looks up an account by username or contact information /// /// Username or contact information to search for /// The matching account if found, otherwise null Task LookupAccount(string probe); /// /// Looks up an account by external authentication provider connection /// /// The provider's unique identifier for the user /// The name of the authentication provider /// The matching account if found, otherwise null Task LookupAccountByConnection(string identifier, string provider); /// /// Gets the account level for the specified account ID /// /// The ID of the account /// The account level if found, otherwise null Task GetAccountLevel(Guid accountId); /// /// Creates a new account with the specified details /// /// The account username /// The display name/nickname /// The primary email address /// The account password (optional, can be set later) /// The preferred language (defaults to en-US) /// Whether the email is verified (defaults to false) /// Whether the account is activated (defaults to false) /// The newly created account Task CreateAccount( string name, string nick, string email, string? password, string language = "en-US", bool isEmailVerified = false, bool isActivated = false ); /// /// Creates a new account using OpenID Connect user information /// /// The OpenID Connect user information /// The newly created account Task CreateAccount(OidcUserInfo userInfo); /// /// Gets an account by its ID. /// /// The ID of the account. /// Join the profile table or not. /// The account if found, otherwise null. Task GetAccountById(Guid accountId, bool withProfile = false); /// /// Gets an account profile by account ID. /// /// The ID of the account. /// The account profile if found, otherwise null. Task GetAccountProfile(Guid accountId); /// /// Gets an authentication challenge by its ID. /// /// The ID of the challenge. /// The authentication challenge if found, otherwise null. Task GetAuthChallenge(Guid challengeId); /// /// Gets an authentication challenge by account ID, IP address, and user agent. /// /// The ID of the account. /// The IP address. /// The user agent. /// The current instant. /// The authentication challenge if found, otherwise null. Task GetAuthChallenge(Guid accountId, string? ipAddress, string? userAgent, NodaTime.Instant now); /// /// Creates a new authentication challenge. /// /// The challenge to create. /// The created challenge. Task CreateAuthChallenge(Challenge challenge); /// /// Gets an account authentication factor by its ID and account ID. /// /// The ID of the factor. /// The ID of the account. /// The account authentication factor if found, otherwise null. Task GetAccountAuthFactor(Guid factorId, Guid accountId); /// /// Gets a list of account authentication factors for a given account ID. /// /// The ID of the account. /// A list of account authentication factors. Task> GetAccountAuthFactors(Guid accountId); /// /// Gets an authentication session by its ID. /// /// The ID of the session. /// The authentication session if found, otherwise null. Task GetAuthSession(Guid sessionId); /// /// Gets a magic spell by its ID. /// /// The ID of the magic spell. /// The magic spell if found, otherwise null. Task GetMagicSpell(Guid spellId); /// /// Gets an abuse report by its ID. /// /// The ID of the abuse report. /// The abuse report if found, otherwise null. Task GetAbuseReport(Guid reportId); /// /// Creates a new abuse report. /// /// The identifier of the resource being reported. /// The type of abuse report. /// The reason for the report. /// The ID of the account making the report. /// The created abuse report. Task CreateAbuseReport(string resourceIdentifier, AbuseReportType type, string reason, Guid accountId); /// /// Counts abuse reports. /// /// Whether to include resolved reports. /// The count of abuse reports. Task CountAbuseReports(bool includeResolved = false); /// /// Counts abuse reports by a specific user. /// /// The ID of the account. /// Whether to include resolved reports. /// The count of abuse reports by the user. Task CountUserAbuseReports(Guid accountId, bool includeResolved = false); /// /// Gets a list of abuse reports. /// /// Number of reports to skip. /// Number of reports to take. /// Whether to include resolved reports. /// A list of abuse reports. Task> GetAbuseReports(int skip = 0, int take = 20, bool includeResolved = false); /// /// Gets a list of abuse reports by a specific user. /// /// The ID of the account. /// Number of reports to skip. /// Number of reports to take. /// Whether to include resolved reports. /// A list of abuse reports by the user. Task> GetUserAbuseReports(Guid accountId, int skip = 0, int take = 20, bool includeResolved = false); /// /// Resolves an abuse report. /// /// The ID of the report to resolve. /// The resolution message. /// The resolved abuse report. Task ResolveAbuseReport(Guid id, string resolution); /// /// Gets the count of pending abuse reports. /// /// The count of pending abuse reports. Task GetPendingAbuseReportsCount(); /// /// Checks if a relationship with a specific status exists between two accounts. /// /// The ID of the first account. /// The ID of the second account. /// The relationship status to check for. /// True if the relationship exists, otherwise false. Task HasRelationshipWithStatus(Guid accountId1, Guid accountId2, RelationshipStatus status); /// /// Gets the statuses for a list of account IDs. /// /// A list of account IDs. /// A dictionary where the key is the account ID and the value is the status. Task> GetStatuses(List accountIds); /// /// Sends a notification to an account. /// /// The target account. /// The notification topic. /// The notification title. /// The notification subtitle. /// The notification body. /// The action URI for the notification. /// A task representing the asynchronous operation. Task SendNotification(Account account, string topic, string title, string? subtitle, string body, string? actionUri = null); /// /// Lists the friends of an account. /// /// The account. /// A list of friend accounts. Task> ListAccountFriends(Account account); /// /// Verifies an authentication factor code. /// /// The authentication factor. /// The code to verify. /// True if the code is valid, otherwise false. Task VerifyFactorCode(AccountAuthFactor factor, string code); /// /// Send the auth factor verification code to users, for factors like in-app code and email. /// Sometimes it requires a hint, like a part of the user's email address to ensure the user is who own the account. /// /// The owner of the auth factor /// The auth factor needed to send code /// The part of the contact method for verification Task SendFactorCode(Account account, AccountAuthFactor factor, string? hint = null); /// /// Creates an action log entry. /// /// The type of action log. /// Additional metadata for the action log. /// The HTTP request. /// The account associated with the action. /// The created action log. Task CreateActionLogFromRequest(string type, Dictionary meta, string? ipAddress, string? userAgent, Account? account = null); /// /// Creates a new session. /// /// The last granted instant. /// The expiration instant. /// The associated account. /// The associated challenge. /// The created session. Task CreateSession(NodaTime.Instant lastGrantedAt, NodaTime.Instant expiredAt, Account account, Challenge challenge); /// /// Updates the LastGrantedAt for a session. /// /// The ID of the session. /// The new LastGrantedAt instant. Task UpdateSessionLastGrantedAt(Guid sessionId, NodaTime.Instant lastGrantedAt); /// /// Updates the LastSeenAt for an account profile. /// /// The ID of the account. /// The new LastSeenAt instant. Task UpdateAccountProfileLastSeenAt(Guid accountId, NodaTime.Instant lastSeenAt); /// /// Creates a token for a session. /// /// The session. /// The token string. string CreateToken(Session session); /// /// Gets the AuthConstants.CookieTokenName. /// /// The cookie token name. string GetAuthCookieTokenName(); /// /// Searches for accounts by a search term. /// /// The term to search for. /// A list of matching accounts. Task> SearchAccountsAsync(string searchTerm); }