Commit Graph

543 Commits

Author SHA1 Message Date
diamondburned 16a408bf30 wsutil: Refactored and decoupled structures for better thread safety 2020-10-28 10:19:22 -07:00
diamondburned 6c332ac145 {Voice,}Gateway: Fixed various race conditions
This commit fixes race conditions in both package voice, package
voicegateway and package gateway.

Originally, several race conditions exist when both the user's and the
pacemaker's goroutines both want to do several things to the websocket
connection. For example, the user's goroutine could be writing, and the
pacemaker's goroutine could trigger a reconnection. This is racey.

This issue is partially fixed by removing the pacer loop from package
heart and combining the ticker into the event (pacemaker) loop itself.

Technically, a race condition could still be triggered with care, but
the API itself never guaranteed any of those. As events are handled
using an internal loop into a channel, a race condition will not be
triggered just by handling events and writing to the websocket.
2020-10-22 10:47:27 -07:00
diamondburned 91ee92e9d5 Gateway: Fixed a race condition on ReconnectOP 2020-10-21 22:42:16 -07:00
diamondburned 86795e42a6 Session: Fixed a potential race condition on Close 2020-10-21 22:42:16 -07:00
Maximilian von Lindern 397d288927
API: fix errors in message pagination and streamline changes with other pagination methods (#150)
* API: fix faulty pagination behavior

This fix fixes a condition which lead to all messages getting fetched if the limit was a multiple of 100, instead of just the limit.

* API: add NewestMessages

* API: clarify MessageAfter docs

* API: adapt paginating methods for guild, member and message reaction to match the style of message's pagination methods

* API: return nil if no items were fetched

* API: remove Messages and Rename NewestMessages to Messages
2020-10-19 07:47:43 -07:00
diamondburned dec39c4c2d API: Fixed Messages{Before,After} fetching incorrectly beyond 100s 2020-10-18 22:14:49 -07:00
mavolin 6dabffb46c State: fix case where Role would return nil error, even though no role was found 2020-10-18 13:44:37 -07:00
diamondburned 1bec57523d Gateway: GuildSubscribeData should omit empty Channels map 2020-10-17 03:18:50 -07:00
diamondburned 86dd05da9e Gateway: Fixed empty Query on RequestGuildMembersData broken 2020-10-16 02:17:59 -07:00
mavolin 647efb8030 Discord: add Mention method to mentionable Snowflakes 2020-09-24 11:54:45 -07:00
diamondburned 64ab8c4f30 Bot: Fixed trailing backticks causing out of bound panic 2020-08-29 22:09:58 -07:00
mavolin 5acf9f3f22 Discord: fix invalid role mention generation 2020-08-24 16:32:51 -07:00
mavolin 7d5cc89ff0 API: add KickWithReason 2020-08-22 10:05:37 -07:00
diamondburned 6b4e26e839 wsutil: Improved internal code 2020-08-20 14:15:52 -07:00
diamondburned fd818e181e Gateway: GuildFolderID is now a signed int because Discord 2020-08-19 21:54:20 -07:00
diamondburned 87c648ae1d Discord: ParseSnowflake now uses ParseUint 2020-08-19 21:53:22 -07:00
diamondburned 3312c66515 Voice: Made EventLoop a valid struct value instead of nil pointer 2020-08-19 21:32:40 -07:00
diamondburned de61fd912d wsutil: Made PacemakerLoop valid as zero-value 2020-08-19 21:30:57 -07:00
diamondburned f0c73f4c99 State: Ready events now automatically reset the state 2020-08-18 10:20:48 -07:00
Maximilian von Lindern a7e9439109
Discord/API: implement changes to permission, allow and deny fields (#141) 2020-08-17 17:10:43 -07:00
diamondburned af7f413cea Gateway: Clarified GuildMemberListGroup.ID docs 2020-08-14 21:13:48 -07:00
diamondburned c819b56170 Gateway: Added a custom GuildFolderID type 2020-08-14 18:13:35 -07:00
diamondburned eb46a89e6c Gateway: Fixed GuildFolder.ID unmarshaling 2020-08-14 17:57:06 -07:00
diamondburned d888a5a7ac Bot: Added better middleware documentation 2020-08-11 17:31:29 -07:00
diamondburned 3db68bcb0e Bot: Allow hanging quotes if command has a custom parser 2020-08-11 13:44:32 -07:00
diamondburned 94cca0adca httputil: Fixed unlock of unlocked mutex bug 2020-08-04 14:09:43 -07:00
mavolin 2a032ebfab Discord: add watching activity 2020-08-03 17:46:04 -07:00
diamondburned 77b1b08bce Heart: Better synchronization on close methods 2020-07-30 12:44:50 -07:00
mavolin 362929fad5 Webhook: fix incorrect order of parameters 2020-07-29 20:03:24 -07:00
mavolin ba1fc650d1 API: fix wrong typed Snowflake 2020-07-29 20:03:24 -07:00
Maximilian von Lindern 1585797b52 *: Linting and typo fixes (#134)
* Linting and typo fixes

* Linting and typo fixes

* revert comma fix
2020-07-29 16:58:33 -07:00
mavolin 8baf8ee84b Multipartutil: move back to package api 2020-07-29 16:58:33 -07:00
Maximilian von Lindern 908ef96089 Discord: Uint64 typed Snowflakes (#132)
* Use typed Snowflakes if possible

* Discord: make Snowflakes uint64

* Fix errors that emerged because of new typing
2020-07-29 16:58:33 -07:00
Maximilian von Lindern 32789bb6e2 *: Separate utils and internal (#129)
* Utils: move package utils/heart to internal/heart

* Utils: move package utils/moreatomic to internal/moreatomic

* Utils: move package utils/zlib to internal/zlib
2020-07-29 16:58:33 -07:00
Maximilian von Lindern 78c36f13cd Discord: Rename Snowflake and Timestamp Valid methods (#128)
* Discord: rename Snowflake.Valid() to IsValid()

* Discord: rename Timestamp.Valid() to IsValid()
2020-07-29 16:58:33 -07:00
Maximilian von Lindern e1d9685cdb API: separate token-based and bot-based interactions with webhooks (#130)
* API: separate token-based and bot-based interactions with webhooks

* API: move writeMultipart to internal/multipartutil

* Multipartutil: fix double filetype-suffix
2020-07-29 16:58:33 -07:00
mavolin ba4b224168 handler: move package from /handler to /utils/handler 2020-07-29 16:58:33 -07:00
diamondburned e79132f2c5 State: Breaking API to fix race conditions in store 2020-07-29 16:58:33 -07:00
Tadeo Kondrak b8f6fbbda9 Gateway: Fix type of GuildFolder.ID 2020-07-29 16:58:33 -07:00
Tadeo Kondrak d290b0d01c *: Add typed Snowflake IDs (#122)
This PR closes #120.
2020-07-29 16:58:33 -07:00
diamondburned 24f7ed0499 Gateway: ReconnectCtx now returns error; fixed test 2020-07-18 18:33:07 -07:00
diamondburned a929817c0f Handler: Fixed data race in test 2020-07-18 18:25:00 -07:00
diamondburned 1c8aaaefcc State: Fixed individual message fetch missing GuildID 2020-07-17 11:35:44 -07:00
diamondburned d18298aca9 Discord: Updated message's URL 2020-07-17 11:33:57 -07:00
diamondburned 35e143a99f Handler: Added blocking send cleanup to avoid goroutine leak 2020-07-15 23:11:20 -07:00
diamondburned 6717f8002c Gateway: Fixed autoreconnect misusing context 2020-07-15 16:39:40 -07:00
diamondburned a1038cb8bb Gateway: Fixed wrong usage of Context in Gateway reconnection 2020-07-15 16:32:53 -07:00
diamondburned 880691c51b Handler: Fixed inconsistency in documentation 2020-07-15 00:48:50 -07:00
diamondburned cb8567f006 Handler: Added examples as comments for documentation 2020-07-15 00:05:35 -07:00
diamondburned 18024526fe Handler: Added support for channel event handlers 2020-07-14 23:57:50 -07:00