Commit Graph

1431 Commits (2db414f12d264648415dcec5751286acec9e44c4)

Author SHA1 Message Date
Snakes 4db48a6ec9 Separate modaction notifs from inbox. 2022-06-10 08:28:46 -04:00
Snakes 8709ca816d Add Y'all Seein' Eye award v2 for offsitementions.
Reusing the assets and design for the ill-fated YSE in a0f441a67d.
This time, the award provides access to our offsite mentions (reddit
notifs).
2022-06-10 07:12:19 -04:00
Snakes bea6d82b61 Lottery: fix granted value, zero royalty.
grant_lottery_tickets_to_user incorrectly deposited the full ticket
value into manager account, not just the net value.

Additionally, royalty rate has been set to zero because Chapose won
the first lottery and grifting 8% that could instead go into the
prize pool seems unwarranted given that.
2022-06-10 06:15:37 -04:00
Snakes 5f7b38b477 Refactor stat timers, award timers.
Prior to this comment, the every-1d cron.py command was broken due
to lack of proper stats import. However, while refactoring this, it
was convenient to move other recurring tasks that had been stuffed in
odd places--not least `stats(...)`--into the new cron system. This
entailed a number of refactorings of other things.

1. Move stats(...) from static.py to helpers/stats.py.
2. Move hole inactivity purge task from stats(...) to routes/subs.py.
3. Move bot award timer checks from stats(...) to helpers/awards.py.
4. Unify award timer logic formerly in routes/front.py into the new
   helpers/awards.py.
2022-06-10 05:47:41 -04:00
Snakes dc7f13304e Add following holes for notifications. 2022-06-09 16:24:24 -04:00
Aevann1 39e0e6d017 make cron also calculate stats (based and cronpilled) 2022-06-09 20:09:49 +02:00
Snakes ed240735fb Improve slur replacer performance, part deux.
h/t @official-techsupport again for finding another optimization.
We are now cumulatively at about 70% speedup over original.
It remains one of the hottest paths of the codebase in relative
terms, but its absolute performance demands have decreased enough
to buy us potentially substantial time on it.
2022-06-07 21:56:14 -04:00
Snakes da82ea81d8 Improve slur replacer performance.
h/t @official-techsupport for digging into the regex performance and
coming up with one that greatly reduces backtracking. We see an
approximately 2x speedup under typical loads, which proves to be a
major overall savings in performance. Previously, censor_slurs was,
second to ORM DB accesses, by far the most time-consuming function
in the codebase under typical loads. It's still not ideal, but it is
much better.

Future options to improve this critical path further would be:
  1) Precompute a slur-replaced HTML, rather than recomputing
     each pageload. Storage is cheap.
  2) Tokenize the HTML and replace plaintext words using O(1)
     exact-match lookups to a dict.
2022-06-07 21:16:58 -04:00
Snakes e85d76947a Lottery: fix negative ticket quantity exploit. 2022-06-07 17:50:31 -04:00
Snakes 995375decc Refactor reddit mentions, move to cron.
The reddit mentions system contained much duplicated code and was
grafted onto the post thumbnail pipeline to achieve semi-regular
invocation. Instead, we now run it through the new cron system,
and the duplicate code has been refactored out.
2022-06-07 10:42:24 -04:00
Snakes 152315f73e cron: Move charts from static to helper. 2022-06-07 08:31:24 -04:00
Snakes ace0a62f69 cron: Add lottery as scheduled task. 2022-06-07 07:36:55 -04:00
Snakes acb3a0b338 Enable flask command, add cron target.
Adding an empty __init__.py, the imports-only cli.py, and setting
FLASK_APP in the environment are enough to get the `flask` command
to work. This will enable future changes, including database
migrations.

The proximate reason for the fix is to add a `flask cron` command
to run scheduled tasks within the application from cron. Specifically,
the lottery should be run from cron.
2022-06-07 06:57:26 -04:00
Aevann1 4a98c2a639 don't whitelist fagmins 2022-06-07 12:34:46 +02:00
Aevann1 4a1e6cc726 a 500 error is much better than an XSS, bro 2022-06-07 12:03:51 +02:00
Snakes dece3fd460 Add user title coin cost parameter. 2022-06-06 19:02:23 -04:00
Snakes 7556fe8988 Add lottershe badge logic, badge helper. 2022-06-06 00:07:38 -04:00
Snakes 5fb358a32a Add more TLDs to sanitize. 2022-06-03 17:01:32 -04:00
Snakes b306d113ad Lottery: Fix treasure adding coins to manager.
It was observed in prod that the lottery prize as tracked by the DB
had diverged from the amount held in the Lottershe manager account.
This appears to be the result of grant_lottery_tickets_to_user
adding the # of _tickets_ rather than the value of those tickets to
the manager.
2022-06-03 02:24:32 -04:00
Snakes 843ff51ace Make post rate limit site-specific. 2022-06-02 22:10:59 -04:00
Snakes 379ae664a3 Make PIN_LIMIT a per-site constant. 2022-06-02 19:45:33 -04:00
Snakes 6b9a133204 Kitchen sink commit, misc. content updates.
- Increment cache version on popover badges.
- Add comments+submission_listing.js to assetcache to support ^.
- Append new words to wordle list.
- Cache bust assorted assets for recent PRs.
2022-06-02 19:32:13 -04:00
outruncolors dfd521b652 Add quantity field to purchasing tickets / Make Chapose the beneficiary (#302)
* Add quantity field to purchasing tickets

* Remove height requirement for div (manlets  seething)
2022-06-02 19:19:49 -04:00
float-trip 58c4b62163 Some fixes (#300)
* Narrow emoji_regex

* Fix mirrored pat emojis

* Fix ban icon on posts/comments
2022-06-02 19:18:10 -04:00
Snakes 2008c09136 Add 'filter' to allowed_styles. 2022-06-02 06:14:20 -04:00
Snakes 227ddbec0e Truncate notifs with too-long bodies.
In general, we don't do a great job of length validating body_html
fields. Lots of ways to get 500 errors by providing too long of
input. Really ought to find a way to fix it in the classes/comment.py
and classes/submission.py classes. In the interim, the recent gifts
messages change is salient because the notification can 500 out
mid-way through performing coin transactions.

Recommended to find a better way of truncating or safely bubbling
the exception up. Truncating probably not best long-term solution
because it could hypothetically permit strings that would otherwise
be considered unsanitized.
2022-06-01 00:54:05 -04:00
Snakes 49622b3268 Lottery: add admin participants listing. 2022-05-31 23:20:39 -04:00
Snakes 79e338de38 Treasure: raise minimum reward 10 -> 12.
A rare case where users receive 0 lotto tickets from a treasure chest
occurs when they received 10 or 11 coins from a chest pre-conversion
to lotto tickets. Rather than change ticket_count to the ceil of
dividing coins by ticket cost, it seems less distortionary to instead
imperceptibly raise the minimum to avoid this case.
2022-05-31 20:23:19 -04:00
Snakes 5d56e71cc9 Rate limiter: fix 81e2a5a for logged-out. 2022-05-30 23:50:56 -04:00
Snakes 4ba2098612 Rate limiter: whitelist admins.
Due to presently hitting perpetual 429s after a mishap with lottery
polling on production, among past events where admins have gotten
rate-limited for doing otherwise normal admin behavior, the
flask_limiter.Limiter now has a request filter to whitelist JL2+.
Despite running on every request, I don't anticipate this undermining
the DoS prevention power of the Limiter.

It is yet unknown whether there are edge cases where running
get_logged_in_user in a different spot in the request pipeline might
e.g. subtly break the logged-in counters. This is not expected at
present, however.
2022-05-30 23:01:18 -04:00
Snakes 81e19b1aed Add can_gamble user setting.
Users now have a toggleable can_gamble setting which disables their
ability to use all chance-based gains on the site: viz. slots,
blackjack, the lottery, and treasure chests.

This only applies on invocation of commands that start gambling
games, so it should cause no bugs when toggled with e.g. active
blackjack games.

This was added for the benefit of users with actual problems with
gambling, be they past addiction or religious conviction. All future
gambling features are humbly requested to respect it.
2022-05-30 05:32:45 -04:00
outruncolors 0abf890575 Make a few styling changes for mobile lottery modal (#293) 2022-05-30 01:40:55 -04:00
Snakes cf46b8b3fe Refactor e81edb711d for modularity. 2022-05-30 00:30:10 -04:00
Aevann1 e81edb711d fixed this https://rdrama.net/post/72013/-/2010109?context=8#context 2022-05-30 06:12:51 +02:00
Outrun Colors, LLC ef7da60432 Remove new schema changes from file and replace account ids for lottery system 2022-05-29 22:17:31 -05:00
Outrun Colors, LLC db13e0976c Have tickets show up in treasure chests 2022-05-29 21:59:22 -05:00
Outrun Colors, LLC b9dc28e6d1 Don't show lotteries on the sister sites 2022-05-29 20:43:16 -05:00
Outrun Colors, LLC a0cc7e1cf6 Move more stuff to proper location 2022-05-29 19:49:14 -05:00
Outrun Colors, LLC 562202b38d Reorganize route logic 2022-05-29 01:06:39 -05:00
Outrun Colors, LLC bef0b0ff6d Add participants and field updating 2022-05-29 01:01:45 -05:00
Outrun Colors, LLC 1a55a7670e Send notifications to winners and losers 2022-05-28 23:23:20 -05:00
Outrun Colors, LLC 469c39dca6 Configure admin section and purchasing a ticket full flow 2022-05-28 22:33:44 -05:00
Aevann1 709c756660 fds 2022-05-28 16:55:22 +02:00
Aevann1 cd2380fb33 fds 2022-05-28 04:20:31 +02:00
Aevann1 3f04c69cb8 fds 2022-05-28 01:50:33 +02:00
Aevann1 6b6e2e8253 sfd 2022-05-27 20:28:54 +02:00
Aevann1 db98b4e140 sfd 2022-05-27 19:19:12 +02:00
Aevann1 384afb125a fsd 2022-05-27 17:28:30 +02:00
Snakes 2bde3650d4 Awards: enable lootbox on WPD, refactor AWARDS2 logic. 2022-05-26 22:12:53 -04:00
Aevann1 758a30e166 fsd 2022-05-26 22:53:24 +02:00