sgx-catapult users on same DB so need passthru fix
Denver Gingerich
created
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).
@@ -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)