Skip to content

Commit

Permalink
🐛 invalidate commonhaus data on reset, too
Browse files Browse the repository at this point in the history
  • Loading branch information
ebullient committed Jun 10, 2024
1 parent 2a68d8d commit e3f74c8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public Response finishLogin() {
public Response getUserInfo(@DefaultValue("false") @QueryParam("refresh") boolean refresh) {
if (refresh) {
AdminDataCache.KNOWN_USER.invalidate(session.login());
AdminDataCache.COMMONHAUS_DATA.invalidate(CommonhausDatastore.getKey(session));
session.userIsKnown(ctx);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public CommonhausUser setCommonhausUser(CommonhausUser user, Set<String> roles,
*/
@ConsumeEvent(value = READ)
public Uni<CommonhausUser> fetchCommonhausUser(QueryEvent event) {
final String key = event.login() + ":" + event.id();
final String key = getKey(event);

CommonhausUser result = event.refresh()
? null
Expand Down Expand Up @@ -141,7 +141,7 @@ public Uni<CommonhausUser> fetchCommonhausUser(QueryEvent event) {
@ConsumeEvent(value = WRITE)
public Uni<CommonhausUser> pushCommonhausUser(UpdateEvent event) {
final CommonhausUser user = event.user();
final String key = user.login() + ":" + user.id();
final String key = getKey(user);

CommonhausUser result;
ScopedQueryContext qc = ctx.getDatastoreContext();
Expand Down Expand Up @@ -241,4 +241,16 @@ private CommonhausUser deepCopy(CommonhausUser user) {
private String dataPath(long id) {
return "data/users/" + id + ".yaml";
}

public static String getKey(QueryEvent event) {
return event.login() + ":" + event.id();
}

public static String getKey(CommonhausUser user) {
return user.login() + ":" + user.id();
}

public static String getKey(MemberSession session) {
return session.login() + ":" + session.nodeId();
}
}

0 comments on commit e3f74c8

Please sign in to comment.