add: extended app storage limits
This commit is contained in:
parent
c757ddb77a
commit
9aed5de097
12 changed files with 143 additions and 20 deletions
|
@ -1,6 +1,6 @@
|
|||
use oiseau::cache::Cache;
|
||||
use crate::model::{
|
||||
apps::{AppQuota, ThirdPartyApp},
|
||||
apps::{AppQuota, ThirdPartyApp, DeveloperPassStorageQuota},
|
||||
auth::User,
|
||||
oauth::AppScope,
|
||||
permissions::{FinePermission, SecondaryPermission},
|
||||
|
@ -25,6 +25,7 @@ impl DataManager {
|
|||
scopes: serde_json::from_str(&get!(x->9(String))).unwrap(),
|
||||
api_key: get!(x->10(String)),
|
||||
data_used: get!(x->11(i32)) as usize,
|
||||
storage_capacity: serde_json::from_str(&get!(x->12(String))).unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,7 +96,7 @@ impl DataManager {
|
|||
|
||||
let res = execute!(
|
||||
&conn,
|
||||
"INSERT INTO apps VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)",
|
||||
"INSERT INTO apps VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)",
|
||||
params![
|
||||
&(data.id as i64),
|
||||
&(data.created as i64),
|
||||
|
@ -108,7 +109,8 @@ impl DataManager {
|
|||
&(data.grants as i32),
|
||||
&serde_json::to_string(&data.scopes).unwrap(),
|
||||
&data.api_key,
|
||||
&(data.data_used as i32)
|
||||
&(data.data_used as i32),
|
||||
&serde_json::to_string(&data.storage_capacity).unwrap(),
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -167,6 +169,7 @@ impl DataManager {
|
|||
auto_method!(update_app_quota_status(AppQuota)@get_app_by_id -> "UPDATE apps SET quota_status = $1 WHERE id = $2" --serde --cache-key-tmpl=cache_clear_app);
|
||||
auto_method!(update_app_scopes(Vec<AppScope>)@get_app_by_id:FinePermission::MANAGE_APPS; -> "UPDATE apps SET scopes = $1 WHERE id = $2" --serde --cache-key-tmpl=cache_clear_app);
|
||||
auto_method!(update_app_api_key(&str)@get_app_by_id -> "UPDATE apps SET api_key = $1 WHERE id = $2" --cache-key-tmpl=cache_clear_app);
|
||||
auto_method!(update_app_storage_capacity(DeveloperPassStorageQuota)@get_app_by_id -> "UPDATE apps SET storage_capacity = $1 WHERE id = $2" --serde --cache-key-tmpl=cache_clear_app);
|
||||
|
||||
auto_method!(update_app_data_used(i32)@get_app_by_id -> "UPDATE apps SET data_used = $1 WHERE id = $2" --cache-key-tmpl=cache_clear_app);
|
||||
auto_method!(add_app_data_used(i32)@get_app_by_id -> "UPDATE apps SET data_used = data_used + $1 WHERE id = $2" --cache-key-tmpl=cache_clear_app);
|
||||
|
|
|
@ -9,5 +9,6 @@ CREATE TABLE IF NOT EXISTS apps (
|
|||
banned INT NOT NULL,
|
||||
grants INT NOT NULL,
|
||||
scopes TEXT NOT NULL,
|
||||
data_used INT NOT NULL CHECK (data_used >= 0)
|
||||
data_used INT NOT NULL CHECK (data_used >= 0),
|
||||
storage_capacity TEXT NOT NULL
|
||||
)
|
||||
|
|
|
@ -5,3 +5,7 @@ ADD COLUMN IF NOT EXISTS channel_mutes TEXT DEFAULT '[]';
|
|||
-- users is_deactivated
|
||||
ALTER TABLE users
|
||||
ADD COLUMN IF NOT EXISTS is_deactivated INT DEFAULT 0;
|
||||
|
||||
-- apps storage_capacity
|
||||
ALTER TABLE apps
|
||||
ADD COLUMN IF NOT EXISTS storage_capacity TEXT DEFAULT '"Tier1"';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue