From 25bc6adbfa85259d7bd584391f0951997cfd594f Mon Sep 17 00:00:00 2001 From: Denver Gingerich Date: Sat, 1 Aug 2020 19:26:45 +0000 Subject: [PATCH] sgx-catapult users on same DB so need passthru fix We run sgx-bwmsgsv2 and sgx-catapult off the same database, which means that mere existence in the database does not mean that we can pass on the message directly, as they could be on a different system (i.e. sgx-catapult instead of sgx-bwmsgsv2) and Cheogram will become unhappy if we try to pass on messages in this way (plus it's wrong). As a result, we need to make the check more precise, and specifically determine that the destination user is a user of sgx-bwmsgsv2, which we do by checking for a distinctive characteristic of the credentials. This should ideally be done in a better way, but since we just have the two systems for now, it is easy to do this substring check, as all credentials follow this general pattern. We know this commit works because we've been running it in production for a couple months now (* sigh *) and will be making a similar commit to sgx-catapult in the near future (as it naturally requires the same sort of change in order to work properly, per above). --- sgx-bwmsgsv2.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sgx-bwmsgsv2.rb b/sgx-bwmsgsv2.rb index 2db2375d00967be79a82d07830f72802a925cb77..9a0dcb78f30da6b6902b05edde37f32d21f73a7d 100755 --- a/sgx-bwmsgsv2.rb +++ b/sgx-bwmsgsv2.rb @@ -460,8 +460,17 @@ module SGXbwmsgsv2 [jid, num_dest] + creds } }.then { |(jid, num_dest, *creds)| - # if destination user is in the system pass on directly if jid + cred_key = "catapult_cred-#{jid}" + REDIS.lrange(cred_key, 0, 0).then { |other_user| + [jid, num_dest] + creds + other_user + } + else + [jid, num_dest] + creds + [nil] + end + }.then { |(jid, num_dest, *creds, other_user)| + # if destination user is in the system pass on directly + if other_user and not other_user.start_with? 'u-' pass_on_message(m, creds.last, jid) else to_catapult_possible_oob(m, num_dest, *creds)