twitchdev / twitch-cli

The official Twitch CLI to make developing on Twitch easier.
Apache License 2.0
604 stars 71 forks source link

channel.charity_campaign.donate is Missing some keys #263

Closed MrSnifo closed 1 year ago

MrSnifo commented 1 year ago

What is the problem?

Missing keys: charity_description, charity_logo

Operating System

Windows 10

Architecture Version (x86, x64, arm, etc)

x64

Steps to reproduce

twitch event trigger channel.charity_campaign.donate --transport=websocket

Relevant log output

{
   "subscription":{
      "id":"13379853-d3ac-ddbe-4b96-2b0c977ceb4b",
      "status":"enabled",
      "type":"channel.charity_campaign.donate",
      "version":"1",
      "condition":{
         "broadcaster_user_id":"165867"
      },
      "transport":{
         "method":"websocket",
         "session_id":"WebSocket-Server-Will-Set"
      },
      "created_at":"2023-08-18T02:00:22.8841704Z",
      "cost":0
   },
   "event":{
      "amount":{
         "currency":"USD",
         "decimal_places":2,
         "value":10000
      },
      "broadcaster_user_id":"165867",
      "broadcaster_user_login":"testBroadcaster",
      "broadcaster_user_name":"testBroadcaster",
      "campaign_id":"a6f1256a-850a-e53d-6651-29d48d912c40",
      "charity_logo":"https://abc.cloudfront.net/ppgf/1000/100.png",
      "charity_name":"Example Charity",
      "id":"33c47d90-ab37-3f05-f420-04a5f85ed6a8",
      "user_id":"36484237",
      "user_login":"testFromUser",
      "user_name":"testFromUser"
   }
}
Xemdo commented 1 year ago

I do see charity_logo in the payload (tested it locally too, to confirm) but I don't see charity_description or charity_website. I'll add those in ASAP.

This bug aside, I'm wondering why the session_id didn't set correctly in your example 🤔

Xemdo commented 1 year ago

Oh I'm dumb. Ignore my comment about session_id, I set it to that to tell people that the WebSocket will get the correct payload but the one printed to the console will not. Maybe I should change that to be more clear 😅

MrSnifo commented 1 year ago

is created_at or other datetimes always -1 hour ?

Xemdo commented 1 year ago

By default it is. You can change it with --timestamp

> twitch event trigger channel.charity_campaign.donate --timestamp=1999-12-31T23:59:59.0000Z
{
  "subscription": {
    "id": "9a1bde48-b26c-facf-d200-6269cf2c19a4",
    "status": "enabled",
    "type": "channel.charity_campaign.donate",
    "version": "1",
    "condition": {
      "broadcaster_user_id": "53988464"
    },
    "transport": {
      "method": "webhook",
      "callback": "null"
    },
    "created_at": "1999-12-31T23:59:59.0000Z",
    "cost": 0
  },
  "event": {
    "campaign_id": "960c7653-cb01-ee00-8fad-2ab12dd532c6",
    "id": "baf9bd8a-e5d9-08be-f7d5-190f949014e2",
    "broadcaster_user_id": "53988464",
    "broadcaster_user_name": "testBroadcaster",
    "broadcaster_user_login": "testBroadcaster",
    "user_id": "76564361",
    "user_name": "testFromUser",
    "user_login": "testFromUser",
    "charity_name": "Example Charity",
    "charity_logo": "https://abc.cloudfront.net/ppgf/1000/100.png",
    "amount": {
      "value": 10000,
      "decimal_places": 2,
      "currency": "USD"
    }
  }
}

It seems in production for EventSub WebSockets, created_at is the time the subscription is created. For default behavior I can set it to deliver the timestamp the server started (since all subscriptions are active by default). When using the --require-subscription flag, I can set it to the time that the subscription was actually created (since it mocks EventSub subscriptions properly). Feel free to make a feature request for those changes, or I can make it later when I get around to fixing the charity bug.