File tree Expand file tree Collapse file tree
api/handler/externals/tickets Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ pub async fn handle_external_ticket_create(
134134 ) ) ;
135135 }
136136
137- if thread_exists ( user_id, & db_pool) . await {
137+ if thread_exists_by_user ( user_id, & db_pool) . await {
138138 return if let Some ( channel_id_str) = get_thread_channel_by_user_id ( user_id, & db_pool) . await
139139 {
140140 Err ( (
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ impl RegistrableCommand for AddStaffCommand {
105105 }
106106 } ;
107107
108- if thread_exists ( command. user . id , pool) . await {
108+ if thread_exists_by_channel ( command. channel_id , pool) . await {
109109 match add_user_to_channel ( & ctx, command. channel_id , user_id) . await {
110110 Ok ( _) => {
111111 let mut params = HashMap :: new ( ) ;
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ pub async fn add_staff(
3030 Err ( _) => return Err ( ModmailError :: Command ( CommandError :: InvalidFormat ) ) ,
3131 } ;
3232
33- if thread_exists ( msg. author . id , pool) . await {
33+ if thread_exists_by_channel ( msg. channel_id , pool) . await {
3434 match add_user_to_channel ( & ctx, msg. channel_id , user_id) . await {
3535 Ok ( _) => {
3636 let mut params = HashMap :: new ( ) ;
Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ impl RegistrableCommand for NewThreadCommand {
121121 return Err ( ModmailError :: Discord ( DiscordError :: UserIsABot ) ) ;
122122 }
123123
124- if thread_exists ( user_id, pool) . await {
124+ if thread_exists_by_user ( user_id, pool) . await {
125125 return if let Some ( channel_id_str) =
126126 get_thread_channel_by_user_id ( user_id, pool) . await
127127 {
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ pub async fn new_thread(
3737 return Err ( ModmailError :: Discord ( DiscordError :: UserIsABot ) ) ;
3838 }
3939
40- if thread_exists ( user_id, pool) . await {
40+ if thread_exists_by_user ( user_id, pool) . await {
4141 if let Some ( channel_id_str) = get_thread_channel_by_user_id ( user_id, pool) . await {
4242 let mut params = HashMap :: new ( ) ;
4343 params. insert ( "user" . to_string ( ) , user. name . clone ( ) ) ;
Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ impl RegistrableCommand for RemoveStaffCommand {
107107 }
108108 } ;
109109
110- if thread_exists ( command. user . id , pool) . await {
110+ if thread_exists_by_channel ( command. channel_id , pool) . await {
111111 match remove_user_from_channel ( & ctx, command. channel_id , user_id) . await {
112112 Ok ( _) => {
113113 let mut params = HashMap :: new ( ) ;
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ pub async fn remove_staff(
3030 Err ( _) => return Err ( ModmailError :: Command ( CommandError :: InvalidFormat ) ) ,
3131 } ;
3232
33- if thread_exists ( msg. author . id , pool) . await {
33+ if thread_exists_by_channel ( msg. channel_id , pool) . await {
3434 match remove_user_from_channel ( & ctx, msg. channel_id , user_id) . await {
3535 Ok ( _) => {
3636 let mut params = HashMap :: new ( ) ;
Original file line number Diff line number Diff line change @@ -218,10 +218,16 @@ pub async fn close_thread(
218218 Ok ( ( ) )
219219}
220220
221- pub async fn thread_exists ( user_id : UserId , pool : & SqlitePool ) -> bool {
221+ pub async fn thread_exists_by_user ( user_id : UserId , pool : & SqlitePool ) -> bool {
222222 get_thread_channel_by_user_id ( user_id, pool) . await . is_some ( )
223223}
224224
225+ pub async fn thread_exists_by_channel ( channel : ChannelId , pool : & SqlitePool ) -> bool {
226+ get_thread_by_channel_id ( & channel. to_string ( ) , pool)
227+ . await
228+ . is_some ( )
229+ }
230+
225231pub async fn is_a_ticket_channel ( channel_id : ChannelId , pool : & SqlitePool ) -> bool {
226232 sqlx:: query_scalar ( "SELECT EXISTS(SELECT 1 FROM threads WHERE channel_id = ?)" )
227233 . bind ( channel_id. to_string ( ) )
Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ async fn manage_incoming_message(
140140 let user_mutex = get_thread_lock ( config, user_key) ;
141141 let guard = user_mutex. lock ( ) . await ;
142142
143- if thread_exists ( msg. author . id , pool) . await {
143+ if thread_exists_by_user ( msg. author . id , pool) . await {
144144 if let Some ( channel_id_str) = get_thread_channel_by_user_id ( msg. author . id , pool) . await {
145145 let channel_id_num = channel_id_str
146146 . parse :: < u64 > ( )
Original file line number Diff line number Diff line change @@ -1169,6 +1169,14 @@ pub fn load_english_messages(dict: &mut ErrorDictionary) {
11691169 "audit_log.member.role_update" . to_string ( ) ,
11701170 DictionaryMessage :: new ( "Member Roles Updated" ) ,
11711171 ) ;
1172+ dict. messages . insert (
1173+ "audit_log.member.move" . to_string ( ) ,
1174+ DictionaryMessage :: new ( "Member Moved" ) ,
1175+ ) ;
1176+ dict. messages . insert (
1177+ "audit_log.member.disconnect" . to_string ( ) ,
1178+ DictionaryMessage :: new ( "Member Disconnected" ) ,
1179+ ) ;
11721180 dict. messages . insert (
11731181 "audit_log.member.member_move" . to_string ( ) ,
11741182 DictionaryMessage :: new ( "Member Moved" ) ,
You can’t perform that action at this time.
0 commit comments