File tree Expand file tree Collapse file tree 2 files changed +72
-7
lines changed Expand file tree Collapse file tree 2 files changed +72
-7
lines changed Original file line number Diff line number Diff line change @@ -283,12 +283,22 @@ sub normalize_issue_url {
283
283
sub normalize_notification_type {
284
284
my ( $self , $data ) = @_ ;
285
285
if ( is_hashref($data ) ) {
286
- if ( is_hashref( $data -> {permission } )
287
- && is_arrayref( $data -> {permission }{co_maintainers } ) )
288
- {
289
- for ( reverse @{ $data -> {permission }{co_maintainers } } ) {
290
- if ( $_ =~ m / ^(NEEDHELP|ADOPTME|HANDOFF)$ / ) {
291
- return $_ ;
286
+ if ( is_hashref( $data -> {permission } ) ) {
287
+ my %special = (
288
+ NEEDHELP => 1,
289
+ ADOPTME => 1,
290
+ HANDOFF => 1
291
+ );
292
+ if ( defined $data -> {permission }{owner }
293
+ && exists $special { $data -> {permission }{owner } } )
294
+ {
295
+ return $data -> {permission }{owner };
296
+ }
297
+ elsif ( is_arrayref( $data -> {permission }{co_maintainers } ) ) {
298
+ for ( reverse @{ $data -> {permission }{co_maintainers } } ) {
299
+ if ( exists $special {$_ } ) {
300
+ return $_ ;
301
+ }
292
302
}
293
303
}
294
304
}
Original file line number Diff line number Diff line change @@ -185,12 +185,67 @@ subtest 'normalize_notification_type' => sub {
185
185
{
186
186
params => {
187
187
permission => {
188
+ owner => ' LNATION' ,
188
189
co_maintainers => [ ' ONE' , ' TWO' , ' THREE' , ' HANDOFF' ]
189
190
}
190
191
},
191
192
expected => ' HANDOFF' ,
192
193
message => ' HANDOFF passed in co_maintainers'
193
- }
194
+ },
195
+ {
196
+ params => {
197
+ permission => {
198
+ owner => ' '
199
+ }
200
+ },
201
+ expected => 0,
202
+ message => ' Null string as owner'
203
+ },
204
+ {
205
+ params => {
206
+ permission => {
207
+ owner => undef
208
+ }
209
+ },
210
+ expected => 0,
211
+ message => ' Undef as owner'
212
+ },
213
+ {
214
+ params => {
215
+ permission => {
216
+ owner => ' LNATION'
217
+ }
218
+ },
219
+ expected => 0,
220
+ message => ' LNATION as owner'
221
+ },
222
+ {
223
+ params => {
224
+ permission => {
225
+ owner => ' ADOPTME'
226
+ }
227
+ },
228
+ expected => ' ADOPTME' ,
229
+ message => ' ADOPTME passed as owner'
230
+ },
231
+ {
232
+ params => {
233
+ permission => {
234
+ owner => ' HANDOFF'
235
+ }
236
+ },
237
+ expected => ' HANDOFF' ,
238
+ message => ' HANDOFF passed as owner'
239
+ },
240
+ {
241
+ params => {
242
+ permission => {
243
+ owner => ' NEEDHELP'
244
+ }
245
+ },
246
+ expected => ' NEEDHELP' ,
247
+ message => ' NEEDHELP passed as owner'
248
+ },
194
249
);
195
250
196
251
for my $test (@tests ) {
You can’t perform that action at this time.
0 commit comments