@@ -118,27 +118,28 @@ pub async fn create_submit_chat(c: &mut SqliteConnection, chat: &SubmitChat) ->
118118 Ok ( ( ) )
119119}
120120
121- /// Upgrade a submit chat with chat_id `id` to a review chat
121+ /// Upgrade a submit chat with chat_id `id` to a review chat.
122122pub async fn upgrade_to_review_chat (
123123 c : & mut SqliteConnection ,
124124 chat : & ReviewChat ,
125125) -> anyhow:: Result < ( ) > {
126126 sqlx:: query (
127- "UPDATE chats SET review_helper = ?, submit_helper = ?, review_chat_id = ?, submit_chat_id = ?, publisher = ?, app_info = ? WHERE submit_chat_id = ?"
128- ) . bind ( chat . review_helper . to_u32 ( ) )
129- . bind ( chat. submit_helper . to_u32 ( ) )
130- . bind ( chat. submit_chat . to_u32 ( ) )
127+ "UPDATE chats SET review_helper = ?, review_chat_id = ?, publisher = ?, testers = ? WHERE submit_chat_id = ?"
128+ )
129+ . bind ( chat. review_helper . to_u32 ( ) )
130+ . bind ( chat. review_chat . to_u32 ( ) )
131131 . bind ( chat. publisher . to_u32 ( ) )
132+ . bind ( serde_json:: to_string ( & chat. testers ) ?)
132133 . bind ( chat. submit_chat . to_u32 ( ) )
133- . bind ( chat . review_chat . to_u32 ( ) ) . execute ( c) . await ?;
134+ . execute ( c) . await ?;
134135 Ok ( ( ) )
135136}
136137
137138pub async fn get_review_chat (
138139 c : & mut SqliteConnection ,
139140 chat_id : ChatId ,
140141) -> anyhow:: Result < ReviewChat > {
141- sqlx:: query ( "SELECT review_helper, submit_helper, review_chat_id, submit_chat_id, publisher, app_info FROM chats WHERE ( review_chat_id = ?) " )
142+ sqlx:: query ( "SELECT review_helper, submit_helper, review_chat_id, submit_chat_id, publisher, testers, app_info FROM chats WHERE review_chat_id = ?" )
142143 . bind ( chat_id. to_u32 ( ) )
143144 . fetch_one ( c)
144145 . await
@@ -150,7 +151,7 @@ pub async fn get_review_chat(
150151 submit_chat : ChatId :: new ( row. try_get ( "submit_chat_id" ) ?) ,
151152 publisher : ContactId :: new ( row. try_get ( "publisher" ) ?) ,
152153 app_info : row. try_get ( "app_info" ) ?,
153- testers : vec ! [ ] ,
154+ testers : serde_json :: from_str ( row . try_get ( "testers" ) ? ) ? ,
154155 } )
155156 } ) ?
156157}
@@ -440,14 +441,18 @@ mod tests {
440441 submit_chat : submit_chat. submit_chat ,
441442 submit_helper : submit_chat. submit_helper ,
442443 review_chat : review_chat_id,
444+ testers : vec ! [ ContactId :: new( 3 ) ] ,
443445 ..Default :: default ( )
444446 } ;
445447
446448 upgrade_to_review_chat ( & mut conn, & review_chat)
447449 . await
448450 . unwrap ( ) ;
449451
450- get_review_chat ( & mut conn, review_chat_id) . await . unwrap ( ) ;
452+ let loaded_review_chat = super :: get_review_chat ( & mut conn, review_chat_id)
453+ . await
454+ . unwrap ( ) ;
455+ assert_eq ! ( loaded_review_chat. testers, review_chat. testers) ;
451456 }
452457
453458 #[ tokio:: test]
0 commit comments