@@ -14,7 +14,7 @@ pub enum PermissionType {
14
14
/// Decides if a GitHub user can perform various actions using the bot.
15
15
#[ async_trait]
16
16
pub trait PermissionResolver {
17
- async fn has_permission ( & self , username : & str , permission : PermissionType ) -> bool ;
17
+ async fn has_permission ( & self , user_id : & u64 , permission : PermissionType ) -> bool ;
18
18
async fn reload ( & self ) ;
19
19
}
20
20
@@ -46,11 +46,11 @@ impl TeamApiPermissionResolver {
46
46
47
47
#[ async_trait]
48
48
impl PermissionResolver for TeamApiPermissionResolver {
49
- async fn has_permission ( & self , username : & str , permission : PermissionType ) -> bool {
49
+ async fn has_permission ( & self , user_id : & u64 , permission : PermissionType ) -> bool {
50
50
self . permissions
51
51
. lock ( )
52
52
. await
53
- . has_permission ( username , permission)
53
+ . has_permission ( user_id , permission)
54
54
}
55
55
56
56
async fn reload ( & self ) {
@@ -59,15 +59,15 @@ impl PermissionResolver for TeamApiPermissionResolver {
59
59
}
60
60
61
61
pub struct UserPermissions {
62
- review_users : HashSet < String > ,
63
- try_users : HashSet < String > ,
62
+ review_users : HashSet < u64 > ,
63
+ try_users : HashSet < u64 > ,
64
64
}
65
65
66
66
impl UserPermissions {
67
- fn has_permission ( & self , username : & str , permission : PermissionType ) -> bool {
67
+ fn has_permission ( & self , user_id : & u64 , permission : PermissionType ) -> bool {
68
68
match permission {
69
- PermissionType :: Review => self . review_users . contains ( username ) ,
70
- PermissionType :: Try => self . try_users . contains ( username ) ,
69
+ PermissionType :: Review => self . review_users . contains ( user_id ) ,
70
+ PermissionType :: Try => self . try_users . contains ( user_id ) ,
71
71
}
72
72
}
73
73
}
@@ -90,14 +90,14 @@ async fn load_permissions(repo: &GithubRepoName) -> anyhow::Result<UserPermissio
90
90
91
91
#[ derive( serde:: Deserialize ) ]
92
92
struct UserPermissionsResponse {
93
- github_users : HashSet < String > ,
93
+ github_ids : HashSet < u64 > ,
94
94
}
95
95
96
96
/// Loads users that are allowed to perform try/review from the Rust Team API.
97
97
async fn load_users_from_team_api (
98
98
repository_name : & str ,
99
99
permission : PermissionType ,
100
- ) -> anyhow:: Result < HashSet < String > > {
100
+ ) -> anyhow:: Result < HashSet < u64 > > {
101
101
let permission = match permission {
102
102
PermissionType :: Review => "review" ,
103
103
PermissionType :: Try => "try" ,
@@ -112,5 +112,5 @@ async fn load_users_from_team_api(
112
112
. json :: < UserPermissionsResponse > ( )
113
113
. await
114
114
. map_err ( |error| anyhow:: anyhow!( "Cannot deserialize users from team API: {error:?}" ) ) ?;
115
- Ok ( users. github_users )
115
+ Ok ( users. github_ids )
116
116
}
0 commit comments