ChangeMeta method
All checks were successful
Build and Test / mario-tennis (push) Successful in 3m10s
Build and Test / puyopuyo (push) Successful in 3m35s
Build and Test / splatoon (push) Successful in 3m36s
Build and Test / minecraft-wiiu (push) Successful in 3m37s
Build and Test / splatoon-testfire (push) Successful in 3m41s
Build and Test / friends (push) Successful in 3m48s
Build and Test / fast-racing-neo (push) Successful in 3m50s
Build and Test / wii-sports-club (push) Successful in 4m1s
Build and Test / wii-u-chat (push) Successful in 4m0s
Build and Test / sonic-transformed (push) Successful in 4m8s
Build and Test / super-mario-maker (push) Successful in 4m43s
All checks were successful
Build and Test / mario-tennis (push) Successful in 3m10s
Build and Test / puyopuyo (push) Successful in 3m35s
Build and Test / splatoon (push) Successful in 3m36s
Build and Test / minecraft-wiiu (push) Successful in 3m37s
Build and Test / splatoon-testfire (push) Successful in 3m41s
Build and Test / friends (push) Successful in 3m48s
Build and Test / fast-racing-neo (push) Successful in 3m50s
Build and Test / wii-sports-club (push) Successful in 4m1s
Build and Test / wii-u-chat (push) Successful in 4m0s
Build and Test / sonic-transformed (push) Successful in 4m8s
Build and Test / super-mario-maker (push) Successful in 4m43s
This commit is contained in:
parent
18ba3d46a2
commit
982f9a2e3b
6 changed files with 194 additions and 1 deletions
15
rnex-core/.sqlx/query-31e36bb378bcf8e665391d9cd2c5282fea9540a0673456d58f8142cafc330240.json
generated
Normal file
15
rnex-core/.sqlx/query-31e36bb378bcf8e665391d9cd2c5282fea9540a0673456d58f8142cafc330240.json
generated
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE datastore.objects SET data_type=$1 WHERE data_id=$2",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int4",
|
||||
"Int8"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "31e36bb378bcf8e665391d9cd2c5282fea9540a0673456d58f8142cafc330240"
|
||||
}
|
||||
28
rnex-core/.sqlx/query-433b8cbd7320b5463391b08545c09b11255b363112c3379319b9e69ed003f2eb.json
generated
Normal file
28
rnex-core/.sqlx/query-433b8cbd7320b5463391b08545c09b11255b363112c3379319b9e69ed003f2eb.json
generated
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n SELECT update_password, under_review FROM datastore.objects WHERE data_id=$1 AND upload_completed=TRUE AND deleted=FALSE\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "update_password",
|
||||
"type_info": "Int8"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "under_review",
|
||||
"type_info": "Bool"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "433b8cbd7320b5463391b08545c09b11255b363112c3379319b9e69ed003f2eb"
|
||||
}
|
||||
15
rnex-core/.sqlx/query-c27439038dc25c17738b4a9cc37f94f83f23239a0c37c7adbccaef571e0128da.json
generated
Normal file
15
rnex-core/.sqlx/query-c27439038dc25c17738b4a9cc37f94f83f23239a0c37c7adbccaef571e0128da.json
generated
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE datastore.objects SET meta_binary=$1 WHERE data_id=$2",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Bytea",
|
||||
"Int8"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "c27439038dc25c17738b4a9cc37f94f83f23239a0c37c7adbccaef571e0128da"
|
||||
}
|
||||
15
rnex-core/.sqlx/query-daac203a168b0aab9550176524d0741da291e8861fd7c6ac4838d7fe20a871f8.json
generated
Normal file
15
rnex-core/.sqlx/query-daac203a168b0aab9550176524d0741da291e8861fd7c6ac4838d7fe20a871f8.json
generated
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE datastore.objects SET period=$1 WHERE data_id=$2",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int4",
|
||||
"Int8"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "daac203a168b0aab9550176524d0741da291e8861fd7c6ac4838d7fe20a871f8"
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
use futures::TryFutureExt;
|
||||
use rnex_core::nex::user::User;
|
||||
use rnex_core::PID;
|
||||
use rnex_core::executables::common::{
|
||||
|
|
@ -5,7 +6,7 @@ use rnex_core::executables::common::{
|
|||
};
|
||||
use rnex_core::kerberos::KerberosDateTime;
|
||||
use rnex_core::nex::s3presigner::S3Presigner;
|
||||
use rnex_core::rmc::protocols::datastore::{BufferQueueParam, CompletePostParam, DataStoreCustomRankingResult, DataStoreGetCustomRankingByDataIDParam, DataStorePrepareGetParam, DataStoreReqGetInfo, DataStoreSearchParam, GetMetaInfo, GetMetaParam, KeyValue, Permission, PersistenceTarget, RateCustomRankingParam, RatingInfo, RatingInfoWithSlot, RatingInitParamWithSlot};
|
||||
use rnex_core::rmc::protocols::datastore::{BufferQueueParam, CompletePostParam, DataStoreChangeMetaParam, DataStoreCustomRankingResult, DataStoreGetCustomRankingByDataIDParam, DataStorePrepareGetParam, DataStoreReqGetInfo, DataStoreSearchParam, GetMetaInfo, GetMetaParam, KeyValue, Permission, PersistenceTarget, RateCustomRankingParam, RatingInfo, RatingInfoWithSlot, RatingInitParamWithSlot};
|
||||
use rnex_core::rmc::protocols::datastore::{DataStore, PreparePostParam, ReqPostInfo, AttachFileParam, DataStoreRateObjectParam, DataStoreRatingTarget};
|
||||
use rnex_core::rmc::response::ErrorCode;
|
||||
use rnex_core::rmc::structures::qbuffer::QBuffer;
|
||||
|
|
@ -66,6 +67,7 @@ fn map_row_to_meta_info(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
pub async fn check_object_availability(data_id: u64, password: u64) -> Result<(), ErrorCode> {
|
||||
let row = sqlx::query!(
|
||||
r#"
|
||||
|
|
@ -658,6 +660,31 @@ async fn rate_object(dataid: u64, slot: i8, rating_value: i32, access_password:
|
|||
Ok(rating)
|
||||
}
|
||||
|
||||
async fn change_meta_object_check(param: &DataStoreChangeMetaParam) -> Result<(), ErrorCode> {
|
||||
let row = sqlx::query!(
|
||||
r#"
|
||||
SELECT update_password, under_review FROM datastore.objects WHERE data_id=$1 AND upload_completed=TRUE AND deleted=FALSE
|
||||
"#,
|
||||
param.dataid as i64
|
||||
)
|
||||
.fetch_one(get_db())
|
||||
.await
|
||||
.map_err(|e| {
|
||||
log::error!("DB Error: {:?}", e);
|
||||
ErrorCode::DataStore_SystemFileError
|
||||
})?;
|
||||
|
||||
if row.update_password != 0 && row.update_password != param.update_password as i64 {
|
||||
return Err(ErrorCode::DataStore_InvalidPassword);
|
||||
}
|
||||
|
||||
if row.under_review {
|
||||
return Err(ErrorCode::DataStore_UnderReviewing);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
impl DataStore for User {
|
||||
async fn get_meta(&self, metaparam: GetMetaParam) -> Result<GetMetaInfo, ErrorCode> {
|
||||
let mut meta_info = if metaparam.dataid != 0 {
|
||||
|
|
@ -1260,4 +1287,59 @@ impl DataStore for User {
|
|||
|
||||
Ok((ratings, results))
|
||||
}
|
||||
|
||||
async fn change_meta(&self, param: DataStoreChangeMetaParam) -> Result<(), ErrorCode> {
|
||||
let object_info = get_object_info_by_data_id(param.dataid, 0).await?;
|
||||
verify_object_permission(object_info.owner, self.pid, &object_info.permission).await?;
|
||||
|
||||
if param.modifies_flag & 0x08 != 0 {
|
||||
change_meta_object_check(¶m).await?;
|
||||
|
||||
sqlx::query!(
|
||||
r#"UPDATE datastore.objects SET period=$1 WHERE data_id=$2"#,
|
||||
param.period as i16,
|
||||
param.dataid as i64
|
||||
)
|
||||
.execute(get_db())
|
||||
.await
|
||||
.map_err(|e| {
|
||||
eprintln!("update error: {:?}", e);
|
||||
ErrorCode::DataStore_SystemFileError
|
||||
})?;
|
||||
}
|
||||
|
||||
if param.modifies_flag & 0x10 != 0 {
|
||||
change_meta_object_check(¶m).await?;
|
||||
|
||||
sqlx::query!(
|
||||
r#"UPDATE datastore.objects SET meta_binary=$1 WHERE data_id=$2"#,
|
||||
param.meta_binary.0,
|
||||
param.dataid as i64
|
||||
)
|
||||
.execute(get_db())
|
||||
.await
|
||||
.map_err(|e| {
|
||||
eprintln!("update error: {:?}", e);
|
||||
ErrorCode::DataStore_SystemFileError
|
||||
})?;
|
||||
}
|
||||
|
||||
if param.modifies_flag & 0x80 != 0 {
|
||||
change_meta_object_check(¶m).await?;
|
||||
|
||||
sqlx::query!(
|
||||
r#"UPDATE datastore.objects SET data_type=$1 WHERE data_id=$2"#,
|
||||
param.data_type as i16,
|
||||
param.dataid as i64
|
||||
)
|
||||
.execute(get_db())
|
||||
.await
|
||||
.map_err(|e| {
|
||||
eprintln!("update error: {:?}", e);
|
||||
ErrorCode::DataStore_SystemFileError
|
||||
})?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -235,6 +235,39 @@ pub struct DataStoreRateObjectParam {
|
|||
pub access_password: u64,
|
||||
}
|
||||
|
||||
#[derive(RmcSerialize, Clone, Default, Debug)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct DataStoreChangeMetaCompareParam {
|
||||
pub comparison_flag: u32,
|
||||
pub name: String,
|
||||
pub permission: Permission,
|
||||
pub del_permission: Permission,
|
||||
pub period: u16,
|
||||
pub meta_binary: QBuffer,
|
||||
pub tags: Vec<String>,
|
||||
pub referred_cnt: u32,
|
||||
pub data_type: u16,
|
||||
pub status: u8,
|
||||
}
|
||||
|
||||
#[derive(RmcSerialize, Clone, Default, Debug)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct DataStoreChangeMetaParam {
|
||||
pub dataid: u64,
|
||||
pub modifies_flag: u32,
|
||||
pub name: String,
|
||||
pub permission: Permission,
|
||||
pub del_permission: Permission,
|
||||
pub period: u16,
|
||||
pub meta_binary: QBuffer,
|
||||
pub tags: Vec<String>,
|
||||
pub update_password: u64,
|
||||
pub referred_cnt: u32,
|
||||
pub data_type: u16,
|
||||
pub status: u8,
|
||||
pub compare_param: DataStoreChangeMetaCompareParam,
|
||||
}
|
||||
|
||||
#[rmc_proto(115)]
|
||||
pub trait DataStore {
|
||||
#[method_id(8)]
|
||||
|
|
@ -285,6 +318,11 @@ pub trait DataStore {
|
|||
&self,
|
||||
application_id: u32,
|
||||
) -> Result<Vec<String>, ErrorCode>;
|
||||
#[method_id(38)]
|
||||
async fn change_meta(
|
||||
&self,
|
||||
param: DataStoreChangeMetaParam
|
||||
) -> Result<(), ErrorCode>;
|
||||
#[method_id(40)]
|
||||
async fn rate_objects(
|
||||
&self,
|
||||
|
|
|
|||
Loading…
Reference in a new issue