// x-poster.controller.ts
import {Body, Controller, Get, Post} from '@nestjs/common';
import {CreateTweetDto} from './dto/create-tweet.dto';
import {XCookieAccountDto} from "./dto/x-cookie-account.dto";
import {XRouterService, XStrategy} from "./x-router.service";
import {XCookieService} from "./x-cookie.service";

@Controller('x-cookie')
export class XCookieController {
    constructor(
        private readonly service: XRouterService,
        private readonly xCookieService: XCookieService
    ) {
    }

    @Post('tweet')
    async tweet(
        @Body() tweet: CreateTweetDto,
    ) {
        const authToken = 'f5574950a0d98cf49ca2e574cc6a4139cc8a2d81';
        const ct0 = '75db96b40f4814925670722e3335840467b87c7eb403aab14fbe719297bf465347810f92dc2116c3d30f15153a332976c50d856983dfe19046d4f10413b3d1cd8bac6f7a99e5b03c6949bafdad0f01c0';
        return this.service.postTweet(
            {
                account: {
                    id: 'realflashkaze',
                    browser: {
                        accountId: 'realflashkaze',
                        cookies: [
                            {
                                name: "ct0",
                                value: '75db96b40f4814925670722e3335840467b87c7eb403aab14fbe719297bf465347810f92dc2116c3d30f15153a332976c50d856983dfe19046d4f10413b3d1cd8bac6f7a99e5b03c6949bafdad0f01c0'
                            },
                            {
                                name: "auth_token",
                                value: 'f5574950a0d98cf49ca2e574cc6a4139cc8a2d81'
                            },
                            {name: "dnt", value: "1"},
                            {name: "lang", value: "en"},
                            {name: "twid", value: "u%3D2043937828644536320"},
                        ]
                    }
                },
                text: tweet.text,
                strategy: XStrategy.BROWSER_ONLY
            });
    }

    @Get('verify')
    verify() {
        return this.xCookieService.verifyCookie();
        // return this.xCookieService.verifyCookie('UserByScreenName');
    }
}
