lib/fetching/channels/crowdtangle.js
/**
     * Annotates a post with the CrowdTangle List or Saved Search from whence it came.
     */
Annotates a post with the CrowdTangle List or Saved Search from whence it came.
Annotates a post with the CrowdTangle List or Saved Search from whence it came .
addCrowdTangleTags(post) {
        let crowdtangleTags;
        const {
            crowdtangle_saved_searches: savedSearches,
            crowdtangle_list_account_pairs: listAccountPairs
        } = this.listPair;
        const { raw } = post;
        const accountId = raw.account.id;
        if (listAccountPairs[accountId]) {
            crowdtangleTags = listAccountPairs[accountId];
        } else if (this.savedSearchToggle) {
            crowdtangleTags = [];
            for (const savedSearchId in savedSearches) {
                const savedSearch = savedSearches[savedSearchId];
                const doesMatch = this.doesPostMatchWords(post, savedSearch.words);
                if (doesMatch) crowdtangleTags.push(savedSearch.name);
            }
            if (crowdtangleTags.length === 0) {
                crowdtangleTags.push('Saved Search');
            }
        } else {
            crowdtangleTags = accountId;
        }
        raw.crowdtangleTags = crowdtangleTags;
    }
addCrowdTangleTags ( post ) { let crowdtangleTags ; const { crowdtangle_saved_searches : savedSearches , crowdtangle_list_account_pairs : listAccountPairs } = this . listPair ; const { raw } = post ; const accountId = raw . account . id ; if ( listAccountPairs [ accountId ] ) { crowdtangleTags = listAccountPairs [ accountId ] ; } else if ( this . savedSearchToggle ) { crowdtangleTags = [ ] ; for ( const savedSearchId in savedSearches ) { const savedSearch = savedSearches [ savedSearchId ] ; const doesMatch = this . doesPostMatchWords ( post , savedSearch . words ) ; if ( doesMatch ) crowdtangleTags . push ( savedSearch . name ) ; } if ( crowdtangleTags . length === 0 ) { crowdtangleTags . push ( 'Saved Search' ) ; } } else { crowdtangleTags = accountId ; } raw . crowdtangleTags = crowdtangleTags ; }
Annotates a post with the CrowdTangle List or Saved Search from whence it came.
Annotates a post with the CrowdTangle List or Saved Search from whence it came .
// This is a workaround to identify possible saved search names associated with a post using substring search. // We plan to remove this workaround when CT adds list IDs/account IDs to saved search API responses. // if no matches are found, then add default "Saved Search" tag. // If the list is not found and not matched, make the ct_tag the account.id so we can identify it later.