Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Twitter Labs filter stream v1 support #127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

btruhand
Copy link

I found the new Twitter Labs filter stream (https://developer.twitter.com/en/docs/labs/filtered-stream/overview) to be more fitting for my use case so I decided to add it as several new function API calls

In detail:

  • added API calls for adding, deleting and getting filter stream rules
  • added stream API call
  • added appropriate types
  • attempted to stick with current code and exporting structure

When I tried to run the tests there are some tests that failed, but doesn't seem to be related to the additions/changes I made:

 FAIL  test/twitter.test.js (9.835s)
  ● rate limits › should get rate limited

    TypeError: Cannot read property '0' of undefined

      141 |           await client.get('help/configuration');
      142 |       } catch (e) {
    > 143 |         expect(e.errors[0]).toHaveProperty('code', 88); // Rate limit exceeded
          |                ^
      144 |         expect(e._headers).toHaveProperty('x-rate-limit-remaining', ['0']);
      145 |       }
      146 |     },

      at Object.<anonymous> (test/twitter.test.js:143:16)

  ● rate limits › should get rate limited

    expect.assertions(4)

    Expected four assertions to be called but received two assertion calls.

      132 |         const response = await client.get('help/configuration');
      133 |         // Since this didn't throw, we'll be running 2 more assertions below
    > 134 |         expect.assertions(4);
          |                ^
      135 |         expect(response).toHaveProperty('photo_sizes');
      136 |         expect(response._headers).toHaveProperty('x-rate-limit-limit', ['15']);
      137 |         let [remaining] = response._headers['x-rate-limit-remaining'];

      at Object.<anonymous> (test/twitter.test.js:134:16)

  ● putting › can update welcome message

    Failed: Object {
      "_headers": Headers {
        Symbol(map): Object {
          "cache-control": [Array],
          "connection": [Array],
          "content-disposition": [Array],
          "content-encoding": [Array],
          "content-length": [Array],
          "content-type": [Array],
          "date": [Array],
          "expires": [Array],
          "last-modified": [Array],
          "pragma": [Array],
          "server": [Array],
          "set-cookie": [Array],
          "status": [Array],
          "strict-transport-security": [Array],
          "x-access-level": [Array],
          "x-connection-hash": [Array],
          "x-content-type-options": [Array],
          "x-frame-options": [Array],
          "x-response-time": [Array],
          "x-transaction": [Array],
          "x-tsa-request-body-time": [Array],
          "x-twitter-response-tags": [Array],
          "x-xss-protection": [Array],
        },
      },
      "errors": Array [
        Object {
          "code": 214,
          "message": "owner must allow dms from anyone",
        },
      ],
    }

      247 |    * and your demo app needs to have access to read, write, and direct messages.
      248 |    */
    > 249 |   it('can update welcome message', async () => {
          |   ^
      250 |     const newWelcomeMessage = await client.post(
      251 |       'direct_messages/welcome_messages/new',
      252 |       {

      at Env.it (node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:89:24)
      at Suite.<anonymous> (test/twitter.test.js:249:3)
      at Object.<anonymous> (test/twitter.test.js:242:1)

I didn't make tests for the filter stream API call itself since I used the current Stream class, but tell me if you want me to still add tests for them (or try to at least test for the query parameters properly being created etc.)

@Cooya
Copy link

Cooya commented Jul 26, 2020

I need it as well, I hope it's going to be merged.
Good job @btruhand !

@peterpme
Copy link
Contributor

We'll merge this, thanks :)

@btruhand
Copy link
Author

@peterpme I didn't make documentation changes on the README, would you like me to do that?

@peterpme
Copy link
Contributor

Yes please, thank you!!! Sorry for the delay

In detail:

- added API calls for adding, deleting and getting filter stream rules
- added stream API call
- added appropriate types
- attempted to stick with current code and exporting structure
- updated README
@btruhand
Copy link
Author

btruhand commented Aug 1, 2020

@peterpme been busy, but just pushed the updated README :)

@peterpme
Copy link
Contributor

Hey @btruhand wow this is amazing, thank you so much! are you ready for this to be merged in?

@btruhand
Copy link
Author

btruhand commented Aug 20, 2020

@peterpme absolutely. From my end there is nothing else I'd like to do, merge whenever you are comfortable with it. I hope it can help pave the way for others to add more Twitter Labs functionalities

Edit: Oh just to make sure, I didn't add to the github workflows pipeline to run the twitter labs related tests (since it uses a different command name). I think I'll leave that to you to decide on when to add it since you will have to opt in to the Twitter Labs functionality

@btruhand
Copy link
Author

btruhand commented Sep 6, 2020

@peterpme hey peter, just noticed recently that Twitter announced official v2 API for filter stream: https://developer.twitter.com/en/docs/labs/filtered-stream/overview. It's a bit different but would make this PR ineffective

I'll try to find time to modify the PR in the upcoming month or so. Tell me if you want me to remove or retain the withLabs addition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants