feat(guild): /guild/create + populated /guild/info
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -27,4 +27,10 @@ public interface IViewerRepository
|
||||
/// doesn't exist.
|
||||
/// </summary>
|
||||
Task<Models.Viewer?> LoadForMatchContextAsync(long viewerId);
|
||||
|
||||
/// <summary>Sets Viewer.GuildId to <paramref name="guildId"/>. No-op if the viewer does not exist.</summary>
|
||||
Task SetGuildIdAsync(long viewerId, int guildId, CancellationToken ct = default);
|
||||
|
||||
/// <summary>Clears Viewer.GuildId to null. No-op if the viewer does not exist.</summary>
|
||||
Task ClearGuildIdAsync(long viewerId, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
@@ -268,6 +268,24 @@ public class ViewerRepository : IViewerRepository
|
||||
.FirstOrDefaultAsync(v => v.Id == viewerId);
|
||||
}
|
||||
|
||||
public async Task SetGuildIdAsync(long viewerId, int guildId, CancellationToken ct = default)
|
||||
{
|
||||
var viewer = await _dbContext.Set<Models.Viewer>()
|
||||
.FirstOrDefaultAsync(v => v.Id == viewerId, ct);
|
||||
if (viewer is null) return;
|
||||
viewer.GuildId = guildId;
|
||||
await _dbContext.SaveChangesAsync(ct);
|
||||
}
|
||||
|
||||
public async Task ClearGuildIdAsync(long viewerId, CancellationToken ct = default)
|
||||
{
|
||||
var viewer = await _dbContext.Set<Models.Viewer>()
|
||||
.FirstOrDefaultAsync(v => v.Id == viewerId, ct);
|
||||
if (viewer is null) return;
|
||||
viewer.GuildId = null;
|
||||
await _dbContext.SaveChangesAsync(ct);
|
||||
}
|
||||
|
||||
private async Task<Models.Viewer> BuildDefaultViewer(string displayName, int initialTutorialState = 1)
|
||||
{
|
||||
Models.Viewer viewer = new Models.Viewer
|
||||
|
||||
Reference in New Issue
Block a user