From e3f74c88ab5454f7fb7b02bed03a223ff47a37d1 Mon Sep 17 00:00:00 2001 From: Erin Schnabel Date: Mon, 10 Jun 2024 07:44:18 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20invalidate=20commonhaus=20data?= =?UTF-8?q?=20on=20reset,=20too?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../automation/admin/api/MemberResource.java | 1 + .../admin/github/CommonhausDatastore.java | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cf-admin-bot/src/main/java/org/commonhaus/automation/admin/api/MemberResource.java b/cf-admin-bot/src/main/java/org/commonhaus/automation/admin/api/MemberResource.java index 08d3620..7288a21 100644 --- a/cf-admin-bot/src/main/java/org/commonhaus/automation/admin/api/MemberResource.java +++ b/cf-admin-bot/src/main/java/org/commonhaus/automation/admin/api/MemberResource.java @@ -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); } diff --git a/cf-admin-bot/src/main/java/org/commonhaus/automation/admin/github/CommonhausDatastore.java b/cf-admin-bot/src/main/java/org/commonhaus/automation/admin/github/CommonhausDatastore.java index 4f6caef..29b962d 100644 --- a/cf-admin-bot/src/main/java/org/commonhaus/automation/admin/github/CommonhausDatastore.java +++ b/cf-admin-bot/src/main/java/org/commonhaus/automation/admin/github/CommonhausDatastore.java @@ -104,7 +104,7 @@ public CommonhausUser setCommonhausUser(CommonhausUser user, Set roles, */ @ConsumeEvent(value = READ) public Uni fetchCommonhausUser(QueryEvent event) { - final String key = event.login() + ":" + event.id(); + final String key = getKey(event); CommonhausUser result = event.refresh() ? null @@ -141,7 +141,7 @@ public Uni fetchCommonhausUser(QueryEvent event) { @ConsumeEvent(value = WRITE) public Uni 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(); @@ -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(); + } }