src/api/instagram.js
/**
     * Process the requests in the request buffer
     */
Process the requests in the request buffer
Process the requests in the request buffer
async processRequests() {
        await this.requestBufferLock.acquireAsync();
        let newApiRequest = false;
        for (const req of this.requestBuffer) {
            if (!this.matchURL(req.url())) {
                continue;
            }
            else {
                newApiRequest = true;
            }
            if (this.graft) {
                if (this.foundGraft === false) {
                    this.graftURL = req.url();
                    this.graftHeaders = req.headers();
                    this.foundGraft = true;
                    await req.abort();
                }
                else {
                    const overrides = {
                        headers: this.graftHeaders,
                        url: this.graftURL,
                    };
                    await this.executePlugins("request", req, overrides);
                    await req.continue(overrides);
                    this.graft = false;
                    this.foundGraft = false;
                    this.graftURL = null;
                    this.graftHeaders = null;
                }
                break;
            }
            else {
                const overrides = {};
                this.executePlugins("request", req, overrides);
                await req.continue(overrides);
            }
        }
        this.requestBuffer = [];
        this.requestBufferLock.release();
        if (this.foundGraft && newApiRequest) {
            console.log("Ignoring api error");
        }
    }
async processRequests ( ) { await this . requestBufferLock . acquireAsync ( ) ; let newApiRequest = false ; for ( const req of this . requestBuffer ) { if ( ! this . matchURL ( req . url ( ) ) ) { continue ; } else { newApiRequest = true ; } if ( this . graft ) { if ( this . foundGraft === false ) { this . graftURL = req . url ( ) ; this . graftHeaders = req . headers ( ) ; this . foundGraft = true ; await req . abort ( ) ; } else { const overrides = { headers : this . graftHeaders , url : this . graftURL , } ; await this . executePlugins ( "request" , req , overrides ) ; await req . continue ( overrides ) ; this . graft = false ; this . foundGraft = false ; this . graftURL = null ; this . graftHeaders = null ; } break ; } else { const overrides = { } ; this . executePlugins ( "request" , req , overrides ) ; await req . continue ( overrides ) ; } } this . requestBuffer = [ ] ; this . requestBufferLock . release ( ) ; if ( this . foundGraft && newApiRequest ) { console . log ( "Ignoring api error" ) ; } }
Process the requests in the request buffer
Process the requests in the request buffer
// Match url // Begin grafting if required, else continue the request // Gather details // Cancel request // Swap request // Reset grafting data // Stop reading requests // Clear buffer and release // Sometimes IG api falsely throws an error, we want to ignore that for now // tslint:disable-next-line:no-console