Add _test_submission.png silent test submissions
This commit is contained in:
parent
2e45f0205a
commit
b3cb507b16
1 changed files with 76 additions and 67 deletions
|
@ -99,6 +99,7 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
|
|||
};
|
||||
let author = ctx.author();
|
||||
let mut submitted_images = Vec::new();
|
||||
let mut is_test = false;
|
||||
for submission in submission_data.iter_mut() {
|
||||
if is_matching_submission(submission, author) {
|
||||
existing_submitter = true;
|
||||
|
@ -110,6 +111,9 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
|
|||
.map(|value| value.as_str().unwrap().to_owned())
|
||||
.collect();
|
||||
for (i, attachment) in attachments.iter().enumerate() {
|
||||
if attachment.filename.starts_with("_test_submission.") {
|
||||
is_test = true;
|
||||
}
|
||||
let extension;
|
||||
if let Some(content_type) = &attachment.content_type {
|
||||
if content_type == "image/png" {
|
||||
|
@ -156,6 +160,9 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
|
|||
submitter_data.insert(String::from("username"), username.clone().into());
|
||||
let mut images: Vec<String> = Vec::new();
|
||||
for (i, attachment) in attachments.iter().enumerate() {
|
||||
if attachment.filename.starts_with("_test_submission.") {
|
||||
is_test = true;
|
||||
}
|
||||
let extension;
|
||||
if let Some(content_type) = &attachment.content_type {
|
||||
if content_type == "image/png" {
|
||||
|
@ -227,6 +234,7 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
|
|||
} else {
|
||||
None
|
||||
};
|
||||
if !is_test {
|
||||
for image in submitted_images.iter() {
|
||||
for (other_guild_id, data) in guild_data.iter() {
|
||||
let here = other_guild_id.eq(&ctx.guild_id().unwrap().as_u64().to_string());
|
||||
|
@ -297,6 +305,7 @@ pub async fn submit(ctx: Context<'_>, submission: serenity::Attachment) -> Resul
|
|||
.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if invalid_types {
|
||||
message.push_str("Sorry, your submission could not be uploaded; only **.png**, **.jpg**, and **.jpeg** files are permitted.");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue