fix: get rid of top-level guild_id key in dispatch payloads

This commit is contained in:
spiral 2021-11-26 14:45:58 -05:00
parent a4a5f5c17a
commit d28e99ba43
No known key found for this signature in database
GPG Key ID: A6059F0CA0E1BD31
7 changed files with 11 additions and 12 deletions

View File

@ -42,7 +42,6 @@ namespace PluralKit.Core
public DispatchEvent Event; public DispatchEvent Event;
public string SystemId; public string SystemId;
public string? EntityId; public string? EntityId;
public ulong? GuildId;
public string SigningToken; public string SigningToken;
public JObject? EventData; public JObject? EventData;
} }
@ -57,7 +56,6 @@ namespace PluralKit.Core
o.Add("signing_token", data.SigningToken); o.Add("signing_token", data.SigningToken);
o.Add("system_id", data.SystemId); o.Add("system_id", data.SystemId);
o.Add("id", data.EntityId); o.Add("id", data.EntityId);
o.Add("guild_id", data.GuildId.ToString());
o.Add("data", data.EventData); o.Add("data", data.EventData);
return new StringContent(JsonConvert.SerializeObject(o), Encoding.UTF8, "application/json"); return new StringContent(JsonConvert.SerializeObject(o), Encoding.UTF8, "application/json");

View File

@ -174,8 +174,7 @@ namespace PluralKit.Core
data.Event = DispatchEvent.UPDATE_SYSTEM_GUILD; data.Event = DispatchEvent.UPDATE_SYSTEM_GUILD;
data.SigningToken = system.WebhookToken; data.SigningToken = system.WebhookToken;
data.SystemId = system.Uuid.ToString(); data.SystemId = system.Uuid.ToString();
data.GuildId = guild_id; data.EventData = patch.ToJson(memberRef, guild_id);
data.EventData = patch.ToJson(memberRef);
_logger.Debug("Dispatching webhook for system {SystemId} in guild {GuildId}", system.Id, guild_id); _logger.Debug("Dispatching webhook for system {SystemId} in guild {GuildId}", system.Id, guild_id);
await DoPostRequest(system.Id, system.WebhookUrl, data.GetPayloadBody()); await DoPostRequest(system.Id, system.WebhookUrl, data.GetPayloadBody());
@ -194,8 +193,7 @@ namespace PluralKit.Core
data.SigningToken = system.WebhookToken; data.SigningToken = system.WebhookToken;
data.SystemId = system.Uuid.ToString(); data.SystemId = system.Uuid.ToString();
data.EntityId = member.Uuid.ToString(); data.EntityId = member.Uuid.ToString();
data.GuildId = guild_id; data.EventData = patch.ToJson(guild_id);
data.EventData = patch.ToJson();
_logger.Debug("Dispatching webhook for member {MemberId} (system {SystemId}) in guild {GuildId}", member.Id, system.Id, guild_id); _logger.Debug("Dispatching webhook for member {MemberId} (system {SystemId}) in guild {GuildId}", member.Id, system.Id, guild_id);
await DoPostRequest(system.Id, system.WebhookUrl, data.GetPayloadBody()); await DoPostRequest(system.Id, system.WebhookUrl, data.GetPayloadBody());

View File

@ -104,7 +104,7 @@ namespace PluralKit.Core
{ {
// todo: should this be moved to a different JSON model? // todo: should this be moved to a different JSON model?
o.Add("webhook_url", system.WebhookUrl); o.Add("webhook_url", system.WebhookUrl);
o.Add("webhook_token", system.WebhookToken); // o.Add("webhook_token", system.WebhookToken);
var p = new JObject(); var p = new JObject();

View File

@ -39,10 +39,12 @@ namespace PluralKit.Core
return patch; return patch;
} }
public JObject ToJson() public JObject ToJson(ulong guild_id)
{ {
var o = new JObject(); var o = new JObject();
o.Add("guild_id", guild_id.ToString());
if (DisplayName.IsPresent) if (DisplayName.IsPresent)
o.Add("display_name", DisplayName.Value); o.Add("display_name", DisplayName.Value);

View File

@ -56,10 +56,12 @@ namespace PluralKit.Core
return patch; return patch;
} }
public JObject ToJson(string memberRef) public JObject ToJson(string memberRef, ulong guild_id)
{ {
var o = new JObject(); var o = new JObject();
o.Add("guild_id", guild_id.ToString());
if (ProxyEnabled.IsPresent) if (ProxyEnabled.IsPresent)
o.Add("proxying_enabled", ProxyEnabled.Value); o.Add("proxying_enabled", ProxyEnabled.Value);

View File

@ -29,11 +29,8 @@ PluralKit will send invalid requests to your endpoint, with `PING` event type, o
|signing_token|string|the [signing token](#security) for your webhook URL| |signing_token|string|the [signing token](#security) for your webhook URL|
|system_id|string|the system ID associated with this event| |system_id|string|the system ID associated with this event|
|id|string?|the ID of the entity referenced by the event (can be a system/member/group/switch/Discord user ID)| |id|string?|the ID of the entity referenced by the event (can be a system/member/group/switch/Discord user ID)|
|guild_id|snowflake?*|the ID of the guild where this event occurred|
|data|object?|event data| |data|object?|event data|
\* only sent for guild settings update events. in message create events, the guild id is sent in the `data` object as `guild` key
## Dispatch Events ## Dispatch Events
|name|description|content of `data` object|notes| |name|description|content of `data` object|notes|

View File

@ -104,6 +104,7 @@ Every PluralKit entity has two IDs: a short (5-character) ID and a longer UUID.
|key|type|notes| |key|type|notes|
|---|---|---| |---|---|---|
|guild_id|snowflake|only sent if the guild ID isn't already known (in dispatch payloads)|
|proxying_enabled|boolean|| |proxying_enabled|boolean||
|autoproxy_mode|autoproxy mode enum|| |autoproxy_mode|autoproxy mode enum||
|autoproxy_member|?string|must be set if autoproxy_mode is `member`| |autoproxy_member|?string|must be set if autoproxy_mode is `member`|
@ -123,5 +124,6 @@ Every PluralKit entity has two IDs: a short (5-character) ID and a longer UUID.
|key|type|notes| |key|type|notes|
|---|---|---| |---|---|---|
|guild_id|snowflake|only sent if the guild ID isn't already known (in dispatch payloads)|
|display_name|?string|100-character limit| |display_name|?string|100-character limit|
|avatar_url|?string|256-character limit, must be a publicly-accessible URL| |avatar_url|?string|256-character limit, must be a publicly-accessible URL|