Skip to content

Commit c789fbd

Browse files
committed
Expose last usage of users unique ids
1 parent 1444644 commit c789fbd

File tree

6 files changed

+55
-4
lines changed

6 files changed

+55
-4
lines changed

compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ services:
1616
- "3306:3306"
1717

1818
faf-db-migrations:
19-
image: faforever/faf-db-migrations:v138
19+
image: faforever/faf-db-migrations:v140
2020
command: migrate
2121
environment:
2222
FLYWAY_URL: jdbc:mysql://faf-db/faf?useSSL=false

src/inttest/java/com/faforever/api/config/MainDbTestContainers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
@Configuration
2222
public class MainDbTestContainers {
2323
private static final MariaDBContainer<?> fafDBContainer = new MariaDBContainer<>("mariadb:11.7");
24-
private static final GenericContainer<?> flywayMigrationsContainer = new GenericContainer<>("faforever/faf-db-migrations:v137");
24+
private static final GenericContainer<?> flywayMigrationsContainer = new GenericContainer<>("faforever/faf-db-migrations:v140");
2525
private static final Network sharedNetwork = Network.newNetwork();
2626

2727
@Bean

src/inttest/java/com/faforever/api/data/GroupPermissionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void canReadPermissionsWithScopeAndRole() throws Exception {
5151
mockMvc.perform(get("/data/groupPermission")
5252
.with(getOAuthTokenWithActiveUser(OAuthScope._READ_SENSIBLE_USERDATA, GroupPermission.ROLE_READ_USER_GROUP)))
5353
.andExpect(status().isOk())
54-
.andExpect(jsonPath("$.data", hasSize(25)));
54+
.andExpect(jsonPath("$.data", hasSize(26)));
5555
}
5656

5757
@Test

src/main/java/com/faforever/api/data/domain/Login.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public abstract class Login extends AbstractEntity<Login> implements OwnableEnti
4040
private String recentIpAddress;
4141
private OffsetDateTime lastLogin;
4242
private Set<UniqueId> uniqueIds;
43+
private Set<UniqueIdAssignment> uniqueIdAssignments;
4344

4445

4546
public Login() {
@@ -122,6 +123,7 @@ public Set<UserGroup> getUserGroups() {
122123
return userGroups;
123124
}
124125

126+
@Deprecated(forRemoval = true)
125127
@OneToMany
126128
@JoinTable(name = "unique_id_users",
127129
joinColumns = @JoinColumn(name = "user_id"),
@@ -132,6 +134,12 @@ public Set<UniqueId> getUniqueIds() {
132134
return uniqueIds;
133135
}
134136

137+
@OneToMany(mappedBy = "user")
138+
@ReadPermission(expression = ReadAccountPrivateDetailsCheck.EXPRESSION)
139+
public Set<UniqueIdAssignment> getUniqueIdAssignments() {
140+
return uniqueIdAssignments;
141+
}
142+
135143
@Override
136144
@Transient
137145
@JsonIgnore
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.faforever.api.data.domain;
2+
3+
import com.yahoo.elide.annotation.Include;
4+
import lombok.EqualsAndHashCode;
5+
import lombok.Getter;
6+
import lombok.NoArgsConstructor;
7+
import lombok.Setter;
8+
import lombok.ToString;
9+
10+
import jakarta.persistence.Entity;
11+
import jakarta.persistence.FetchType;
12+
import jakarta.persistence.JoinColumn;
13+
import jakarta.persistence.ManyToOne;
14+
import jakarta.persistence.Table;
15+
import java.io.Serializable;
16+
17+
@Entity
18+
@Table(name = "unique_id_users")
19+
@Include(name = UniqueIdAssignment.TYPE_NAME, rootLevel = false)
20+
@Getter
21+
@Setter
22+
@NoArgsConstructor
23+
@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true)
24+
@ToString(onlyExplicitlyIncluded = true)
25+
public class UniqueIdAssignment extends AbstractEntity<UniqueIdAssignment> implements Serializable {
26+
public static final String TYPE_NAME = "uniqueIdAssignment";
27+
28+
private Player user;
29+
private UniqueId uniqueId;
30+
31+
@ManyToOne(fetch = FetchType.LAZY)
32+
@JoinColumn(name = "user_id")
33+
public Player getUser() {
34+
return user;
35+
}
36+
37+
@ManyToOne(fetch = FetchType.LAZY)
38+
// WTF? Who designed this table?
39+
@JoinColumn(name = "uniqueid_hash", referencedColumnName = "hash")
40+
public UniqueId getUniqueId() {
41+
return uniqueId;
42+
}
43+
}

src/main/resources/config/application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ faf-api:
1616
hmac-secret: ${CLOUDFLARE_HMAC_SECRET}
1717
hmac-param: ${CLOUDFLARE_HMAC_PARAM:verify}
1818
database:
19-
schema-version: ${DATABASE_SCHEMA_VERSION:138}
19+
schema-version: ${DATABASE_SCHEMA_VERSION:140}
2020
deployment:
2121
forged-alliance-exe-path: ${FORGED_ALLIANCE_EXE_PATH:/content/legacy-featured-mod-files/updates_faf_files/ForgedAlliance.exe}
2222
repositories-directory: ${REPOSITORIES_DIRECTORY:/repositories}

0 commit comments

Comments
 (0)