@@ -5,14 +5,6 @@ import { dayjs, timezone } from '@sogebot/ui-helpers/dayjsHelper';
55import { getTime } from '@sogebot/ui-helpers/getTime' ;
66import { capitalize } from 'lodash' ;
77
8- import {
9- command , default_permission , example , persistent , settings ,
10- } from '../decorators' ;
11- import { onChange , onLoad , onStartup , onStreamStart } from '../decorators/on' ;
12- import Expects from '../expects' ;
13- import emitter from '../helpers/interfaceEmitter' ;
14- import { debug , error , info } from '../helpers/log' ;
15- import users from '../users' ;
168import Service from './_interface' ;
179import { init as apiIntervalInit , stop as apiIntervalStop } from './twitch/api/interval' ;
1810import { createClip } from './twitch/calls/createClip' ;
@@ -22,6 +14,14 @@ import EventSub from './twitch/eventsub';
2214import PubSub from './twitch/pubsub' ;
2315import { cleanErrors } from './twitch/token/refresh' ;
2416import { cache , validate } from './twitch/token/validate' ;
17+ import {
18+ command , default_permission , example , persistent , settings ,
19+ } from '../decorators' ;
20+ import { onChange , onLoad , onStartup , onStreamStart } from '../decorators/on' ;
21+ import Expects from '../expects' ;
22+ import emitter from '../helpers/interfaceEmitter' ;
23+ import { debug , error , info } from '../helpers/log' ;
24+ import users from '../users' ;
2525
2626import { AppDataSource } from '~/database' ;
2727import {
@@ -387,8 +387,23 @@ class Twitch extends Service {
387387 emitter . emit ( 'set' , '/services/twitch' , `tokenService` , 'SogeBot Token Generator v2' ) ;
388388 emitter . emit ( 'set' , '/services/twitch' , `${ accountType } RefreshToken` , refreshToken ) ;
389389 emitter . emit ( 'set' , '/services/twitch' , `${ accountType } AccessToken` , accessToken ) ;
390- await validate ( accountType ) ;
391- cb ( null ) ;
390+ emitter . emit ( 'set' , '/services/twitch' , `${ accountType } TokenValid` , true ) ;
391+ await validate ( accountType , 0 , true ) ;
392+ setTimeout ( async ( ) => {
393+ cb ( null ) ;
394+ } , 1000 ) ;
395+ } ) ;
396+ adminEndpoint ( '/services/twitch' , 'twitch::token::ownApp' , async ( { accessToken, refreshToken, accountType, clientId, clientSecret } , cb ) => {
397+ emitter . emit ( 'set' , '/services/twitch' , `tokenService` , 'Own Twitch App' ) ;
398+ emitter . emit ( 'set' , '/services/twitch' , `${ accountType } AccessToken` , accessToken ) ;
399+ emitter . emit ( 'set' , '/services/twitch' , `${ accountType } RefreshToken` , refreshToken ) ;
400+ emitter . emit ( 'set' , '/services/twitch' , `tokenServiceCustomClientId` , clientId ) ;
401+ emitter . emit ( 'set' , '/services/twitch' , `tokenServiceCustomClientSecret` , clientSecret ) ;
402+ emitter . emit ( 'set' , '/services/twitch' , `${ accountType } TokenValid` , true ) ;
403+ await validate ( accountType , 0 , true ) ;
404+ setTimeout ( async ( ) => {
405+ cb ( null ) ;
406+ } , 1000 ) ;
392407 } ) ;
393408 }
394409
0 commit comments