wire-server icon indicating copy to clipboard operation
wire-server copied to clipboard

Do Spar things transactionally

Open arianvp opened this issue 6 years ago • 0 comments

Right, I think this might still be worth it in this one, and should look like something in the lines of:

insertScimAndSamlUser :: (HasCallStack, MonadClient m) => UserId -> SAML.UserRef -> ScimC.User.StoredUser SparTag -> m ()
insertScimAndSamlUser uid (SAML.UserRef tenant subject) scimUsr = retry x5 . batch $ do
  setType BatchLogged
  setConsistency Quorum
  addPrepQuery insScim (uid, WrappedScimStoredUser scimUsr)
  addPrepQuery insSaml (tenant, subject, uid)
  where
    insScim :: PrepQuery W (UserId, WrappedScimStoredUser SparTag) ()
    insScim = "INSERT INTO scim_user (id, json) VALUES (?, ?)"

    insSaml :: PrepQuery W (SAML.Issuer, SAML.NameID, UserId) ()
    insSaml = "INSERT INTO user (issuer, sso_id, uid) VALUES (?, ?, ?)"

The main annoyance I see with this is that you will need a Show instance for WrappedScimStoredUser SparTag -> not sure how trivial it is to come up with a meaningful one.

Originally posted by @tiago-loureiro in https://github.com/wireapp/wire-server/pull/905

arianvp avatar Nov 20 '19 14:11 arianvp