Skip to content

Commit

Permalink
Send over DTO instead of config
Browse files Browse the repository at this point in the history
  • Loading branch information
FeroxFoxxo committed Mar 5, 2024
1 parent 5ed9ea4 commit 77682a5
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions backend/Levels/Controllers/LevelsConfigController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,37 @@ public async Task<IActionResult> GetConfig([FromRoute] ulong guildId)
}

var config = await _levelsConfigRepository.GetOrCreateConfig(guildId);
return Ok(config);

var dto = new GuildLevelConfigDto
{
Id = guildId,

Coefficients = config.Coefficients,
XpInterval = config.XpInterval,

MaximumTextXpGiven = config.Experience.MaximumTextXpGiven,
MaximumVoiceXpGiven = config.Experience.MaximumVoiceXpGiven,
MinimumTextXpGiven = config.Experience.MinimumTextXpGiven,
MinimumVoiceXpGiven = config.Experience.MinimumVoiceXpGiven,

VoiceXpRequiredMembers = config.VoiceXpRequiredMembers,
VoiceXpCountMutedMembers = config.VoiceXpCountMutedMembers,

HandleRoles = config.HandleRoles,
NicknameDisabledRole = config.NicknameDisabledRole,
NicknameDisabledReplacement = config.NicknameDisabledReplacement,
Levels = config.Levels,
LevelUpMessageOverrides = config.LevelUpMessageOverrides,
DisabledXpChannels = config.DisabledXpChannels,

LevelUpTemplate = config.LevelUpTemplate,
SendTextLevelUps = config.SendTextLevelUps,
SendVoiceLevelUps = config.SendVoiceLevelUps,
TextLevelUpChannel = config.TextLevelUpChannel,
VoiceLevelUpChannel = config.VoiceLevelUpChannel
};

return Ok(dto);
}

[HttpPut]
Expand Down Expand Up @@ -87,9 +117,6 @@ public async Task<IActionResult> PutConfig([FromRoute] ulong guildId, [FromBody]
existing.TextLevelUpChannel = config.TextLevelUpChannel;
existing.VoiceLevelUpChannel = config.VoiceLevelUpChannel;

existing.Levels = config.Levels;
existing.LevelUpMessageOverrides = config.LevelUpMessageOverrides;

await _levelsConfigRepository.UpdateConfig(existing);
return Ok();
}
Expand Down

0 comments on commit 77682a5

Please sign in to comment.