mirror of
https://github.com/DorkSquadRR/DorkNet.git
synced 2026-10-26 07:28:45 -07:00
feat: Add new API controllers for progression events, room consumables, currencies, earnings distributions, screen share reports, subscription seasons, and UGC purchasables
- Implemented ProgressionEventsController to handle progression event retrieval and active events. - Created RoomConsumablesController for listing and purchasing room consumables. - Developed RoomCurrenciesController for managing room currencies, including creation, updates, and balance retrieval. - Added RoomEarningsDistributionsController to fetch earnings distribution data for rooms. - Introduced ScreenShareReportsController for reporting screen share incidents. - Established SubscriptionSeasonsController to provide current subscription season details and rewards. - Launched UgcPurchasablesController for managing user-generated content purchasables, including bulk operations. - Added new data entities for customization and room economy, including custom avatar items, room currencies, and UGC purchasables.
This commit is contained in:
+102
@@ -0,0 +1,102 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using DorkNet.Server.Auth;
|
||||
using DorkNet.Server.Data;
|
||||
using DorkNet.Server.Data.Entities;
|
||||
|
||||
namespace DorkNet.Server.Controllers.API.InfluencerPartnerProgram;
|
||||
|
||||
[ApiController]
|
||||
public class InfluencerPartnerProgramController(DorkNetDbContext db) : ControllerBase
|
||||
{
|
||||
[HttpGet("api/influencerpartnerprogram/influencers")]
|
||||
[AllowAnonymous]
|
||||
public async Task<IActionResult> Influencers([FromQuery] int take = 50)
|
||||
{
|
||||
take = Math.Clamp(take, 1, 100);
|
||||
var creatorIds = await db.Rooms.Select(r => r.CreatorPlayerId)
|
||||
.Concat(db.Inventions.Where(i => !i.IsDeleted).Select(i => i.CreatorPlayerId))
|
||||
.Concat(db.CustomAvatarItems.Select(i => i.CreatorPlayerId))
|
||||
.Distinct()
|
||||
.Take(take)
|
||||
.ToListAsync();
|
||||
var players = await db.Players
|
||||
.Where(p => creatorIds.Contains(p.Id))
|
||||
.OrderBy(p => p.Username)
|
||||
.ToListAsync();
|
||||
return Ok(players.Select(ToInfluencerWire));
|
||||
}
|
||||
|
||||
[HttpGet("api/influencerpartnerprogram/influencer")]
|
||||
[AllowAnonymous]
|
||||
public async Task<IActionResult> Influencer([FromQuery] long? accountId = null, [FromQuery] string? username = null)
|
||||
{
|
||||
var player = accountId is long id
|
||||
? await db.Players.FirstOrDefaultAsync(p => p.Id == id)
|
||||
: await db.Players.FirstOrDefaultAsync(p => p.Username == username);
|
||||
if (player is null) return NotFound();
|
||||
return Ok(ToInfluencerWire(player));
|
||||
}
|
||||
|
||||
[HttpGet("api/influencerpartnerprogram/myinfluencer")]
|
||||
[Authorize]
|
||||
public async Task<IActionResult> MyInfluencer()
|
||||
{
|
||||
var me = this.RequireCurrentPlayerId();
|
||||
var setting = await db.PlayerSettings
|
||||
.FirstOrDefaultAsync(s => s.PlayerId == me && s.Key == "influencer:supported");
|
||||
if (setting is null || !long.TryParse(setting.Value, out var influencerId))
|
||||
return Ok(new { Influencer = (object?)null });
|
||||
var player = await db.Players.FirstOrDefaultAsync(p => p.Id == influencerId);
|
||||
return Ok(new { Influencer = player is null ? null : ToInfluencerWire(player) });
|
||||
}
|
||||
|
||||
[HttpPost("api/influencerpartnerprogram/support")]
|
||||
[Authorize]
|
||||
public async Task<IActionResult> Support([FromForm] long? influencerAccountId, [FromForm] string? username)
|
||||
{
|
||||
var me = this.RequireCurrentPlayerId();
|
||||
var influencer = influencerAccountId is long id
|
||||
? await db.Players.FirstOrDefaultAsync(p => p.Id == id)
|
||||
: await db.Players.FirstOrDefaultAsync(p => p.Username == username);
|
||||
if (influencer is null) return NotFound();
|
||||
|
||||
var setting = await db.PlayerSettings
|
||||
.FirstOrDefaultAsync(s => s.PlayerId == me && s.Key == "influencer:supported");
|
||||
if (setting is null)
|
||||
{
|
||||
db.PlayerSettings.Add(new PlayerSettingEntity
|
||||
{
|
||||
PlayerId = me,
|
||||
Key = "influencer:supported",
|
||||
Value = influencer.Id.ToString(),
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
setting.Value = influencer.Id.ToString();
|
||||
}
|
||||
await db.SaveChangesAsync();
|
||||
return Ok(new { Success = true, Influencer = ToInfluencerWire(influencer) });
|
||||
}
|
||||
|
||||
[HttpPost("api/influencerpartnerprogram/remove")]
|
||||
[Authorize]
|
||||
public async Task<IActionResult> Remove()
|
||||
{
|
||||
var me = this.RequireCurrentPlayerId();
|
||||
await db.PlayerSettings
|
||||
.Where(s => s.PlayerId == me && s.Key == "influencer:supported")
|
||||
.ExecuteDeleteAsync();
|
||||
return Ok(new { Success = true });
|
||||
}
|
||||
|
||||
private static object ToInfluencerWire(PlayerEntity player) => new
|
||||
{
|
||||
AccountId = (int)player.Id,
|
||||
player.Username,
|
||||
DisplayName = player.DisplayName,
|
||||
ProfileImage = player.ProfileImageName ?? string.Empty,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user