@@ -6,7 +6,7 @@ idrinth.raids = {
66 /**
77 * @type Object
88 */
9- private : { } ,
9+ private : { } ,
1010 /**
1111 * @type Object
1212 */
@@ -39,35 +39,36 @@ idrinth.raids = {
3939 * @param {string } responseText
4040 * @returns {undefined }
4141 */
42- function ( responseText ) {
43- var delHandler = function ( key ) {
44- if ( key in idrinth . raids . list ) {
45- delete idrinth . raids . list [ key ] ;
46- }
47- if ( key in idrinth . raids . joined ) {
48- delete idrinth . raids . joined [ key ] ;
49- }
50- if ( document . getElementById ( 'idrinth-raid-link-' + key ) ) {
51- idrinth . ui . removeElement ( 'idrinth-raid-link-' + key ) ;
52- }
53- } ;
54- var list = JSON . parse ( responseText ) ;
55- for ( var key in list ) {
56- if ( list [ key ] . delete ) {
57- delHandler ( key ) ;
58- } else {
59- //worst case: overwriting itself
60- idrinth . raids . list [ key ] = list [ key ] ;
61- }
62- }
63- } ,
64- function ( ) {
65- } ,
66- function ( ) {
67- } ,
68- idrinth . raids . knowRaids ( )
69- ) ;
70- } ,
42+ function ( responseText ) {
43+ var delHandler = function ( key ) {
44+ if ( key in idrinth . raids . list ) {
45+ delete idrinth . raids . list [ key ] ;
46+ }
47+ if ( key in idrinth . raids . joined ) {
48+ delete idrinth . raids . joined [ key ] ;
49+ }
50+ if ( document . getElementById ( 'idrinth-raid-link-' + key ) ) {
51+ idrinth . ui . removeElement ( 'idrinth-raid-link-' + key ) ;
52+ }
53+ } ;
54+ var list = JSON . parse ( responseText ) ;
55+ for ( var key in list ) {
56+ if ( list [ key ] . delete ) {
57+ delHandler ( key ) ;
58+ } else {
59+ //worst case: overwriting itself
60+ list [ key ] . private = idrinth . raids . list [ key ] && idrinth . raids . list [ key ] . private ;
61+ idrinth . raids . list [ key ] = list [ key ] ;
62+ }
63+ }
64+ } ,
65+ function ( ) {
66+ } ,
67+ function ( ) {
68+ } ,
69+ idrinth . raids . knowRaids ( )
70+ ) ;
71+ } ,
7172 /**
7273 *
7374 * @returns {String }
@@ -282,11 +283,11 @@ idrinth.raids = {
282283 * @param {String } key
283284 * @returns {Function }
284285 */
285- var byMessage = function ( key ) {
286+ var byMessage = function ( key ) {
286287 idrinth . inframe . send (
287288 'joinRaid' ,
288- ( idrinth . raids . join . getServerLink ( key ) ) . replace ( / ^ .* r a i d j o i n \. p h p / , 'raidjoin.php' )
289- ) ;
289+ ( idrinth . raids . join . getServerLink ( key ) ) . replace ( / ^ .* r a i d j o i n \. p h p / , 'raidjoin.php' )
290+ ) ;
290291 idrinth . raids . join . messages . trying ( key ) ;
291292 } ;
292293 /**
@@ -319,7 +320,7 @@ idrinth.raids = {
319320 }
320321 } ;
321322 var options = [ postLink ] ;
322- if ( idrinth . platform === 'armorgames' || idrinth . platform === 'kongregate' ) {
323+ if ( idrinth . platform === 'armorgames' || idrinth . platform === 'kongregate' ) {
323324 options . push ( byMessage ) ;
324325 }
325326 return options ;
@@ -345,9 +346,14 @@ idrinth.raids = {
345346 added ++ ;
346347 options [ 0 ] ( key ) ; //post link
347348 if (
348- ( ! idrinth . settings . get ( "bannedRaids#" + raid . raid ) && ! idrinth . settings . get ( "raidWhitelist" ) ) ||
349- ( idrinth . settings . get ( "bannedRaids#" + raid . raid ) && idrinth . settings . get ( "raidWhitelist" ) )
350- ) {
349+ (
350+ ( ! idrinth . settings . get ( "bannedRaids#" + raid . raid ) && ! idrinth . settings . get ( "raidWhitelist" ) ) ||
351+ ( idrinth . settings . get ( "bannedRaids#" + raid . raid ) && idrinth . settings . get ( "raidWhitelist" ) )
352+ ) && (
353+ ! raid . private ||
354+ idrinth . settings . get ( 'raid#joinPrivate' )
355+ )
356+ ) {
351357 for ( var count = 1 ; count < options . length ; count ++ ) {
352358 options [ count ] ( key ) ;
353359 }
@@ -371,41 +377,47 @@ idrinth.raids = {
371377 * requests information for raids caught from a third party(chat for example)
372378 * @returns {undefined }
373379 */
374- var handlePrivates = function ( ) {
380+ var handlePrivates = function ( ) {
375381 /**
376382 *
377383 * @param {String } reply
378384 * @returns {undefined }
379385 */
380- var handle = function ( reply ) {
381- if ( ! reply ) {
386+ var handle = function ( reply ) {
387+ if ( ! reply ) {
382388 return ;
383389 }
384- reply = JSON . parse ( reply ) ;
385- if ( ! reply ) {
390+ reply = JSON . parse ( reply ) ;
391+ if ( ! reply ) {
386392 return ;
387393 }
388- if ( ! reply . hasOwnProperty ( 'delete' ) ) {
394+ if ( ! reply . hasOwnProperty ( 'delete' ) ) {
389395 idrinth . raids . list [ reply . aid ] = reply ;
396+ idrinth . raids . list [ reply . aid ] . private = true ;
390397 }
391- try {
398+ try {
392399 delete idrinth . raids . private [ reply . raidId ] ;
393- } catch ( e ) {
394- idrinth . core . log ( e . getMessage ? e . getMessage ( ) : e . message ) ;
400+ } catch ( e ) {
401+ idrinth . core . log ( e . getMessage ? e . getMessage ( ) : e . message ) ;
395402 }
396403 } ;
397- for ( var raidId in idrinth . raids . private ) {
398- idrinth . core . ajax . runHome (
399- 'get-raid-service/' + raidId + '/' + idrinth . raids . private [ raidId ] + '/' ,
400- handle
401- ) ;
404+ if ( ! idrinth . settings . get ( 'raid#requestPrivate' ) ) {
405+ return ;
406+ }
407+ for ( var raidId in idrinth . raids . private ) {
408+ if ( idrinth . raids . private . hasOwnProperty ( raidId ) ) {
409+ idrinth . core . ajax . runHome (
410+ 'get-raid-service/' + raidId + '/' + idrinth . raids . private [ raidId ] + '/' ,
411+ handle
412+ ) ;
413+ }
402414 }
403415 } ;
404416 if ( ! join ( ) && Date . now ( ) - 60000 > idrinth . raids . requested ) {
405417 idrinth . raids . requested = Date . now ( ) ;
406418 idrinth . raids . import ( idrinth . settings . get ( "raids" ) ? idrinth . settings . get ( "favs" ) : '-1' ) ;
407419 }
408- handlePrivates ( ) ;
420+ handlePrivates ( ) ;
409421 }
410422 } ,
411423 /**
0 commit comments