mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-08-30 20:54:22 +00:00
fix: discover errors and Removed field (#944)
add Removed status, and fully document locale for ContactSupport Signed-off-by: IAmTomahawkx <iamtomahawkx@gmail.com>
This commit is contained in:
@@ -8,6 +8,7 @@ auto_derived!(
|
||||
pub enum DiscoverRequestStatus {
|
||||
Pending,
|
||||
UnderReview,
|
||||
Removed(Option<String>),
|
||||
Denied(Option<String>), // reason
|
||||
Approved(Option<String>), // reason
|
||||
}
|
||||
|
||||
@@ -27,6 +27,12 @@ impl AbstractDiscoverRequest for MongoDb {
|
||||
DiscoverRequestStatus::Approved(_)
|
||||
| DiscoverRequestStatus::Pending
|
||||
| DiscoverRequestStatus::UnderReview => return Err(create_error!(NoEffect)),
|
||||
DiscoverRequestStatus::Removed(_) => {
|
||||
return Err(create_error!(ContactSupport {
|
||||
locale: "discover.removed_cannot_apply".to_string(),
|
||||
msg: "Your server/bot was removed from Discover. Please contact support for more information.".to_string()
|
||||
}))
|
||||
}
|
||||
_ => Ok(()),
|
||||
}?;
|
||||
self.col::<DiscoverRequest>(DISCOVER_COL).update_one(
|
||||
@@ -70,6 +76,20 @@ impl AbstractDiscoverRequest for MongoDb {
|
||||
request_type: DiscoverRequestType,
|
||||
item: &str,
|
||||
) -> Result<()> {
|
||||
let existing = self
|
||||
.fetch_discover_request_by_item_id(request_type.clone(), item)
|
||||
.await?;
|
||||
match existing.status {
|
||||
DiscoverRequestStatus::Approved(_) | DiscoverRequestStatus::Removed(_) => {
|
||||
Err(create_error!(ContactSupport {
|
||||
locale: "discover.cannot_auto_remove".to_string(), msg: "Your Discover request cannot be automatically removed, please contact Support".to_string()
|
||||
}))
|
||||
}
|
||||
DiscoverRequestStatus::Denied(_) => Err(create_error!(ContactSupport {
|
||||
locale: "discover.declined_apply_again".to_string(), msg: "Your Discover request has been declined, and cannot be removed. Please apply again instead".to_string()
|
||||
})),
|
||||
DiscoverRequestStatus::Pending | DiscoverRequestStatus::UnderReview => Ok(()),
|
||||
}?;
|
||||
query!(
|
||||
self,
|
||||
delete_one,
|
||||
|
||||
@@ -134,6 +134,7 @@ impl From<crate::DiscoverRequestType> for DiscoverRequestType {
|
||||
impl From<crate::DiscoverRequestStatus> for DiscoverRequestStatus {
|
||||
fn from(value: crate::DiscoverRequestStatus) -> Self {
|
||||
match value {
|
||||
crate::DiscoverRequestStatus::Removed(s) => DiscoverRequestStatus::Removed(s),
|
||||
crate::DiscoverRequestStatus::Approved(s) => DiscoverRequestStatus::Approved(s),
|
||||
crate::DiscoverRequestStatus::Denied(s) => DiscoverRequestStatus::Denied(s),
|
||||
crate::DiscoverRequestStatus::Pending => DiscoverRequestStatus::Pending,
|
||||
|
||||
@@ -7,6 +7,7 @@ auto_derived!(
|
||||
pub enum DiscoverRequestStatus {
|
||||
Pending,
|
||||
UnderReview,
|
||||
Removed(Option<String>),
|
||||
Denied(Option<String>), // reason
|
||||
Approved(Option<String>), // reason
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ pub enum ErrorType {
|
||||
|
||||
// ? Support Errors
|
||||
ContactSupport {
|
||||
locale: String,
|
||||
msg: String,
|
||||
},
|
||||
|
||||
|
||||
@@ -43,8 +43,14 @@ pub async fn discover_remove_bot(
|
||||
|
||||
match ret.status {
|
||||
DiscoverRequestStatus::Approved(_) => Err(create_error!(ContactSupport {
|
||||
locale: "discover.bot_removal_approved".to_string(),
|
||||
msg: "Contact support to have your bot removed from Discover".to_string()
|
||||
})),
|
||||
DiscoverRequestStatus::Removed(_) => Err(create_error!(ContactSupport {
|
||||
locale: "discover.bot_removal_removed".to_string(),
|
||||
msg: "Your bot has been removed from discover, contact support for more information"
|
||||
.to_string()
|
||||
})),
|
||||
DiscoverRequestStatus::Denied(_) => Err(create_error!(NoEffect)),
|
||||
DiscoverRequestStatus::Pending | DiscoverRequestStatus::UnderReview => {
|
||||
db.delete_discover_request(ret.request_type, &ret.request_id)
|
||||
|
||||
@@ -43,8 +43,14 @@ pub async fn discover_remove(
|
||||
|
||||
match ret.status {
|
||||
DiscoverRequestStatus::Approved(_) => Err(create_error!(ContactSupport {
|
||||
locale: "discover.server_removal_approved".to_string(),
|
||||
msg: "Contact support to have your server removed from Discover".to_string()
|
||||
})),
|
||||
DiscoverRequestStatus::Removed(_) => Err(create_error!(ContactSupport {
|
||||
locale: "discover.server_removal_removed".to_string(),
|
||||
msg: "Your server has been removed from discover, contact support for more information"
|
||||
.to_string()
|
||||
})),
|
||||
DiscoverRequestStatus::Denied(_) => Err(create_error!(NoEffect)),
|
||||
DiscoverRequestStatus::Pending | DiscoverRequestStatus::UnderReview => {
|
||||
db.delete_discover_request(ret.request_type, &ret.request_id)
|
||||
|
||||
15
docs/docs/developers/locale.md
Normal file
15
docs/docs/developers/locale.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Locale
|
||||
|
||||
Certain endpoints have full text errors with localization keys attached. The current error types with these keys are:
|
||||
|
||||
- ContactSupport(locale: localization key, msg: plaintext english message)
|
||||
|
||||
the following localization keys are used by the backend in error messages:
|
||||
|
||||
- ContactSupport - discover.bot_removal_approved - The bot is already on discover, the user must contact support to have it removed.
|
||||
- ContactSupport - discover.bot_removal_removed - The bot has been removed from discover by moderators, the user must contact support.
|
||||
- ContactSupport - discover.server_removal_approved - The server is already on discover, the user must contact support to have it removed.
|
||||
- ContactSupport - discover.server_removal_removed - The server has been removed from discover by moderators, the user must contact support.
|
||||
- ContactSupport - discover.declined_apply_again - The Discover request was declined. Declined requests cannot be removed, but the user may submit again.
|
||||
- ContactSupport - discover.cannot_auto_remove - The Discover request is approved or the item has been removed from discover. In either case, the user must contact support.
|
||||
- ContactSupport - discover.removed_cannot_apply - The item was removed by moderators, and as such future applications are prohibited. Contact support for more information.
|
||||
Reference in New Issue
Block a user