mirror of
https://github.com/sky-systems/sky_phone.git
synced 2026-09-04 16:23:22 +00:00
ENH - refine banking experience
This commit is contained in:
@@ -71,8 +71,6 @@ local server_callbacks = {
|
||||
"calls:decline",
|
||||
"calls:hangup",
|
||||
"banking:overview",
|
||||
"banking:deposit",
|
||||
"banking:withdraw",
|
||||
"banking:transfer",
|
||||
"messages:conversations",
|
||||
"messages:thread",
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Sky Phone</title>
|
||||
<script type="module" crossorigin src="./assets/sky-index-8Bzj9L4a.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="./assets/sky-index-C6M6KClq.css">
|
||||
<script type="module" crossorigin src="./assets/sky-index-2HtRTJch.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="./assets/sky-index-Bhv3YOTT.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
@@ -91,52 +91,6 @@ Bridge.Callbacks.Register("sky_phone:banking:overview", function(source)
|
||||
return { success = true, data = overview(source, identifier) }
|
||||
end)
|
||||
|
||||
Bridge.Callbacks.Register("sky_phone:banking:deposit", function(source, data)
|
||||
if not SkyPhone.AllowOperation(source, "banking_transaction", Config.Banking.ActionsPerMinute, 60) then
|
||||
return { success = false, error = "rate_limited" }
|
||||
end
|
||||
local identifier, error_response = require_banking_session(source)
|
||||
if not identifier then
|
||||
return error_response
|
||||
end
|
||||
local amount = valid_amount(data and data.amount)
|
||||
if not amount then
|
||||
return { success = false, error = "invalid_request" }
|
||||
end
|
||||
if not Bridge.Framework.RemoveMoney(source, "cash", amount) then
|
||||
return { success = false, error = "insufficient_funds" }
|
||||
end
|
||||
if not Bridge.Framework.AddMoney(source, "bank", amount) then
|
||||
Bridge.Framework.AddMoney(source, "cash", amount)
|
||||
return { success = false, error = "transfer_failed" }
|
||||
end
|
||||
record_transaction(identifier, "deposit", amount, "", "cash-deposit")
|
||||
return { success = true, data = overview(source, identifier) }
|
||||
end)
|
||||
|
||||
Bridge.Callbacks.Register("sky_phone:banking:withdraw", function(source, data)
|
||||
if not SkyPhone.AllowOperation(source, "banking_transaction", Config.Banking.ActionsPerMinute, 60) then
|
||||
return { success = false, error = "rate_limited" }
|
||||
end
|
||||
local identifier, error_response = require_banking_session(source)
|
||||
if not identifier then
|
||||
return error_response
|
||||
end
|
||||
local amount = valid_amount(data and data.amount)
|
||||
if not amount then
|
||||
return { success = false, error = "invalid_request" }
|
||||
end
|
||||
if not Bridge.Framework.RemoveMoney(source, "bank", amount) then
|
||||
return { success = false, error = "insufficient_funds" }
|
||||
end
|
||||
if not Bridge.Framework.AddMoney(source, "cash", amount) then
|
||||
Bridge.Framework.AddMoney(source, "bank", amount)
|
||||
return { success = false, error = "transfer_failed" }
|
||||
end
|
||||
record_transaction(identifier, "withdrawal", amount, "", "cash-withdrawal")
|
||||
return { success = true, data = overview(source, identifier) }
|
||||
end)
|
||||
|
||||
Bridge.Callbacks.Register("sky_phone:banking:transfer", function(source, data)
|
||||
if not SkyPhone.AllowOperation(source, "banking_transaction", Config.Banking.ActionsPerMinute, 60) then
|
||||
return { success = false, error = "rate_limited" }
|
||||
|
||||
Reference in New Issue
Block a user