|
|
|
@ -2,25 +2,21 @@ use std::cmp::Ordering; |
|
|
|
|
use std::collections::HashSet; |
|
|
|
|
use std::time::Duration; |
|
|
|
|
|
|
|
|
|
use elefren::{FediClient, SearchType, StatusBuilder}; |
|
|
|
|
use elefren::entities::account::Account; |
|
|
|
|
use elefren::entities::prelude::Status; |
|
|
|
|
use elefren::status_builder::Visibility; |
|
|
|
|
use elefren::{FediClient, SearchType, StatusBuilder}; |
|
|
|
|
|
|
|
|
|
use crate::command::{RE_NOBOT_TAG, StatusCommand}; |
|
|
|
|
use crate::command::{StatusCommand, RE_NOBOT_TAG}; |
|
|
|
|
use crate::error::GroupError; |
|
|
|
|
use crate::group_handler::GroupHandle; |
|
|
|
|
use crate::store::CommonConfig; |
|
|
|
|
use crate::store::group_config::GroupConfig; |
|
|
|
|
use crate::store::CommonConfig; |
|
|
|
|
use crate::tr::TranslationTable; |
|
|
|
|
use crate::utils; |
|
|
|
|
use crate::utils::{LogError, normalize_acct, VisExt}; |
|
|
|
|
use crate::utils::{normalize_acct, LogError, VisExt}; |
|
|
|
|
|
|
|
|
|
use crate::{ |
|
|
|
|
grp_debug, |
|
|
|
|
grp_warn, |
|
|
|
|
grp_info |
|
|
|
|
}; |
|
|
|
|
use crate::{grp_debug, grp_info, grp_warn}; |
|
|
|
|
|
|
|
|
|
pub struct ProcessMention<'a> { |
|
|
|
|
status: Status, |
|
|
|
@ -51,7 +47,7 @@ impl<'a> ProcessMention<'a> { |
|
|
|
|
self.client |
|
|
|
|
.search_v2(acct, !followed, Some(SearchType::Accounts), Some(1), followed), |
|
|
|
|
) |
|
|
|
|
.await |
|
|
|
|
.await |
|
|
|
|
{ |
|
|
|
|
Err(_) => { |
|
|
|
|
grp_warn!(self, "Account lookup timeout!"); |
|
|
|
@ -98,9 +94,9 @@ impl<'a> ProcessMention<'a> { |
|
|
|
|
let mut to_add = String::new(); |
|
|
|
|
for m in members { |
|
|
|
|
to_add.push_str(&if admins.contains(&m) { |
|
|
|
|
crate::tr!(self, "user_list_entry_admin", user=m) |
|
|
|
|
crate::tr!(self, "user_list_entry_admin", user = m) |
|
|
|
|
} else { |
|
|
|
|
crate::tr!(self, "user_list_entry", user=m) |
|
|
|
|
crate::tr!(self, "user_list_entry", user = m) |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
self.add_reply(&to_add); |
|
|
|
@ -149,8 +145,7 @@ impl<'a> ProcessMention<'a> { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async fn reblog_status(&self) { |
|
|
|
|
self.client.reblog(&self.status.id) |
|
|
|
|
.await.log_error("Failed to reblog status"); |
|
|
|
|
self.client.reblog(&self.status.id).await.log_error("Failed to reblog status"); |
|
|
|
|
self.delay_after_post().await; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -419,7 +414,7 @@ impl<'a> ProcessMention<'a> { |
|
|
|
|
|
|
|
|
|
async fn cmd_undo(&mut self) -> Result<(), GroupError> { |
|
|
|
|
if let (Some(ref parent_account_id), Some(ref parent_status_id)) = |
|
|
|
|
(&self.status.in_reply_to_account_id, &self.status.in_reply_to_id) |
|
|
|
|
(&self.status.in_reply_to_account_id, &self.status.in_reply_to_id) |
|
|
|
|
{ |
|
|
|
|
if parent_account_id == &self.group_account.id { |
|
|
|
|
// This is a post sent by the group user, likely an announcement.
|
|
|
|
@ -675,7 +670,11 @@ impl<'a> ProcessMention<'a> { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if self.config.is_member_only() { |
|
|
|
|
self.add_reply(crate::tr!(self, "help_group_info_closed", membership = &membership_line)); |
|
|
|
|
self.add_reply(crate::tr!( |
|
|
|
|
self, |
|
|
|
|
"help_group_info_closed", |
|
|
|
|
membership = &membership_line |
|
|
|
|
)); |
|
|
|
|
} else { |
|
|
|
|
self.add_reply(crate::tr!(self, "help_group_info_open", membership = &membership_line)); |
|
|
|
|
} |
|
|
|
@ -709,7 +708,7 @@ impl<'a> ProcessMention<'a> { |
|
|
|
|
let mut to_add = String::new(); |
|
|
|
|
|
|
|
|
|
for t in tags { |
|
|
|
|
to_add.push_str(&crate::tr!(self, "tag_list_entry", tag=t)); |
|
|
|
|
to_add.push_str(&crate::tr!(self, "tag_list_entry", tag = t)); |
|
|
|
|
} |
|
|
|
|
self.add_reply(to_add); |
|
|
|
|
} |
|
|
|
|