Commit Graph

63 Commits

Author SHA1 Message Date
Asaf Gartner 4568def378 Added a bunch of discord debugging 2024-03-28 21:24:46 +02:00
Asaf Gartner cd36eb44eb Don't require url/asset for snippet creation from discord. 2024-03-04 21:19:56 +02:00
Asaf Gartner 444f43a195 Added !til for discord messages 2024-03-04 21:09:40 +02:00
Ben Visness 76be9b668a Republish Discord announcements to Abner's Matrix server 2023-12-05 23:55:39 -06:00
bvisness 0210a0784b Add Discord login (#106)
This leverages our existing Discord OAuth implementation. Any users with a linked Discord account will be able to log in immediately. When logging in, we request the `email` scope in addition to `identity`, so existing users will be prompted one time to accept the new permissions. On subsequent logins, Discord will skip the prompt.

When linking your Discord account to an existing HMN account, we continue to only request the `identity` scope, so we do not receive the user's Discord email.

Both login and linking go through the same Discord OAuth callback. All flows through the callback try to achieve the same end goal: a logged-in HMN user with a linked Discord account.

Linking works the same as it ever has. Login, however, is different because we do not have a session ID to use as the OAuth state. To account for this, I have added a `pending_login` table that stores a secure unique ID and the eventual destination URL. These pending logins expire after 10 minutes. When we receive the OAuth callback, we look up the pending login by the OAuth `state` and immediately delete it. The destination URL will be used to redirect the user to the right place.

If we have a `discord_user` entry for the OAuth'd Discord user, we immediately log the user into the associated HMN account. This is the typical login case. If we do not have a `discord_user`, but there is exactly one HMN user with the same email address as the Discord user, we will link the two accounts and log into the HMN account.

(It is possible for multiple HMN accounts to have the same email, because we don't have a uniqueness constraint there. We fail the login in this case rather than link to the wrong account.)

Finally, if no associated HMN user exists, a new one will be created. It will use the Discord user's username, email, and avatar. This user will have no password, but they can set or reset a password through the usual flows.

Co-authored-by: Ben Visness <bvisness@gmail.com>
Reviewed-on: #106
2023-05-06 19:38:50 +00:00
Asaf Gartner 2af28d9f3f Update pgx v4 to pgx v5 2023-01-29 08:53:57 +02:00
Ben Visness 9e27835e51 Add /manifesto Discord command 2023-01-22 09:38:14 -06:00
Asaf Gartner d7f1325ace Better time truncation for stream notifications. 2022-10-20 12:43:26 +03:00
Asaf Gartner cf809a3cdc Twitch fixes 2022-10-20 12:43:26 +03:00
Asaf Gartner 0f58cfc2da Added support for db arrays and some twitch fixes. 2022-10-20 12:43:26 +03:00
Asaf Gartner 5cc920dc2f Better twitch tracking 2022-10-20 12:43:26 +03:00
Ben Visness 4f1989f663 Add /wishlist command 2022-08-12 22:01:40 -05:00
Asaf Gartner efc7d76cb7 Snippet creation and editing 2022-08-06 00:41:37 +03:00
Asaf Gartner b165bf7c23 Added panic recovery to all of our background jobs
Fixes issue #32
2022-06-16 00:33:57 +03:00
Asaf Gartner ac2d00aca7 Logging bad discord resources 2022-05-30 21:56:09 +03:00
Asaf Gartner 2bb14c1794 Replaced panic with error 2022-05-30 21:52:13 +03:00
Asaf Gartner 4c296c9ddd Soft failure for failing to delete discord message. 2022-05-30 18:55:10 +03:00
Asaf Gartner 0d0773fd0e Reverse streamer sort and replaced green circle with red 2022-05-27 16:34:34 +03:00
Asaf Gartner 09c4561428 Slightly improved discord message formatting. 2022-05-27 11:55:57 +03:00
Asaf Gartner 8495982d3f Added persistent vars and improved stream tracking on discord. 2022-05-27 11:37:43 +03:00
Ben Visness 475716322f Fix up missing avatars 2022-05-21 16:44:39 -05:00
Ben Visness c1fa6cae13 Integrate Nick's local S3 server
Works like a charm!

Small tweak for clarity
2022-05-14 00:48:19 -05:00
Ben Visness 3a93aa93e9 Seed users (and rework a lot of user access to use new helpers) 2022-05-07 13:58:00 -05:00
Ben Visness 0e56f56372 Rename all the db tables 2022-05-07 08:11:05 -05:00
Ben Visness a147cfa325 Rework DB API
This takes advantage of generics, and generally clears up a lot of
inconsistencies and quality-of-life issues.

Start of db rework: clean up, start generics, improve tests

Write some nice aspirational package docs

Rework and document the db API

Tests still pass, at least...now for everything else

Update all callsites of db functions

Finish converting all callsites

Not too bad actually! Centralizing access into the helpers makes a big
difference.

wtf it works
2022-05-06 16:56:13 -05:00
Ben Visness b45a28156c Add projects to profile user command 2022-02-12 01:00:45 -06:00
Asaf Gartner c8f401f738 Updated cmd description 2022-02-07 14:25:21 +02:00
Asaf Gartner 43651d98e8 Code review 2022-02-07 14:21:40 +02:00
Asaf Gartner 92d6a31aa9 Fixed tag removal issue. 2022-01-31 10:22:25 +02:00
Asaf Gartner 378d6eb836 Removed old comment. 2022-01-31 08:52:56 +02:00
Asaf Gartner 60a71d5dd1 Fixed indent. 2022-01-31 08:51:34 +02:00
Asaf Gartner ad888346ef Discord message handling reorganization. 2022-01-31 08:46:43 +02:00
Asaf Gartner f4f439489d Assets for user avatars 2021-12-29 16:38:23 +02:00
Asaf Gartner f8e7779b7d Fixed discord linking issue 2021-12-21 08:14:51 +02:00
Asaf Gartner b5eb718615 Query automatically does ToSlice. Use QueryIterator if you need an
iterator.
2021-12-15 03:36:37 +02:00
Ben Visness 3b8b02a856 Watch for snippet updates on all messages
This captures stuff in jam-showcase and ryan's stuff in #projects
2021-12-13 01:40:54 -06:00
Ben Visness 7cb6869fcb Fix conflict error when tagging from Discord 2021-12-11 10:11:44 -06:00
Ben Visness 4d63d02533 Always update snippet tags on every Discord edit 2021-12-08 23:00:44 -06:00
Ben Visness e70dcbdd53 Switch to ampersand for delimiter 2021-12-08 22:05:17 -06:00
Ben Visness 40cd19c5f0 Do the Discord integration with personal projects! 2021-12-08 21:13:58 -06:00
Ben Visness 0cc879df21 Add tags to snippets on timelines 2021-11-11 11:00:46 -08:00
Ben Visness 00864842b3 Add file upload support for Discord 2021-09-27 09:23:57 -05:00
Ben Visness 4b4c205566 Make profile messages ephemeral 2021-09-26 23:04:53 -05:00
Ben Visness 88da574446 Tweak /profile messages, add and fix tests 2021-09-26 22:35:42 -05:00
Ben Visness 1df691bc13 Add user command for profile 2021-09-26 20:30:09 -05:00
Ben Visness 85a7a37162 Add /profile slash command 2021-09-26 17:34:38 -05:00
Ben Visness 251446d6e4 Do jam showcase stuff 2021-09-24 22:53:00 -05:00
Ben Visness 986a42c1ac Switch to centralized helpers for fetching threads/posts
This includes the ability to "shadowban" new users who have not yet been
approved. We do not have UI for approving these users.

Migrate deserving users to new Approved status

Add post fetching helpers as well

The logic in the thread/post stuff is definitely getting redundant, but
I'm not sure I'm yet ready to try to abstract any of it away.

The next thing to do is probably to update blogs and other places that
fetch threads/posts, and delete the old helpers.

Move forums and blogs fully to new helpers

Use the helpers on the landing page too

that was easy!

Fix up some spots I missed

Check user status and use helpers on the profile page
2021-09-22 23:48:31 -05:00
Ben Visness 36bb2ce2d5 Put timestamp in avatar filenames to avoid cache problems 2021-09-07 19:55:52 -05:00
Ben Visness b53770932d No longer require a migration in seedfile
We don't need to do this any more, since our database backups now
include the migration table. The seedfile command also no longer
requires the user to type a password.

This also prevents the Discord history bot from running when it has no
credentials.
2021-09-05 19:43:49 -05:00