@@ -4,45 +4,45 @@ module.exports = function(controller, teamId) {
4
4
console . error ( `ERROR: could not delete team ${ teamId } :` , err ) ;
5
5
}
6
6
7
- controller . storage . feeds . find ( { teamId } , ( err , feeds ) => {
7
+ controller . storage . feeds . find ( { } , ( err , feeds ) => {
8
8
if ( err ) {
9
9
console . error ( `ERROR: could not find feeds for team ${ teamId } ` , err ) ;
10
10
}
11
11
12
12
feeds . forEach ( ( feed ) => {
13
- const { channelId } = feed ;
13
+ if ( feed . id . split ( '::' ) [ 0 ] === teamId ) {
14
+ controller . storage . feeds . delete ( feed . id , ( err ) => {
15
+ if ( err ) {
16
+ console . error ( `ERROR: could not delete feed ${ teamId } ::${ feed . id } :` , err ) ;
17
+ } else {
18
+ if ( process . env . ANALYTICS === 'TRUE' ) {
19
+ const pingFeedRequest = {
20
+ method : 'GET' ,
21
+ url : `${ process . env . FEEDPRESS_API_URL } /feeds/ping.json` ,
22
+ data : stringify ( {
23
+ feed : `${ teamId } -${ channelId } ` ,
24
+ } ) ,
25
+ params : {
26
+ key : process . env . FEEDPRESS_API_KEY ,
27
+ token : process . env . FEEDPRESS_API_TOKEN ,
28
+ feed : `${ teamId } -${ channelId } ` ,
29
+ } ,
30
+ } ;
14
31
15
- controller . storage . feeds . delete ( feed . id , ( err ) => {
16
- if ( err ) {
17
- console . error ( `ERROR: could not delete feed ${ teamId } ::${ feed . id } :` , err ) ;
18
- } else {
19
- if ( process . env . ANALYTICS === 'TRUE' ) {
20
- const pingFeedRequest = {
21
- method : 'GET' ,
22
- url : `${ process . env . FEEDPRESS_API_URL } /feeds/ping.json` ,
23
- data : stringify ( {
24
- feed : `${ teamId } -${ channelId } ` ,
25
- } ) ,
26
- params : {
27
- key : process . env . FEEDPRESS_API_KEY ,
28
- token : process . env . FEEDPRESS_API_TOKEN ,
29
- feed : `${ teamId } -${ channelId } ` ,
30
- } ,
31
- } ;
32
-
33
- axios ( pingFeedRequest )
34
- . then ( ( { data } ) => {
35
- if ( data . errors && data . errors . length ) {
36
- data . errors . forEach ( ( err ) => console . error ( 'ERROR:' , err ) ) ;
37
- }
38
- } )
39
- . catch ( ( error ) => {
40
- console . error ( 'ERROR: could not ping feed for refresh:' , error ) ;
41
- } )
42
- ;
32
+ axios ( pingFeedRequest )
33
+ . then ( ( { data } ) => {
34
+ if ( data . errors && data . errors . length ) {
35
+ data . errors . forEach ( ( err ) => console . error ( 'ERROR:' , err ) ) ;
36
+ }
37
+ } )
38
+ . catch ( ( error ) => {
39
+ console . error ( 'ERROR: could not ping feed for refresh:' , error ) ;
40
+ } )
41
+ ;
42
+ }
43
43
}
44
- }
45
- } )
44
+ } ) ;
45
+ }
46
46
} ) ;
47
47
} ) ;
48
48
0 commit comments