♻️ Moving to MagicOnion
This commit is contained in:
28
DysonNetwork.Shared/Services/IAccountEventService.cs
Normal file
28
DysonNetwork.Shared/Services/IAccountEventService.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using DysonNetwork.Shared.Models;
|
||||
using MagicOnion;
|
||||
using NodaTime;
|
||||
|
||||
namespace DysonNetwork.Shared.Services;
|
||||
|
||||
public interface IAccountEventService : IService<IAccountEventService>
|
||||
{
|
||||
/// <summary>
|
||||
/// Purges the status cache for a user
|
||||
/// </summary>
|
||||
void PurgeStatusCache(Guid userId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the status of a user
|
||||
/// </summary>
|
||||
Task<Status> GetStatus(Guid userId);
|
||||
|
||||
/// <summary>
|
||||
/// Performs a daily check-in for a user
|
||||
/// </summary>
|
||||
Task<CheckInResult> CheckInDaily(Account user);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the check-in streak for a user
|
||||
/// </summary>
|
||||
Task<int> GetCheckInStreak(Account user);
|
||||
}
|
62
DysonNetwork.Shared/Services/IAccountService.cs
Normal file
62
DysonNetwork.Shared/Services/IAccountService.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using DysonNetwork.Shared.Models;
|
||||
using MagicOnion;
|
||||
|
||||
namespace DysonNetwork.Shared.Services;
|
||||
|
||||
public interface IAccountService : IService<IAccountService>
|
||||
{
|
||||
/// <summary>
|
||||
/// Removes all cached data for the specified account
|
||||
/// </summary>
|
||||
Task PurgeAccountCache(Account account);
|
||||
|
||||
/// <summary>
|
||||
/// Looks up an account by username or contact information
|
||||
/// </summary>
|
||||
/// <param name="probe">Username or contact information to search for</param>
|
||||
/// <returns>The matching account if found, otherwise null</returns>
|
||||
Task<Account?> LookupAccount(string probe);
|
||||
|
||||
/// <summary>
|
||||
/// Looks up an account by external authentication provider connection
|
||||
/// </summary>
|
||||
/// <param name="identifier">The provider's unique identifier for the user</param>
|
||||
/// <param name="provider">The name of the authentication provider</param>
|
||||
/// <returns>The matching account if found, otherwise null</returns>
|
||||
Task<Account?> LookupAccountByConnection(string identifier, string provider);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the account level for the specified account ID
|
||||
/// </summary>
|
||||
/// <param name="accountId">The ID of the account</param>
|
||||
/// <returns>The account level if found, otherwise null</returns>
|
||||
Task<int?> GetAccountLevel(Guid accountId);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new account with the specified details
|
||||
/// </summary>
|
||||
/// <param name="name">The account username</param>
|
||||
/// <param name="nick">The display name/nickname</param>
|
||||
/// <param name="email">The primary email address</param>
|
||||
/// <param name="password">The account password (optional, can be set later)</param>
|
||||
/// <param name="language">The preferred language (defaults to en-US)</param>
|
||||
/// <param name="isEmailVerified">Whether the email is verified (defaults to false)</param>
|
||||
/// <param name="isActivated">Whether the account is activated (defaults to false)</param>
|
||||
/// <returns>The newly created account</returns>
|
||||
Task<Account> CreateAccount(
|
||||
string name,
|
||||
string nick,
|
||||
string email,
|
||||
string? password,
|
||||
string language = "en-US",
|
||||
bool isEmailVerified = false,
|
||||
bool isActivated = false
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new account using OpenID Connect user information
|
||||
/// </summary>
|
||||
/// <param name="userInfo">The OpenID Connect user information</param>
|
||||
/// <returns>The newly created account</returns>
|
||||
Task<Account> CreateAccount(OidcUserInfo userInfo);
|
||||
}
|
23
DysonNetwork.Shared/Services/IAccountUsernameService.cs
Normal file
23
DysonNetwork.Shared/Services/IAccountUsernameService.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using MagicOnion;
|
||||
|
||||
namespace DysonNetwork.Shared.Services;
|
||||
|
||||
public interface IAccountUsernameService : IService<IAccountUsernameService>
|
||||
{
|
||||
/// <summary>
|
||||
/// Generates a unique username based on the provided base name
|
||||
/// </summary>
|
||||
/// <param name="baseName">The preferred username</param>
|
||||
/// <returns>A unique username</returns>
|
||||
Task<string> GenerateUniqueUsernameAsync(string baseName);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a username already exists
|
||||
/// </summary>
|
||||
Task<bool> IsUsernameExistsAsync(string username);
|
||||
|
||||
/// <summary>
|
||||
/// Sanitizes a username to remove invalid characters
|
||||
/// </summary>
|
||||
string SanitizeUsername(string username);
|
||||
}
|
24
DysonNetwork.Shared/Services/IActionLogService.cs
Normal file
24
DysonNetwork.Shared/Services/IActionLogService.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using DysonNetwork.Shared.Models;
|
||||
using MagicOnion;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace DysonNetwork.Shared.Services;
|
||||
|
||||
public interface IActionLogService : IService<IActionLogService>
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates an action log entry
|
||||
/// </summary>
|
||||
void CreateActionLog(Guid accountId, string action, Dictionary<string, object> meta);
|
||||
|
||||
/// <summary>
|
||||
/// Creates an action log entry from an HTTP request
|
||||
/// </summary>
|
||||
void CreateActionLogFromRequest(
|
||||
string action,
|
||||
Dictionary<string, object> meta,
|
||||
HttpRequest request,
|
||||
Account? account = null
|
||||
);
|
||||
}
|
30
DysonNetwork.Shared/Services/IMagicSpellService.cs
Normal file
30
DysonNetwork.Shared/Services/IMagicSpellService.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using DysonNetwork.Shared.Models;
|
||||
using MagicOnion;
|
||||
using NodaTime;
|
||||
|
||||
namespace DysonNetwork.Shared.Services;
|
||||
|
||||
public interface IMagicSpellService : IService<IMagicSpellService>
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new magic spell
|
||||
/// </summary>
|
||||
Task<MagicSpell> CreateMagicSpell(
|
||||
Account account,
|
||||
MagicSpellType type,
|
||||
Dictionary<string, object> meta,
|
||||
Instant? expiredAt = null,
|
||||
Instant? affectedAt = null,
|
||||
bool preventRepeat = false
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a magic spell by its token
|
||||
/// </summary>
|
||||
Task<MagicSpell?> GetMagicSpellAsync(string token);
|
||||
|
||||
/// <summary>
|
||||
/// Consumes a magic spell
|
||||
/// </summary>
|
||||
Task ApplyMagicSpell(string token);
|
||||
}
|
23
DysonNetwork.Shared/Services/INotificationService.cs
Normal file
23
DysonNetwork.Shared/Services/INotificationService.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using DysonNetwork.Shared.Models;
|
||||
using MagicOnion;
|
||||
|
||||
namespace DysonNetwork.Shared.Services;
|
||||
|
||||
public interface INotificationService : IService<INotificationService>
|
||||
{
|
||||
/// <summary>
|
||||
/// Unsubscribes a device from push notifications
|
||||
/// </summary>
|
||||
/// <param name="deviceId">The device ID to unsubscribe</param>
|
||||
Task UnsubscribePushNotifications(string deviceId);
|
||||
|
||||
/// <summary>
|
||||
/// Subscribes a device to push notifications
|
||||
/// </summary>
|
||||
Task<NotificationPushSubscription> SubscribePushNotification(
|
||||
Account account,
|
||||
NotificationPushProvider provider,
|
||||
string deviceId,
|
||||
string deviceToken
|
||||
);
|
||||
}
|
27
DysonNetwork.Shared/Services/IRelationshipService.cs
Normal file
27
DysonNetwork.Shared/Services/IRelationshipService.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using DysonNetwork.Shared.Models;
|
||||
using MagicOnion;
|
||||
|
||||
namespace DysonNetwork.Shared.Services;
|
||||
|
||||
public interface IRelationshipService : IService<IRelationshipService>
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if a relationship exists between two accounts
|
||||
/// </summary>
|
||||
Task<bool> HasExistingRelationship(Guid accountId, Guid relatedId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a relationship between two accounts
|
||||
/// </summary>
|
||||
Task<Relationship?> GetRelationship(
|
||||
Guid accountId,
|
||||
Guid relatedId,
|
||||
RelationshipStatus? status = null,
|
||||
bool ignoreExpired = false
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new relationship between two accounts
|
||||
/// </summary>
|
||||
Task<Relationship> CreateRelationship(Account sender, Account target, RelationshipStatus status);
|
||||
}
|
Reference in New Issue
Block a user