fix: get rid of top-level guild_id
key in dispatch payloads
This commit is contained in:
parent
a4a5f5c17a
commit
d28e99ba43
@ -42,7 +42,6 @@ namespace PluralKit.Core
|
||||
public DispatchEvent Event;
|
||||
public string SystemId;
|
||||
public string? EntityId;
|
||||
public ulong? GuildId;
|
||||
public string SigningToken;
|
||||
public JObject? EventData;
|
||||
}
|
||||
@ -57,7 +56,6 @@ namespace PluralKit.Core
|
||||
o.Add("signing_token", data.SigningToken);
|
||||
o.Add("system_id", data.SystemId);
|
||||
o.Add("id", data.EntityId);
|
||||
o.Add("guild_id", data.GuildId.ToString());
|
||||
o.Add("data", data.EventData);
|
||||
|
||||
return new StringContent(JsonConvert.SerializeObject(o), Encoding.UTF8, "application/json");
|
||||
|
@ -174,8 +174,7 @@ namespace PluralKit.Core
|
||||
data.Event = DispatchEvent.UPDATE_SYSTEM_GUILD;
|
||||
data.SigningToken = system.WebhookToken;
|
||||
data.SystemId = system.Uuid.ToString();
|
||||
data.GuildId = guild_id;
|
||||
data.EventData = patch.ToJson(memberRef);
|
||||
data.EventData = patch.ToJson(memberRef, guild_id);
|
||||
|
||||
_logger.Debug("Dispatching webhook for system {SystemId} in guild {GuildId}", system.Id, guild_id);
|
||||
await DoPostRequest(system.Id, system.WebhookUrl, data.GetPayloadBody());
|
||||
@ -194,8 +193,7 @@ namespace PluralKit.Core
|
||||
data.SigningToken = system.WebhookToken;
|
||||
data.SystemId = system.Uuid.ToString();
|
||||
data.EntityId = member.Uuid.ToString();
|
||||
data.GuildId = guild_id;
|
||||
data.EventData = patch.ToJson();
|
||||
data.EventData = patch.ToJson(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());
|
||||
|
@ -104,7 +104,7 @@ namespace PluralKit.Core
|
||||
{
|
||||
// todo: should this be moved to a different JSON model?
|
||||
o.Add("webhook_url", system.WebhookUrl);
|
||||
o.Add("webhook_token", system.WebhookToken);
|
||||
// o.Add("webhook_token", system.WebhookToken);
|
||||
|
||||
var p = new JObject();
|
||||
|
||||
|
@ -39,10 +39,12 @@ namespace PluralKit.Core
|
||||
return patch;
|
||||
}
|
||||
|
||||
public JObject ToJson()
|
||||
public JObject ToJson(ulong guild_id)
|
||||
{
|
||||
var o = new JObject();
|
||||
|
||||
o.Add("guild_id", guild_id.ToString());
|
||||
|
||||
if (DisplayName.IsPresent)
|
||||
o.Add("display_name", DisplayName.Value);
|
||||
|
||||
|
@ -56,10 +56,12 @@ namespace PluralKit.Core
|
||||
return patch;
|
||||
}
|
||||
|
||||
public JObject ToJson(string memberRef)
|
||||
public JObject ToJson(string memberRef, ulong guild_id)
|
||||
{
|
||||
var o = new JObject();
|
||||
|
||||
o.Add("guild_id", guild_id.ToString());
|
||||
|
||||
if (ProxyEnabled.IsPresent)
|
||||
o.Add("proxying_enabled", ProxyEnabled.Value);
|
||||
|
||||
|
@ -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|
|
||||
|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)|
|
||||
|guild_id|snowflake?*|the ID of the guild where this event occurred|
|
||||
|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
|
||||
|
||||
|name|description|content of `data` object|notes|
|
||||
|
@ -104,6 +104,7 @@ Every PluralKit entity has two IDs: a short (5-character) ID and a longer UUID.
|
||||
|
||||
|key|type|notes|
|
||||
|---|---|---|
|
||||
|guild_id|snowflake|only sent if the guild ID isn't already known (in dispatch payloads)|
|
||||
|proxying_enabled|boolean||
|
||||
|autoproxy_mode|autoproxy mode enum||
|
||||
|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|
|
||||
|---|---|---|
|
||||
|guild_id|snowflake|only sent if the guild ID isn't already known (in dispatch payloads)|
|
||||
|display_name|?string|100-character limit|
|
||||
|avatar_url|?string|256-character limit, must be a publicly-accessible URL|
|
||||
|
Loading…
Reference in New Issue
Block a user