@@ -49,6 +49,8 @@ static CHECKS: &[Check<fn(&Data, &mut Vec<String>)>] = checks![
4949 validate_zulip_group_extra_people,
5050 validate_unique_zulip_streams,
5151 validate_unique_zulip_user_ids,
52+ validate_present_zulip_id,
53+ validate_zulip_id_allowlist,
5254 validate_zulip_stream_ids,
5355 validate_zulip_stream_extra_people,
5456 validate_repos,
@@ -715,6 +717,53 @@ fn validate_unique_zulip_user_ids(data: &Data, errors: &mut Vec<String>) {
715717 } )
716718}
717719
720+ /// Ensure that every active member except a few remaining people on an allowlist have a Zulip ID.
721+ fn validate_present_zulip_id ( data : & Data , errors : & mut Vec < String > ) {
722+ wrapper (
723+ data. active_members ( ) . unwrap ( ) . iter ( ) ,
724+ errors,
725+ |person, _| {
726+ let person = data. person ( person) . expect ( "Person not found" ) ;
727+ if person. zulip_id ( ) . is_none ( )
728+ && !data
729+ . config ( )
730+ . members_without_zulip_id ( )
731+ . contains ( person. github ( ) )
732+ {
733+ return Err ( anyhow:: anyhow!(
734+ "User {} does not have a Zulip ID" ,
735+ person. github( )
736+ ) ) ;
737+ }
738+ Ok ( ( ) )
739+ } ,
740+ )
741+ }
742+
743+ /// Ensure people in the missing Zulip ID allowlist do not actually have Zulip ID configured.
744+ fn validate_zulip_id_allowlist ( data : & Data , errors : & mut Vec < String > ) {
745+ // Sort for deterministic output
746+ let mut members = data
747+ . config ( )
748+ . members_without_zulip_id ( )
749+ . iter ( )
750+ . collect :: < Vec < _ > > ( ) ;
751+ members. sort ( ) ;
752+ for member in members {
753+ let Some ( person) = data. person ( member) else {
754+ errors. push ( format ! (
755+ "Person {member} in Zulip ID allowlist does not exist"
756+ ) ) ;
757+ continue ;
758+ } ;
759+ if person. zulip_id ( ) . is_some ( ) {
760+ errors. push ( format ! (
761+ "Person {member} in Zulip ID allowlist has Zulip ID configured. Please remove them from the `members-without-zulip-id` list in `config.toml`"
762+ ) ) ;
763+ }
764+ }
765+ }
766+
718767/// Ensure team members in Zulip groups have a Zulip id
719768fn validate_zulip_group_ids ( data : & Data , errors : & mut Vec < String > ) {
720769 wrapper ( data. teams ( ) , errors, |team, errors| {
@@ -731,15 +780,17 @@ fn validate_zulip_group_ids(data: &Data, errors: &mut Vec<String>) {
731780 // Okay, have zulip IDs.
732781 }
733782 ZulipMember :: MemberWithoutId { github } => {
734- // Bad, only github handle, no zulip ID, even though included in zulip user
735- // group
736- bail ! (
737- "person `{}` in '{}' is a member of a Zulip user group '{}' but has no \
738- Zulip id",
739- github,
740- team. name( ) ,
741- group. name( )
742- ) ;
783+ if !data. config ( ) . members_without_zulip_id ( ) . contains ( github) {
784+ // Bad, only github handle, no zulip ID, even though included in zulip user
785+ // group
786+ bail ! (
787+ "person `{}` in '{}' is a member of a Zulip user group '{}' but has no \
788+ Zulip id",
789+ github,
790+ team. name( ) ,
791+ group. name( )
792+ ) ;
793+ }
743794 }
744795 }
745796 Ok ( ( ) )
@@ -764,11 +815,13 @@ fn validate_zulip_stream_ids(data: &Data, errors: &mut Vec<String>) {
764815 match member {
765816 ZulipMember :: MemberWithId { .. } | ZulipMember :: JustId ( _) => { }
766817 ZulipMember :: MemberWithoutId { github } => {
767- bail ! (
768- "person `{github}` is a member of a Zulip stream `{}` defined in team `{}`, but has no Zulip id" ,
769- stream. name( ) ,
770- team. name( )
771- ) ;
818+ if !data. config ( ) . members_without_zulip_id ( ) . contains ( github) {
819+ bail ! (
820+ "person `{github}` is a member of a Zulip stream `{}` defined in team `{}`, but has no Zulip id" ,
821+ stream. name( ) ,
822+ team. name( )
823+ ) ;
824+ }
772825 }
773826 }
774827 Ok ( ( ) )
0 commit comments