Skip to content

Commit fcbb753

Browse files
committed
feat(gencodecs): add support for 'reason' fields
Support X-Audit-Log-Reason by adding a reason field to each request that may accept reason for action
1 parent c3716b9 commit fcbb753

10 files changed

+243
-8
lines changed

Doxyfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ TAB_SIZE = 4
263263

264264
ALIASES += "CCORD_ret{1}=@param \1 return context of the request. if successful the assigned `done` will be triggered @see @ref discord_ret for more options^^" \
265265
"CCORD_ret_obj{2}=@param \1 return context of the request. if successful a @ref discord_\2 will be sent over to its assigned `done` callback @see @ref discord_ret_\2 for more options^^" \
266-
"CCORD_return=@return @ref CCORDcode value for how the operation went:^^ - `0` means nothing out of the ordinary^^ - `greater than zero` means a change of state^^ - `lesser than zero` means an error has occurred^^" \
266+
"CCORD_reason{1}=@param \1 a `reason` to indicate why the action was taken^^" \
267+
"CCORD_return=@return @ref CCORDcode value for how the operation went, @ref CCORD_OK means nothing out of the ordinary^^" \
267268
"CCORD_pub_struct{1}=**Public methods**^^^^ - Initializer:^^^^ - `\1_init(struct \1 *this)`^^ - Cleanup:^^^^ - `\1_cleanup(struct \1 *this)`^^ - JSON Decoder:^^^^ - `\1_from_json(const char json[], size_t len, struct \1 *this)`^^ - `\1_from_jsmnf(jsmnf *root, const char json[], struct \1 *this)`^^ - JSON Encoder:^^^^ - `\1_to_json(char buf[], size_t size, const struct \1 *this)`^^ - `\1_to_jsonb(jsonb *b, char buf[], size_t size, const struct \1 *this)`" \
268269
"CCORD_pub_list{1}=**Public methods**^^^^ - Cleanup:^^^^ - `\1_cleanup(struct \1 *this)`^^ - JSON Decoder:^^^^ - `\1_from_json(const char json[], size_t len, struct \1 *this)`^^ - `\1_from_jsmnf(jsmnf *root, const char json[], struct \1 *this)`^^ - JSON Encoder:^^^^ - `\1_to_json(char buf[], size_t size, const struct \1 *this)`^^ - `\1_to_jsonb(jsonb *b, char buf[], size_t size, const struct \1 *this)`"
269270

gencodecs/api/auto_moderation.PRE.h

+17
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ LIST_END
160160
/** @CCORD_pub_struct{discord_create_auto_moderation_rule} */
161161
#if GENCODECS_RECIPE & (DATA | JSON)
162162
PUB_STRUCT(discord_create_auto_moderation_rule)
163+
/** @CCORD_reason{reason} */
164+
#if GENCODECS_RECIPE == DATA
165+
FIELD_PTR(reason, char, *)
166+
#endif
163167
/** the rule name */
164168
FIELD_PTR(name, char, *)
165169
/** the rule event type */
@@ -194,8 +198,14 @@ STRUCT_END
194198
/** @CCORD_pub_struct{discord_modify_auto_moderation_rule} */
195199
#if GENCODECS_RECIPE & (DATA | JSON)
196200
PUB_STRUCT(discord_modify_auto_moderation_rule)
201+
/** @CCORD_reason{reason} */
202+
#if GENCODECS_RECIPE == DATA
203+
FIELD_PTR(reason, char, *)
204+
#endif
197205
/** the rule name */
206+
COND_WRITE(self->name != NULL)
198207
FIELD_PTR(name, char, *)
208+
COND_END
199209
/** the rule event type */
200210
COND_WRITE(self->event_type != 0)
201211
FIELD_ENUM(event_type, discord_auto_moderation_event_types)
@@ -220,3 +230,10 @@ PUB_STRUCT(discord_modify_auto_moderation_rule)
220230
COND_END
221231
STRUCT_END
222232
#endif
233+
234+
#if GENCODECS_RECIPE == DATA
235+
STRUCT(discord_delete_auto_moderation_rule)
236+
/** @CCORD_reason{reason} */
237+
FIELD_PTR(reason, char, *)
238+
STRUCT_END
239+
#endif

gencodecs/api/channel.PRE.h

+61-2
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,10 @@ STRUCT_END
672672
/** @CCORD_pub_struct{discord_modify_channel} */
673673
#if GENCODECS_RECIPE & (DATA | JSON)
674674
PUB_STRUCT(discord_modify_channel)
675+
/** @CCORD_reason{reason} */
676+
#if GENCODECS_RECIPE == DATA
677+
FIELD_PTR(reason, char, *)
678+
#endif
675679
/** 1-100 character channel name */
676680
FIELD_PTR(name, char, *)
677681
/* GROUP DM */
@@ -741,7 +745,14 @@ STRUCT_END
741745
#endif
742746

743747
#if GENCODECS_RECIPE == DATA
744-
PUB_STRUCT(discord_get_channel_messages)
748+
STRUCT(discord_delete_channel)
749+
/** @CCORD_reason{reason} */
750+
FIELD_PTR(reason, char, *)
751+
STRUCT_END
752+
#endif
753+
754+
#if GENCODECS_RECIPE == DATA
755+
STRUCT(discord_get_channel_messages)
745756
/** get messages around this message ID */
746757
COND_WRITE(self->around != 0)
747758
FIELD_SNOWFLAKE(around)
@@ -799,7 +810,7 @@ STRUCT_END
799810
#endif
800811

801812
#if GENCODECS_RECIPE == DATA
802-
PUB_STRUCT(discord_get_reactions)
813+
STRUCT(discord_get_reactions)
803814
/** get users after this user ID */
804815
COND_WRITE(self->after != 0)
805816
FIELD_SNOWFLAKE(after)
@@ -838,9 +849,20 @@ PUB_STRUCT(discord_edit_message)
838849
STRUCT_END
839850
#endif
840851

852+
#if GENCODECS_RECIPE == DATA
853+
STRUCT(discord_delete_message)
854+
/** @CCORD_reason{reason} */
855+
FIELD_PTR(reason, char, *)
856+
STRUCT_END
857+
#endif
858+
841859
/** @CCORD_pub_struct{discord_bulk_delete_messages} */
842860
#if GENCODECS_RECIPE & (DATA | JSON)
843861
PUB_STRUCT(discord_bulk_delete_messages)
862+
/** @CCORD_reason{reason} */
863+
#if GENCODECS_RECIPE == DATA
864+
FIELD_PTR(reason, char, *)
865+
#endif
844866
/** an array of message ids to delete (2-100) */
845867
FIELD_STRUCT_PTR(messages, snowflakes, *)
846868
STRUCT_END
@@ -849,6 +871,10 @@ STRUCT_END
849871
/** @CCORD_pub_struct{discord_edit_channel_permissions} */
850872
#if GENCODECS_RECIPE & (DATA | JSON)
851873
PUB_STRUCT(discord_edit_channel_permissions)
874+
/** @CCORD_reason{reason} */
875+
#if GENCODECS_RECIPE == DATA
876+
FIELD_PTR(reason, char, *)
877+
#endif
852878
/** the bitwise value of all allowed permissions (default \"0\")
853879
@see @ref DiscordPermissions */
854880
COND_WRITE(self->allow != 0)
@@ -867,6 +893,10 @@ STRUCT_END
867893
/** @CCORD_pub_struct{discord_create_channel_invite} */
868894
#if GENCODECS_RECIPE & (DATA | JSON)
869895
PUB_STRUCT(discord_create_channel_invite)
896+
/** @CCORD_reason{reason} */
897+
#if GENCODECS_RECIPE == DATA
898+
FIELD_PTR(reason, char, *)
899+
#endif
870900
/** duration of invite in seconds before expiry, or 0 for never. between
871901
0 and 604800 (7 days) */
872902
COND_WRITE(self->max_age != 0)
@@ -902,6 +932,13 @@ PUB_STRUCT(discord_create_channel_invite)
902932
STRUCT_END
903933
#endif
904934

935+
#if GENCODECS_RECIPE == DATA
936+
STRUCT(discord_delete_channel_permission)
937+
/** @CCORD_reason{reason} */
938+
FIELD_PTR(reason, char, *)
939+
STRUCT_END
940+
#endif
941+
905942
/** @CCORD_pub_struct{discord_follow_news_channel} */
906943
#if GENCODECS_RECIPE & (DATA | JSON)
907944
PUB_STRUCT(discord_follow_news_channel)
@@ -912,6 +949,20 @@ PUB_STRUCT(discord_follow_news_channel)
912949
STRUCT_END
913950
#endif
914951

952+
#if GENCODECS_RECIPE == DATA
953+
STRUCT(discord_pin_message)
954+
/** @CCORD_reason{reason} */
955+
FIELD_PTR(reason, char, *)
956+
STRUCT_END
957+
#endif
958+
959+
#if GENCODECS_RECIPE == DATA
960+
STRUCT(discord_unpin_message)
961+
/** @CCORD_reason{reason} */
962+
FIELD_PTR(reason, char, *)
963+
STRUCT_END
964+
#endif
965+
915966
/** @CCORD_pub_struct{discord_group_dm_add_recipient} */
916967
#if GENCODECS_RECIPE & (DATA | JSON)
917968
PUB_STRUCT(discord_group_dm_add_recipient)
@@ -925,6 +976,10 @@ STRUCT_END
925976
/** @CCORD_pub_struct{discord_start_thread_with_message} */
926977
#if GENCODECS_RECIPE & (DATA | JSON)
927978
PUB_STRUCT(discord_start_thread_with_message)
979+
/** @CCORD_reason{reason} */
980+
#if GENCODECS_RECIPE == DATA
981+
FIELD_PTR(reason, char, *)
982+
#endif
928983
/** 1-100 character channel name */
929984
FIELD_PTR(name, char, *)
930985
/** duration in minutes to automatically archive the thread after recent
@@ -944,6 +999,10 @@ STRUCT_END
944999
/** @CCORD_pub_struct{discord_start_thread_without_message} */
9451000
#if GENCODECS_RECIPE & (DATA | JSON)
9461001
PUB_STRUCT(discord_start_thread_without_message)
1002+
/** @CCORD_reason{reason} */
1003+
#if GENCODECS_RECIPE == DATA
1004+
FIELD_PTR(reason, char, *)
1005+
#endif
9471006
/** 1-100 character channel name */
9481007
FIELD_PTR(name, char, *)
9491008
/** duration in minutes to automatically archive the thread after recent

gencodecs/api/emoji.PRE.h

+15
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ LIST_END
4343
/** @CCORD_pub_struct{discord_create_guild_emoji} */
4444
#if GENCODECS_RECIPE & (DATA | JSON)
4545
PUB_STRUCT(discord_create_guild_emoji)
46+
/** @CCORD_reason{reason} */
47+
#if GENCODECS_RECIPE == DATA
48+
FIELD_PTR(reason, char, *)
49+
#endif
4650
/** name of the emoji */
4751
FIELD_PTR(name, char, *)
4852
/* TODO: implement base64 encoding */
@@ -58,6 +62,10 @@ STRUCT_END
5862
/** @CCORD_pub_struct{discord_modify_guild_emoji} */
5963
#if GENCODECS_RECIPE & (DATA | JSON)
6064
PUB_STRUCT(discord_modify_guild_emoji)
65+
/** @CCORD_reason{reason} */
66+
#if GENCODECS_RECIPE == DATA
67+
FIELD_PTR(reason, char, *)
68+
#endif
6169
/** name of the emoji */
6270
FIELD_PTR(name, char, *)
6371
/* TODO: implement base64 encoding */
@@ -69,3 +77,10 @@ PUB_STRUCT(discord_modify_guild_emoji)
6977
COND_END
7078
STRUCT_END
7179
#endif
80+
81+
#if GENCODECS_RECIPE == DATA
82+
STRUCT(discord_delete_guild_emoji)
83+
/** @CCORD_reason{reason} */
84+
FIELD_PTR(reason, char, *)
85+
STRUCT_END
86+
#endif

0 commit comments

Comments
 (0)