forked from MightyPork/group-actor
wip translation system
This commit is contained in:
+10
-19
@@ -1,4 +1,5 @@
|
||||
use std::collections::VecDeque;
|
||||
use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
@@ -19,6 +20,7 @@ use crate::command::StatusCommand;
|
||||
use crate::error::GroupError;
|
||||
use crate::store::CommonConfig;
|
||||
use crate::store::GroupConfig;
|
||||
use crate::tr::{EMPTY_TRANSLATION_TABLE, TranslationTable};
|
||||
use crate::utils::{normalize_acct, LogError, VisExt};
|
||||
|
||||
mod handle_mention;
|
||||
@@ -46,14 +48,6 @@ impl Default for GroupInternal {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO move other options to common_config!
|
||||
|
||||
// // const DELAY_BEFORE_ACTION: Duration = Duration::from_millis(250);
|
||||
// const DELAY_REOPEN_STREAM: Duration = Duration::from_millis(500);
|
||||
// // higher because we can expect a lot of non-hashtag statuses here
|
||||
// const SOCKET_ALIVE_TIMEOUT: Duration = Duration::from_secs(30);
|
||||
// const SOCKET_RETIRE_TIME: Duration = Duration::from_secs(120);
|
||||
|
||||
macro_rules! grp_debug {
|
||||
($self:ident, $f:expr) => {
|
||||
::log::debug!(concat!("(@{}) ", $f), $self.config.get_acct());
|
||||
@@ -531,6 +525,11 @@ impl GroupHandle {
|
||||
res
|
||||
}
|
||||
|
||||
fn tr(&self) -> &TranslationTable {
|
||||
self.cc.tr.get(self.config.get_locale())
|
||||
.unwrap_or(&EMPTY_TRANSLATION_TABLE)
|
||||
}
|
||||
|
||||
async fn handle_new_follow(&mut self, notif_acct: &str, notif_user_id: &str) {
|
||||
let mut follow_back = false;
|
||||
let text = if self.config.is_member_only() {
|
||||
@@ -539,24 +538,16 @@ impl GroupHandle {
|
||||
let mut admins = self.config.get_admins().cloned().collect::<Vec<_>>();
|
||||
admins.sort();
|
||||
|
||||
format!(
|
||||
"\
|
||||
@{user} Welcome to the group! This group has posting restricted to members. \
|
||||
If you'd like to join, please ask one of the group admins:\n\
|
||||
{admins}",
|
||||
crate::tr!(self, "welcome_member_only",
|
||||
user = notif_acct,
|
||||
admins = admins.join(", ")
|
||||
admins = &admins.join(", ")
|
||||
)
|
||||
} else {
|
||||
follow_back = true;
|
||||
|
||||
self.config.set_member(notif_acct, true).log_error("Fail add a member");
|
||||
|
||||
format!(
|
||||
"\
|
||||
@{user} Welcome to the group! The group user will now follow you back to complete the sign-up. \
|
||||
To share a post, @ the group user or use a group hashtag.\n\n\
|
||||
Use /help for more info.",
|
||||
crate::tr!(self, "welcome_public",
|
||||
user = notif_acct
|
||||
)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user