mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 05:38:04 +01:00
Add category to badges
This commit is contained in:
@@ -90,11 +90,15 @@ public class ConfiguredProfileBadgeConverter implements ProfileBadgeConverter {
|
||||
.filter(accountBadge -> accountBadge.isVisible()
|
||||
&& now.isBefore(accountBadge.getExpiration())
|
||||
&& knownBadges.containsKey(accountBadge.getId()))
|
||||
.map(accountBadge -> new Badge(
|
||||
accountBadge.getId(),
|
||||
knownBadges.get(accountBadge.getId()).getImageUrl(),
|
||||
resourceBundle.getString(accountBadge.getId() + "_name"),
|
||||
resourceBundle.getString(accountBadge.getId() + "_description")))
|
||||
.map(accountBadge -> {
|
||||
BadgeConfiguration configuration = knownBadges.get(accountBadge.getId());
|
||||
return new Badge(
|
||||
accountBadge.getId(),
|
||||
configuration.getCategory(),
|
||||
configuration.getImageUrl(),
|
||||
resourceBundle.getString(accountBadge.getId() + "_name"),
|
||||
resourceBundle.getString(accountBadge.getId() + "_description"));
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,16 @@ import javax.validation.constraints.NotNull;
|
||||
public class BadgeConfiguration {
|
||||
private final String id;
|
||||
private final URL imageUrl;
|
||||
private final String category;
|
||||
|
||||
@JsonCreator
|
||||
public BadgeConfiguration(
|
||||
@JsonProperty("id") final String id,
|
||||
@JsonProperty("imageUrl") @JsonDeserialize(converter = URLDeserializationConverter.class) final URL imageUrl) {
|
||||
@JsonProperty("imageUrl") @JsonDeserialize(converter = URLDeserializationConverter.class) final URL imageUrl,
|
||||
@JsonProperty("category") final String category) {
|
||||
this.id = id;
|
||||
this.imageUrl = imageUrl;
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
@NotEmpty
|
||||
@@ -35,4 +38,9 @@ public class BadgeConfiguration {
|
||||
public URL getImageUrl() {
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
@NotEmpty
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.Objects;
|
||||
|
||||
public class Badge {
|
||||
private final String id;
|
||||
private final String category;
|
||||
private final URL imageUrl;
|
||||
private final String name;
|
||||
private final String description;
|
||||
@@ -19,10 +20,12 @@ public class Badge {
|
||||
@JsonCreator
|
||||
public Badge(
|
||||
@JsonProperty("id") final String id,
|
||||
@JsonProperty("category") final String category,
|
||||
@JsonProperty("imageUrl") final URL imageUrl,
|
||||
@JsonProperty("name") final String name,
|
||||
@JsonProperty("description") final String description) {
|
||||
this.id = id;
|
||||
this.category = category;
|
||||
this.imageUrl = imageUrl;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
@@ -32,6 +35,10 @@ public class Badge {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public URL getImageUrl() {
|
||||
return imageUrl;
|
||||
}
|
||||
@@ -53,13 +60,14 @@ public class Badge {
|
||||
return false;
|
||||
}
|
||||
Badge badge = (Badge) o;
|
||||
return Objects.equals(id, badge.id) && Objects.equals(imageUrl,
|
||||
badge.imageUrl) && Objects.equals(name, badge.name) && Objects.equals(
|
||||
description, badge.description);
|
||||
return Objects.equals(id, badge.id) && Objects.equals(category,
|
||||
badge.category) && Objects.equals(imageUrl, badge.imageUrl)
|
||||
&& Objects.equals(name, badge.name) && Objects.equals(description,
|
||||
badge.description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, imageUrl, name, description);
|
||||
return Objects.hash(id, category, imageUrl, name, description);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user