~singpolyma/sgx-jmp

sgx-jmp/lib/customer_repo.rb -rw-r--r-- 5.0 KiB
Merge branch 'use-tel-we-have'

* use-tel-we-have:
  Skip asking backend about registration when we know the tel already
Skip asking backend about registration when we know the tel already

This is an optimization.  If we are looking up by tel already, then we don't
need to ask the backend sgx if they have a tel or what it is, we know that, so
just use that information directly and save us a call.
Merge branch 'multi-account-billing'

* multi-account-billing:
  Use billing customer for LowBalance notification
  Get settled amount from billing customer for TrustLevelRepo
  Use the multi account billing schema
Get settled amount from billing customer for TrustLevelRepo
Merge branch 'cancel-account'

* cancel-account:
  Admin command to cancel customer
  Move Customer factory/extractor to Customer
Admin command to cancel customer

Notify customer
Deregister from SGX
Deregister from Cheogram
Disconnect from Bandwidth
	If on special list, move intead of disconnect
Move Customer factory/extractor to Customer

The repo's job is to get the data, constructing the object can be a factory's job.
JID Switch

This allows a customer to change their JID, but it's a bit raw.
In practice I don't expect anyone to actually run this directly, instead
cheogram covers with with a friendlier and safer version.

This is just the business.
CustomerPlan.extract

To allow building from a hash with extra keys. Makes the CustomerRepo more readable.
Postgres#query_one

Helper for queries that only return a single row.
Do not allow nil tndetails
LazyObject is not nil, so safenav doesn't work
Refactor CustomerInfoForm to use find_by_format
Set Sentry user from CustomerRepo

We don't always use this to get the current user, so make it optional.
CustomerRepo::QueryKey and CustomerRepo#find_by_format

Introduce objects representing the different kind of query keys that can be used
to look up a customer.  These keys know how to use themselves to get
the (customer_id, jid) pair that is needed for an actual repo lookup.  All
find_by_* methods are now just trivial wrappers over these objects that pass on
to find_inner.

This enables the easy creation of a new helper: QueryKey.for, used as
find_by_format which allows passing an xmpp: URI, or a properly formatted tel,
or a customer id, and will find by the correct one.  This could cause a problem
if a customer id were to be a valid xmpp: URI or a formatted tel, so this method
does assume not using these formats for any customer id (which would be
ill-advised in any case).
put_monthly_overage_limit
Use default from Customer constructor
Next