@@ -9,6 +9,7 @@ import { IDatabaseRepository } from 'src/interfaces/database.interface';
9
9
import { DiscordChannel , IDiscordInterface } from 'src/interfaces/discord.interface' ;
10
10
import { IGithubInterface } from 'src/interfaces/github.interface' ;
11
11
import { IOutlineInterface } from 'src/interfaces/outline.interface' ;
12
+ import { FourthwallRepository } from 'src/repositories/fourthwall.repository' ;
12
13
import { formatCommand , logError , shorten } from 'src/util' ;
13
14
14
15
const PREVIEW_BLACKLIST = [ Constants . Urls . Immich , Constants . Urls . GitHub , Constants . Urls . MyImmich ] ;
@@ -58,6 +59,7 @@ export class DiscordService {
58
59
constructor (
59
60
@Inject ( IDatabaseRepository ) private database : IDatabaseRepository ,
60
61
@Inject ( IDiscordInterface ) private discord : IDiscordInterface ,
62
+ @Inject ( FourthwallRepository ) private fourthwall : FourthwallRepository ,
61
63
@Inject ( IGithubInterface ) private github : IGithubInterface ,
62
64
@Inject ( IOutlineInterface ) private outline : IOutlineInterface ,
63
65
) { }
@@ -464,4 +466,32 @@ export class DiscordService {
464
466
}
465
467
}
466
468
}
469
+
470
+ async updateFourthwallOrders ( id ?: string | null ) {
471
+ const {
472
+ fourthwall : { user, password } ,
473
+ } = getConfig ( ) ;
474
+
475
+ if ( id ) {
476
+ await this . updateOrder ( { id, user, password } ) ;
477
+ }
478
+
479
+ for await ( const { id } of this . database . streamFourthwallOrders ( ) ) {
480
+ await this . updateOrder ( { id, user, password } ) ;
481
+ }
482
+ }
483
+
484
+ private async updateOrder ( { id, user, password } : { id : string ; user : string ; password : string } ) {
485
+ const order = await this . fourthwall . getOrder ( { id, user, password } ) ;
486
+
487
+ await this . database . updateFourthwallOrder ( {
488
+ id,
489
+ discount : order . discount ,
490
+ status : order . status ,
491
+ total : order . totalPrice . value ,
492
+ profit : order . profit . value ,
493
+ shipping : order . currentAmounts . shipping . value ,
494
+ tax : order . currentAmounts . tax . value ,
495
+ } ) ;
496
+ }
467
497
}
0 commit comments