Fix webhook avatar, simplify message title

This commit is contained in:
Nassim Jahnke 2024-07-08 16:54:16 +02:00
parent cf4b92d273
commit 1a78c0b7c2
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
4 changed files with 7 additions and 6 deletions

View File

@ -1,13 +1,14 @@
package io.papermc.hangar.components.webhook.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRawValue;
import java.util.List;
public record DiscordWebhook(
String username,
String avatarUrl,
@JsonProperty("avatar_url") String avatarUrl,
@JsonRawValue String embeds,
AllowedMentions allowedMentions
@JsonProperty("allowed_mentions") AllowedMentions allowedMentions
) {
public DiscordWebhook(final String embeds) {

View File

@ -31,7 +31,7 @@ public class WebhookService {
[
{
"id": {{id}},
"title": "{{author}} / {{name}} is now available on Hangar!",
"title": "{{author}}/{{name}}",
"description": "{{description}}",
"color": 2326507,
"fields": [],
@ -50,7 +50,7 @@ public class WebhookService {
[
{
"id": {{id}},
"title": "Version {{version}} for {{author}} / {{name}} has been released!",
"title": "Version {{version}} - {{author}}/{{name}}",
"description": "{{description}}",
"color": 2326507,
"fields": [],

View File

@ -61,7 +61,7 @@ public class JobService extends HangarComponent {
@Transactional
public void schedule(final Job... jobs) {
for (final Job job : jobs) {
logger.info("Scheduling job: {}", job);
this.logger.info("Scheduling job: {}", job);
this.jobsDAO.save(job.toTable());
}
}

View File

@ -472,7 +472,7 @@ public class VersionFactory extends HangarComponent {
final Platform platform = entry.getKey();
final Set<String> versionsForPlatform = new HashSet<>(this.platformService.getFullVersionsForPlatform(platform));
if (!versionsForPlatform.containsAll(entry.getValue())) {
throw new HangarApiException(HttpStatus.BAD_REQUEST, "version.new.error.invalidPlatformVersion", entry.getValue());
throw new HangarApiException(HttpStatus.BAD_REQUEST, "version.new.error.invalidPlatformVersionList", entry.getValue());
}
}
}