12
12
/// </summary>
13
13
internal class TeamsAppPreApprovalPolicyConverter
14
14
{
15
+ /// <summary>
16
+ /// Team Scope Type.
17
+ /// </summary>
18
+ private const string TeamScopeType = "team" ;
19
+
20
+ /// <summary>
21
+ /// Chat scope type.
22
+ /// </summary>
23
+ private const string ChatScopeType = "chat" ;
24
+
15
25
/// <summary>
16
26
/// Collection of RSC permissions.
17
27
/// </summary>
@@ -109,7 +119,7 @@ internal async Task<MGTeamsInternalPermissionGrantPreApprovalPolicy> ConvertToPe
109
119
await this . ValidateAndGetRscPermissionIds ( resourceSpecificApplicationPermissionsAllowedForChats ) ;
110
120
111
121
MGTeamsInternalPreapprovalDetail preapprovalDetail = new MGTeamsInternalPreapprovalDetail (
112
- scopeType : "chat" ,
122
+ scopeType : TeamsAppPreApprovalPolicyConverter . ChatScopeType ,
113
123
sensitivityLabels : new MGTeamsInternalAllScopeSensitivityLabels ( ) ,
114
124
permissions : new MGTeamsInternalEnumeratedPreApprovedPermissions ( chatRscPermissionIds ) ) ;
115
125
@@ -122,7 +132,7 @@ internal async Task<MGTeamsInternalPermissionGrantPreApprovalPolicy> ConvertToPe
122
132
await this . ValidateAndGetRscPermissionIds ( resourceSpecificApplicationPermissionsAllowedForTeams ) ;
123
133
124
134
MGTeamsInternalPreapprovalDetail preapprovalDetail = new MGTeamsInternalPreapprovalDetail (
125
- scopeType : "group" ,
135
+ scopeType : TeamsAppPreApprovalPolicyConverter . TeamScopeType ,
126
136
sensitivityLabels : this . GetTeamSensitivityLabelsForPreApprovalDetail (
127
137
teamLevelSensitivityLabelSelectionMode ,
128
138
specificSensitivityLabelIdsApplicableToTeams ) ,
@@ -159,41 +169,41 @@ internal async Task<IMicrosoftGraphTeamsAppPreApproval> ConvertToTeamsAppPreAppr
159
169
$ "Unsupported scenario. Preapproval policy '{ permissionGrantPreApprovalPolicy . Id } ' has more than 2 conditions.") ;
160
170
}
161
171
162
- MGTeamsInternalPreapprovalDetail groupCondition =
163
- permissionGrantPreApprovalPolicy . Conditions . FirstOrDefault ( c => string . Equals ( c . ScopeType , "group" ) ) ;
172
+ MGTeamsInternalPreapprovalDetail teamCondition =
173
+ permissionGrantPreApprovalPolicy . Conditions . FirstOrDefault ( c => string . Equals ( c . ScopeType , TeamsAppPreApprovalPolicyConverter . TeamScopeType ) ) ;
164
174
165
175
MGTeamsInternalPreapprovalDetail chatCondition =
166
- permissionGrantPreApprovalPolicy . Conditions . FirstOrDefault ( c => string . Equals ( c . ScopeType , "chat" ) ) ;
176
+ permissionGrantPreApprovalPolicy . Conditions . FirstOrDefault ( c => string . Equals ( c . ScopeType , TeamsAppPreApprovalPolicyConverter . ChatScopeType ) ) ;
167
177
168
- if ( permissionGrantPreApprovalPolicy . Conditions . Any ( c => c != groupCondition && c != chatCondition ) )
178
+ if ( permissionGrantPreApprovalPolicy . Conditions . Any ( c => c != teamCondition && c != chatCondition ) )
169
179
{
170
180
throw new MGTeamsInternalException (
171
181
MGTeamsInternalErrorType . UnsupportedScenario ,
172
182
$ "Unsupported scenario. Preapproval policy '{ permissionGrantPreApprovalPolicy . Id } ' has unsupported conditions.") ;
173
183
}
174
184
175
- if ( groupCondition != null )
185
+ if ( teamCondition != null )
176
186
{
177
- if ( string . Equals ( groupCondition . SensitivityLabels . OdataType , "#microsoft.graph.allScopeSensitivityLabels" , System . StringComparison . OrdinalIgnoreCase ) )
187
+ if ( string . Equals ( teamCondition . SensitivityLabels . OdataType , "#microsoft.graph.allScopeSensitivityLabels" , System . StringComparison . OrdinalIgnoreCase ) )
178
188
{
179
189
teamsAppPreApproval . TeamLevelSensitivityLabelCondition = MicrosoftGraphSensitivityLabelCondition . AnySensitivityLabel ;
180
190
}
181
- else if ( string . Equals ( groupCondition . SensitivityLabels . OdataType , "#microsoft.graph.enumeratedScopeSensitivityLabels" , System . StringComparison . OrdinalIgnoreCase ) )
191
+ else if ( string . Equals ( teamCondition . SensitivityLabels . OdataType , "#microsoft.graph.enumeratedScopeSensitivityLabels" , System . StringComparison . OrdinalIgnoreCase ) )
182
192
{
183
193
teamsAppPreApproval . TeamLevelSensitivityLabelCondition = MicrosoftGraphSensitivityLabelCondition . SpecificSensivityLabel ;
184
194
MGTeamsInternalEnumeratedScopeSensitivityLabels mGTeamsInternalEnumeratedScopeSensitivityLabels =
185
- groupCondition . SensitivityLabels as MGTeamsInternalEnumeratedScopeSensitivityLabels ;
195
+ teamCondition . SensitivityLabels as MGTeamsInternalEnumeratedScopeSensitivityLabels ;
186
196
teamsAppPreApproval . SpecificSensitivityLabelIdsApplicableToTeams = mGTeamsInternalEnumeratedScopeSensitivityLabels . SensitivityLabels . ToArray ( ) ;
187
197
}
188
198
else
189
199
{
190
200
throw new MGTeamsInternalException (
191
201
MGTeamsInternalErrorType . UnsupportedScenario ,
192
- $ "Unsupported team scope sensitivity label type '{ groupCondition . SensitivityLabels . OdataType } ' in preapproval policy '{ permissionGrantPreApprovalPolicy . Id } '.") ;
202
+ $ "Unsupported team scope sensitivity label type '{ teamCondition . SensitivityLabels . OdataType } ' in preapproval policy '{ permissionGrantPreApprovalPolicy . Id } '.") ;
193
203
}
194
204
195
205
MGTeamsInternalEnumeratedPreApprovedPermissions mGTeamsInternalEnumeratedPreApprovedPermissions =
196
- groupCondition . Permissions as MGTeamsInternalEnumeratedPreApprovedPermissions ;
206
+ teamCondition . Permissions as MGTeamsInternalEnumeratedPreApprovedPermissions ;
197
207
if ( mGTeamsInternalEnumeratedPreApprovedPermissions != null )
198
208
{
199
209
teamsAppPreApproval . ResourceSpecificApplicationPermissionsAllowedForTeams =
@@ -203,7 +213,7 @@ internal async Task<IMicrosoftGraphTeamsAppPreApproval> ConvertToTeamsAppPreAppr
203
213
{
204
214
throw new MGTeamsInternalException (
205
215
MGTeamsInternalErrorType . UnsupportedScenario ,
206
- $ "Unsupported permission type '{ groupCondition . Permissions . OdataType } ' in preapproval policy '{ permissionGrantPreApprovalPolicy . Id } '.") ;
216
+ $ "Unsupported permission type '{ teamCondition . Permissions . OdataType } ' in preapproval policy '{ permissionGrantPreApprovalPolicy . Id } '.") ;
207
217
}
208
218
}
209
219
0 commit comments