@@ -17,7 +17,7 @@ export class Approved {
1717 const userId = ctx . message ?. reply_to_message ?. from ?. id ! ;
1818 const chatId = ctx . chat ?. id ! ;
1919
20- const groupSettings = await this . groupSettingsRepo . getByGroupId ( chatId ) ;
20+ const group = await this . groupSettingsRepo . getByGroupId ( chatId ) ;
2121
2222 let user = await this . userRepo . getByTelegramId ( userId ) ;
2323 if ( ! user ) {
@@ -28,34 +28,34 @@ export class Approved {
2828 } ) ;
2929 await this . userRepo . save ( user ) ;
3030 }
31- return { user, groupSettings } ;
31+ return { user, group } ;
3232 }
3333
3434 @initGroupSetting ( )
3535 static async add ( ctx : Context ) {
36- const { user, groupSettings } = await this . getEntities ( ctx ) ;
36+ const { user, group } = await this . getEntities ( ctx ) ;
3737 // Check if the user is already approved
3838 const existingApproval = await this . approvedUserRepo . getByUserIdAndGroup (
3939 user . id ,
40- groupSettings ! . id !
40+ group ! . id !
4141 ) ;
4242 if ( existingApproval ) {
4343 return ctx . reply ( "This user is already approved." ) ;
4444 }
4545
4646 // Add user to the approved list
4747 const approvedUser = await this . approvedUserRepo . create ( {
48- group : groupSettings ! ,
48+ group : group ! ,
4949 user_id : user . telegram_id ,
5050 username : user . username ! ,
5151 user : user ,
5252 } ) ;
5353 await this . approvedUserRepo . save ( approvedUser ) ;
54- if ( ! groupSettings ! . approvedUsers ) {
55- groupSettings ! . approvedUsers = [ ] ;
54+ if ( ! group ! . approvedUsers ) {
55+ group ! . approvedUsers = [ ] ;
5656 }
57- groupSettings ! . approvedUsers . push ( approvedUser ) ;
58- await this . groupSettingsRepo . save ( groupSettings ! ) ;
57+ group ! . approvedUsers . push ( approvedUser ) ;
58+ await this . groupSettingsRepo . save ( group ! ) ;
5959 user . role = "approved" ;
6060 await this . userRepo . save ( user ) ;
6161 // Grant full permissions
@@ -72,12 +72,12 @@ export class Approved {
7272
7373 @initGroupSetting ( )
7474 static async remove ( ctx : Context ) {
75- const { user, groupSettings } = await this . getEntities ( ctx ) ;
75+ const { user, group } = await this . getEntities ( ctx ) ;
7676
7777 // Remove user from the approved list
7878 const approvedUser = await this . approvedUserRepo . getByUserIdAndGroup (
7979 user . id ,
80- groupSettings ! . id !
80+ group ! . id !
8181 ) ;
8282 if ( approvedUser ) {
8383 await this . approvedUserRepo . remove ( approvedUser . id ) ;
@@ -99,19 +99,16 @@ export class Approved {
9999 @initGroupSetting ( )
100100 static async list ( ctx : Context ) {
101101 const chatId = ctx . chat ?. id ! ;
102- const groupSettings = await this . groupSettingsRepo . getByGroupId ( chatId ) ;
103- const approvedUsers = await this . approvedUserRepo . getByGroup (
104- groupSettings !
105- ) ;
102+ const group = await this . groupSettingsRepo . getByGroupId ( chatId ) ;
103+ const approvedUsers = await this . approvedUserRepo . getByGroup ( group ! ) ;
106104
107105 if ( ! approvedUsers || approvedUsers . length === 0 ) {
108106 await ctx . reply ( "There are no approved users in this group." ) ;
109107 return ;
110108 }
111109 // Format the list of approved users
112- const userList = approvedUsers
113- . map ( ( user ) => {
114- const username = user . username ? `@${ user . username } ` : "No username" ;
110+ const userList = approvedUsers . map ( ( user ) => {
111+ const username = user . username ? `@${ user . username } ` : "No username" ;
115112 return `- ${ username } ` ;
116113 } )
117114 . join ( "\n" ) ;
0 commit comments