SudoSOS Back-end API / websocket / getTerminalPaymentRelation
Function: getTerminalPaymentRelation() ​
function getTerminalPaymentRelation(userId, terminalPaymentId): Promise<"all" | "own">;Determine the RBAC relation between a user and a single TerminalPayment.
Deliberately avoids TerminalPaymentService: that reaches TransactionService, which imports WebSocketService, so importing it from the websocket layer would close a require cycle.
The TerminalPayment entity is loaded with a dynamic import rather than a top-level one for a second, separate reason. Its subtree contains a mutual import between tmp-sub-transaction and tmp-sub-transaction-row, and pulling that subtree in from here changes module initialisation order enough that TmpSubTransactionRow ends up extending an undefined SubTransactionRow. Resolving at call time sidesteps the ordering entirely, by which point every entity is loaded. The underlying entity cycle is worth fixing on its own.
Only the relations needed for the check are loaded, which is a leaner query than the full graph TerminalPaymentService.getTerminalPayment builds.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
userId | number | ID of the user subscribing. |
terminalPaymentId | number | ID of the terminal payment being subscribed to. |
Returns ​
Promise<"all" | "own">
own when the user is connected to the payment, all otherwise (including when it does not exist).