Commit graph

2907 commits

Author SHA1 Message Date
Michael Kohl
09828853f6
✂✂✂ Remove Connect (#14734)
* Remove Connect

* Remove more Connect specs

* Remove a lot more Connect code

* 🚮

* It all has to go

* Explicitly add httpclient

* Update application layout

* Remove messages association from User

* Start fixing specs

* reintroduce util function and refactor references

* Remove Connect Cypress test

* Fix more specs

* Remove Connect from listings

* Ignore contact_via_connect column on listings

* Remove contact_via_connect usages

* Ignore mod_chat_channel_id on tags

* Drop Connect tables

* Remove email_connect_messages from user notification settings

* Re-add httpclient 2.8.3

This was mistakenly removed as a merge conflict

* Don't need to exclude removed chat channel file

* Remove unneeded style for chat channels

* Remove unneeded channel list prop type

* Remove chat channels index/connect-link from getPageEntries

* Re-add comment from httpclient in Gemfile

* Remove connect references from mailers

Tag Moderators no longer have a chat channel

No longer will users be notified about new messages (there won't be
any)

No longer will users be notified about channel invites (you can't
invite anyone anymore)

* Don't configure Pusher and remove PUSHER_* from .env_sample

since it's removed from gemfile, the Pusher constant will not resolve, if this is
configured in the environment variables we'll fail to boot.

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Dan Uber <dan@forem.com>
2021-11-18 08:21:00 -06:00
Anna Buianova
4cab190285
Hiding comments: an option to hide or keep children (#15178)
* Optional hiding child comments (start)

* Changed confirm button in comments hide form

* Hide children comments if hide_children was passed

* Added a spec for hidden child comment notifications

* Hide only explicitly hidden comments

* Hide comment modal on article page

* Prevent default behaviour for hide comment link

* Improved hide comments modal looks

* Improved hide comments modal looks

* Removed unused code

* Send hide comment form via fetch

* Hide comment descendants when hide_children was passed

* Don't hide hidden comments descendants on permalink

* Removed unnecesary span

* Improved hide comments modal styling

* Removed unused styles and js, improved styling

* Clickable label

Co-authored-by: ludwiczakpawel <ludwiczakpawel@gmail.com>

* Fixed showing hidden comments spoiler for article author

* Fixed hideArticleComments.spec.js

* Fixed displaying hidden comments text for artice author, added specs

* Target hide comments modal inside the modal when adding a listener

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* Replaced hide comment link with a button

* Refactored adding hide_children url param

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* Fixed cypress hide comments test

* Removed aria-label for submit on the hide comments modal

* Fixed formatting

Co-authored-by: ludwiczakpawel <ludwiczakpawel@gmail.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2021-11-18 11:57:40 +03:00
Jeremy Friesen
91b951eb05
Refactoring and extending article spam behavior (#15399)
* Refactoring and extending article spam behavior

Prior to this refactor, we were checking an Article's title for
spaminess.  This change now checks the Article's title and
body_markdown.

In addition, the encapsulates the regular expression implementations in
favor of asking the Settings::RateLimit class to determine if the passed
in text is "spammy".

Furthermore, instead of having lots of inline logic within the article,
this refactor introduces a `Spam::ArticleHandler` class.  This helps
tidy up the already busy Article specs by delegating the business logic
of Spam handling to it's own class.

There are further refactors for Comments and Users that would follow
this pattern, but this change is more important to get out the door.

Closes #15396

* Adding comments to clarify behavior of spam handling

* Adding missing expectation to spec
2021-11-17 17:09:17 -05:00
Lewis Sparlin
ca6719b9b1
Issue #9077 has already been resolved, added specs (#15342)
* Prove #9077 has been resolved

* Do no create mentions for any @mention-like syntax from embedded liquid, add spec
2021-11-17 11:27:50 +02:00
Jeremy Friesen
3782db891a
Adding ability to block domains from registration (#15397)
Prior to this commit, we had filtering options for email registration:

1. Specific allowed domains.
2. Implicitly allow all domains if no allowed domains specified.

With this commit, we add another option: The adminstrator may block one
or more domains from registering.

Closes forem/rfcs#281
2021-11-16 18:56:01 -05:00
ludwiczakpawel
1f685d93d1
Remove unused assets (#15367)
* remove unused assets

* spec update

* spec

* spec

* minus

* whoops

* whoops
2021-11-16 19:57:37 +01:00
Daniel Uber
845bc01c69
Remove name from allowed tag params in admin (#15382)
Don't allow passing `tag[name]=` in post params to admin tag update.

There's no field for this in the view, it's not expected that someone
change the name (it serves as a natural key) - it's preferrable to
alias an old name to a new tag if a renaming is desired.
2021-11-15 14:58:24 -06:00
Daniel Uber
90c3ee2e6a
Nullify invalid tag colors (#15361)
* Nullify invalid tag colors

Set bg_color_hex and text_color_hex to nil when they were an empty
string.

This is a cleanup of legacy data (from form submissions, when the
field was unset and another attribute was updated, the value could be
saved as '' rather than set nil). This is no longer possible due to
validations added in #10495 so only needs to be handled once.
2021-11-12 14:35:08 -06:00
ludwiczakpawel
09db50b296
Update tag's style (#15266)
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Michael Kohl <citizen428@forem.com>
2021-11-11 14:03:31 -05:00
Daniel Uber
14caad86a7
handle deleted article's comments page with a 404 response (#15351)
* Add a failing test for comments index of deleted article

After https://github.com/forem/forem/pull/15052 removed the (also
broken) deleted commentable template and the redirect, requests for
comments from deleted articles raise no method errors (initially
trying to set the page title to "Comments for commentable.title" but
the assumption that @commentable is non-nil is present in several
other places.

This test currently fails (by design). Either we want to update the
controller so that comments from deleted articles are no longer
viewable (returning not found, as we did prior to
https://github.com/forem/forem/pull/5199 or making the view safe for
the case where @commentable is nil and no @root_comment is present.

These requests are happening quite frequently (@maestromac and I
suspect the sitemap may contain these pages and crawlers are visiting
the site from a published link), as evidenced by
https://app.honeybadger.io/projects/66984/faults/81994265

* Add request spec for deleted article scenario

Additionally, relabel the legacy spec (updated during #15052) to
clarify we do not render the deleted_commentable_comment view (this is
testing the comment.path, rather than the article.path/comments index

The scenario with comment.path sets `@root_comment` in the controller,
so does not trigger errors on the `@commentable` method calls.

* Update view

pass 1: get the errors to stop (need to check the rendered page is
also usable, the comment tree is not shown when commentable is nil and
this might be a huge usability/correctness issue).

* extract logic from comments index to methods and update tests

We no longer expect deleted article's comments index to render (should
return 404), only direct links to comments of deleted articles.

Only assign @article in the index for the view if it is in fact an
article (not a podcast episode, it's possible `@root_comment` was for
a podcast episode).

* remove unneeded (and soon to be incorrect spec)

No longer want or need to test for the case where root comment is nil
and so is commentable. This was an exploratory spec (scaffolding) and
can be removed.

* Undo nil safety changes to comments index

and fix typo in comments spec
2021-11-11 12:56:14 -06:00
Daniel Uber
8f7e0b1744
Let users purchase credits (#15346)
* Dark Theme preference is a user setting and not delegated

Resolves NoMethodError

* Add a view spec

This ensures the /credits/purchase page is rendered

* Test both styles based on user setting

Add an actual expectation to the view test
2021-11-10 15:18:52 -06:00
Daniel Uber
0a47910e30
Skip badge awards for spam accounts (#15344)
* Don't award badges to banished users

* Assert badges aren't created for spam accounts
2021-11-10 10:48:01 -06:00
yheuhtozr
a6f08ae215
views/stories, views/layouts and other homepage i18n (#15083)
* views/stories and home related i18n

* PR key names fixes

* remove ja.yml

* Update en.yml

* Update fr.yml

* Update articles_search_spec.rb

* Update _meta.html.erb

* Update index.html.erb

* Update _meta.html.erb

* Update articles_search_spec.rb

text in HTML should not contain raw brackets

* Update articles_search_spec.rb

* Update _signup_modal.html.erb

* Add back missing Search text

Co-authored-by: Fernando Valverde <fernando@visualcosita.com>
2021-11-10 07:38:43 -06:00
Michael Kohl
6b2160f307
Theming cleanup (#15237)
* Theming cleanup

* Fix specs

* Use correct method

* Update storybook theme switcher
2021-11-09 10:11:55 -05:00
Jeremy Friesen
95969eb973
Caching sum privileged reaction scores (#15299)
* Caching sum privileged reaction scores

This relates to work on improving the feed.  Namely that in the current
proposal in PR #15240 I'm not accounting for how privileged users have
given feedback on an article.

With this change, I will now have a cached value on the articles table
that can be a proxy for how the privileged users have reacted.

In addition there's a small refactor that moves a constant to the
correct scoping object.

Dependent on #15283.

* Fixing method name to `exists?`

Prior to this commit, I was using `exist?` which doesn't work for
ActiveRecord::Relation objects.
2021-11-08 12:50:08 -05:00
Michael Kohl
bff7cd1118
Theme data update script, remove theme choices from UI (#15225)
* Add prefer_os_color_scheme to users_settings

* Add data update script

* Update theme selector view

* Update spec wording

* Fix spec

Co-authored-by: Jeremy Friesen <jeremy.n.friesen@gmail.com>
2021-11-08 08:38:43 -05:00
Anna Buianova
6aab40e90d
[Quick Fix] Fixed a couple of warnings in specs (#15288)
* Fixed warning for not raising a specific error in specs

* Fixed rubocop issue in specs
2021-11-07 22:07:05 +03:00
Michael Kohl
daa1555c00
Cooldown Project: Introduce StringAttributeCleaner (#15281)
* Add attribute cleaner

* Start using AttributeCleaner

* Add additional check

* Also work with non AR classes

* Remove unnecessray :aggregate_failures

* Rename to StringAttributeCleaner
2021-11-06 14:58:14 +07:00
Daniel Uber
d48587721a
Only permit valid class names as sponsorable type (#14387)
* Only permit valid class names as sponsorable type

https://github.com/forem/forem/issues/14386 identified an error could
arise if input was provide to the sponsorable_type field in the admin
creation form, but it was not a valid constant (since we include the
related model in the index when loading @sponsorships, this permits
creating a sponsorship that can't easily be managed or deleted).

Add a validation to ensure when the sponsorable type is present, it's
a class (really, we probably want to also ensure it's available as an
associated model type, since we'll be looking it up with find(:sponsorable_id), but this
is an initial attempt at adding some guard rails to this form).

A more realistic solution would be to add a `Sponsorship::SPONSORABLE_TYPES` constant
to the class, and validate the supplied sponsorable type is in
`SPONSORABLE_TYPES.map(&:name)`. That requires more domain knowledge
about what kind of things can be sponsored than I have, it would
certainly include at least ActsAsTaggableOn::Tag but may include other
classes (or why would it be polymorphic).

* Explicitly list the allowed types for sponsorship

I see we can sponsor tags, and suspect that's all we can sponsor
meaningfully (the view only shows details when it is a tag).

* Use inclusion validation with options to replicate custom method

And remove the code, we don't need it any more.

* Update app/models/sponsorship.rb

Co-authored-by: Michael Kohl <citizen428@dev.to>

Co-authored-by: Michael Kohl <citizen428@dev.to>
2021-11-05 12:25:35 -05:00
Prayesh Shah
c043339654
Bug Fix: Following an organization from article's sidebar creates an incorrect follow record (#15093)
* Downcase `followable_type` to fix wrong follows creation bug

* Use `follow_button` helper

* Remove puts statement

* Revert use of follow_button helper

* Remove downcase of followable_type from helper

* Refactor switch case for better consistency

* Add e2e test for follow organization from article page functionality

* Split cypress `it` block into two

* Add additional test to following organizations from dashboard

* Remove downcasing of followable_type for decorated objects

* Fix failing follow back spec

* Force capitalize `followable_type` param

Co-authored-by: Mac Siri <krairit.siri@gmail.com>

* Update app/controllers/follows_controller.rb

Co-authored-by: Mac Siri <krairit.siri@gmail.com>
2021-11-05 12:40:20 -04:00
Arit Amana
4f1bdcda22
[Small Wins] Show character limits for profile inputs (#15255)
* Start implementation

* Extend raw implementation; will refactor later

* still building

* basic implementation

* create JS pack

* Rename JS pack; use existing CSS property

* complete implementation for profile fields

* Add guard againt irrelevant profile fields

* extract view logic to helper and add specs
2021-11-05 09:11:42 -04:00
Akash Srivastava
4cb48768f9
Added collapsed hidden comments to author's article/podcast episode view (#14018)
* Handling hiding/collapsing hidden comments client side

* Updated comment quality text

* Added placeholder for comments against podcast episodes

* Added logic for encompassing co-author-ids in articles

* Removed rspecs validating non-presence of hidden comments in dom

* Fixed hiding flow on comments page for a commentable

* Fixed e2e specs

* Addressed feedback on e2e tests
2021-11-03 11:08:04 +07:00
Lewis Sparlin
71e90a41f5
Disable all providers when providers_to_enable param is blank (#15260)
* Disable all providers when providers_to_enable param is blank

* Remove guard, a couple more spec examples

* Update app/services/settings/authentication/upsert.rb

Co-authored-by: Fernando Valverde <fernando@visualcosita.com>

Co-authored-by: Fernando Valverde <fernando@visualcosita.com>
2021-11-02 21:20:26 -04:00
Kushal Niroula
87244c345c
Fix: cannot unpin articles using checkbox (#15090)
Co-authored-by: rhymes <github@rhymes.dev>
Co-authored-by: Arit Amana <msarit@gmail.com>
2021-11-02 13:50:56 -04:00
Daniel Uber
e3ebc623da
Compare the utc offset from the timestamp, not now (#15256)
Time Zones are political things, and move. The timezone database knows
this, and correctly interprets times as they would have been at the
time.

For example, when the Time zone is Africa/Monrovia, the offset now is
0, but the offset in 1970 was -44.5 minutes, so Time.zone.at(0) is Dec
31st, 1969, 23:15:30 and not Jan 1st, 1970 00:00:00.

Prevent this spec from randomly failing based on Zonebie's selected
timezone by comparing the offset _then_ against UTC, and predicting
whether the 60's have ended yet.
2021-11-01 15:49:35 -05:00
Julianna Tetreault
4a9f442354
Creator Onboarding: Creator Setup View (#14728)
Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
Co-authored-by: Yhëhtozr <conlang2012@outlook.com>
Co-authored-by: yheuhtozr <84892012+yheuhtozr@users.noreply.github.com>
Co-authored-by: Nick Taylor <nick@dev.to>
2021-11-01 15:50:08 -04:00
Daniel Uber
43adc9f1fb
cross posted articles showing <time> tag (#15224)
* Maybe this is what we need to do?

* Undo change to keyword

Use the on_html translation in the view, but pass 'on' as a keyword to
the template.

* remove unused translation

Since we only want to use views.articles.crossposted.on.html (and this is only used in the
article show template) - remove the unused 'on' key from the
translations file.

* Add a spec

Tested that this fails in main and passes on the branch

* Check that the original publication date is shown in the users local

And that it's not a <time> tag presented as text

* Correct local date selection error

If time zone was UTC (i.e. offset from utc was 0) the check for
positive? was false, I meant "non-negative" (positive or zero). Invert
the test.
2021-10-29 12:10:53 -05:00
Ridhwana
aa6d80bc5d
Only enable user invitations page when SMTP is enabled (#15219)
* first pass of styling of the page

* feat: scroll to the position in the config controller in stimulus

* feat: add the tooltip and a cursor thats not allowed

* feat: add a disabled property for all that needs smtp to be enabled

* feat: update the form styling

* feat: update the form

* specs: update the label name

* fix: syntax error

* chore: update the newline

* spec: test the invitation flow

* fix test

* feat: update the form as per suggestions

* spec: update the tests to match the new workflow

* oops committed debugging code

* chore: add a before to set the smtp_enabled method

* feat: update the boldness and fontsize of the link

* feat: remove size
2021-10-29 17:41:30 +02:00
Arit Amana
20c164ce40
[Small Win] Assign 'trusted' role when user updated to Admin or SuperAdmin (#15215)
* Bada bing, bada boom! 💥

* Give default admin user "trusted" role

* fix failing spec
2021-10-28 15:28:25 -04:00
Michael Kohl
0fab8d6634
Theming changes part 1: Rename default and night_theme (#15176) 2021-10-28 07:55:46 -04:00
ludwiczakpawel
ca108aa9c8
Videos UI update (#15177)
* videos ui updates

* move cheese around

* .

* .

* thumbnail yolo

* thumbnail yolo

* object fit

* aspect ratio yolo

* .

* loading videos

* Make Travis and asset pipeline happy with .mp4 extension

* Use Cloudinary video url, testing for Travis

* Try weird things

* Try a real image url

* Use a real image instead of 'video' string

* Update views.scss

Co-authored-by: Andy Z <17884966+Zhao-Andy@users.noreply.github.com>
2021-10-28 09:34:44 +02:00
Mac Siri
3c204c236d
Update TagsController#index query (#15202)
* Update TagsController#index query

to include empty string

* Update spec
2021-10-27 08:17:53 -04:00
Jeremy Friesen
ed78f8f479
Extracting a common calculator for feed weights (#15199)
Prior to this commit, there existed duplicate logic between two of the
primary user feeds.  This refactor introduces a new object which is
solely concerned with calculating scores to add to an article base score.

With this commit, we can introduce A/B testing by changing passing
different config values to `ArticleScoreCalculatorForUser.new`.

My suspicion is that for some of this, we might be able to better
leverage the database via select statements and SQL sums.  However, that
is presently outside of what I'm prepared to tackle.
2021-10-27 04:45:53 -04:00
Ben Halpern
2395693809
Asynchronously detect image aspect ratios and apply proper attributes (#15170)
* Initial work to expand detection functionality

* Finish up functionality and tests

* Fix class name

* Fix tests

* Update spec/services/articles/enrich_image_attributes_spec.rb

Co-authored-by: Michael Kohl <citizen428@forem.com>

* Update spec/services/articles/enrich_image_attributes_spec.rb

Co-authored-by: Michael Kohl <citizen428@forem.com>
2021-10-26 13:39:25 -07:00
Jeremy Friesen
fbce226c08
Low Stakes Refactor of Feed class (#15180)
* Removing state change and unused method

Prior to this commit, the `@comment_weight` value would change.  This is
not ideal as depending on the call sequence, can notably change the
output.  I suspect this state change occurred so as to not alter an
underlying spec.

What this change does is remove the state change, removes a dead method,
renames a method (to the dead method name), and leverages
parameterization to better test a spec that was brittle based on
possible state changes.

I believe, from a logical stand point, that this change does not impact
the functionality nor the actual logic that is part of the production
call path.

* Marking methods as @api private

The goal is to highlight that we really shouldn't be calling these
outside of their contained class.  Ideally, I'd love to make them
private methods, but there are specs and would prefer to not use
`__send__` to change those specs.

This is a noop change.

* Renaming method to refelct returned param order

Prior to this commit the "default_home_feed_and_featured_story" returned
an array of `[featured_story, default_home_feed]`.  The method name and
the order of the returned values were misaligned.  This change helps
align the method name and the order of those returned values.

Note, methods such as `each_with_index` have an `element, index`
parameter order.
2021-10-26 09:57:33 -04:00
ludwiczakpawel
88a3b573ea
Page headers unified (#15158)
* fix; remove the bottom 100%

* dashboard

* fixes + magic border-radius

* everything

* fix

* fix

* spec

* split PRs

* Update app/assets/stylesheets/views/listings.scss

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>
2021-10-25 21:41:29 +02:00
yheuhtozr
6a3a91d9b7
views/podcasts, views/podcast_episodes i18n (#15020)
* views/podcasts, views/podcast_episodes i18n

* reformat for PR

* helper labels

* PR sync with main

* remove ja.yml

* Update en.yml

* Update fr.yml

* Update _meta.html.erb

* Update podcast_episodes_index_spec.rb

* Update podcast_create_spec.rb

* Update user_visits_podcast_episode_spec.rb

* Update en.yml

* Update feed.rb

* Update index.html.erb
2021-10-25 14:32:51 +01:00
ludwiczakpawel
719b87e2ae
Auto border-radius (#15165) 2021-10-25 14:41:13 +02:00
ludwiczakpawel
656cfcd655
Tag edit (#15173)
* tag edit

* more

* chop chop

* spec

* Apply suggestions from code review

Co-authored-by: Michael Kohl <me@citizen428.net>

* french translation

* Fix I18n usage

* Apply suggestions from code review

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* lang

Co-authored-by: Michael Kohl <me@citizen428.net>
Co-authored-by: Michael Kohl <citizen428@forem.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2021-10-25 12:50:00 +02:00
Lewis Sparlin
e621659279
Add Article post_commit when user_id changes with specs (#15132)
* Add Article post_commit when user_id changes with specs

* Add example in requests/admin/articles_spec for updating user
2021-10-25 10:53:21 +07:00
ludwiczakpawel
d1aac57053
Podcasts fixes (#15130) 2021-10-22 11:06:11 +02:00
Nick Taylor
bf2d673492
Created the Forem creator confirmation email template (#14659)
Co-authored-by: Michael Kohl <citizen428@forem.com>
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2021-10-21 14:56:09 -04:00
Arit Amana
55a6bc3644
Allow users to choose their default Home and Tags-View Feed (Part 1) (#15128)
* add new column & define enums

* add new column & define enums

* add tests; improve enum naming

* complete specs update 😅

* discard changes to schema.rb

* rename column name more appropriately

* update specs

* update specs properly 🤦🏾‍♀️

* Please Travis do the thing

* Add DB schema diff

Co-authored-by: Jamie Gaskins <jgaskins@hey.com>
2021-10-20 18:02:59 -04:00
Julianna Tetreault
22d1e6dd83
Adds a Creator user to the users.rb for testing purposes (#15138) 2021-10-20 07:15:41 -06:00
Michael Kohl
26aef9da93
Don't notify authors about own org posts (#15113) 2021-10-19 21:32:44 +07:00
Suzanne Aitchison
5069cd681a
Markdown editor toolbar (#14876)
* rough starting point, roving tabindex in toolbar, bold and italic buttons

* refactor, add link

* add ul

* add ordered list

* core formatters in place, wip

* overflow options

* add keyboard shortcuts

* tidy up some dodgy classes

* add mocks for runtime in test and storybook, use correct modifier key for tooltip

* style tweaks

* refactor tooltips

* add markdown formatters tests

* add tests for toolbar component, fix mistake in overflow menu tooltips

* undo change no longer needed to button

* fix issue accessing runtime in formatters file

* only show darkened buttons and tooltips when focus-visible is true

* mobile view

* fix for responsive buttons & roving tabindex

* tweaks from PR review

* update cursor position on link insertion

* add a new line after block selection formatting

* align icons in center

* tidy up overflow menu listeners

* small refactors

* test for new text area util

* tidy up new lines after syntaxes

* fix logic in cursor offsets for links

* prevent scroll jumps after inserting syntax

* some style tweaks

* insert level 2 heading with new lines above and below

* update icons

* use margin instead of gap
2021-10-19 09:22:54 +01:00
Ben Halpern
09fa66a03f
Fix and clean up podcast pages (#15004)
* Fix and clean up podcast pages

* Adjust tests

* Fix a test

* Fix missing i18n

* Fix tests

* Fix tests

* Fiddle with test

* Sure up css and tests

* Add featured as allowed param

* Fix a couple tests

* xit out test

* Update app/views/podcast_episodes/index.html.erb

* Update app/views/podcast_episodes/index.html.erb

Co-authored-by: ludwiczakpawel <ludwiczakpawel@gmail.com>

Co-authored-by: ludwiczakpawel <ludwiczakpawel@gmail.com>
2021-10-15 17:38:57 -04:00
Jamie Gaskins
820dd9b5a6
Allow Emails::RemoveOldEmailsWorker to run longer (#15085)
* Allow Emails::RemoveOldEmailsWorker to run longer

We set the SQL statement timeout based on the STATEMENT_TIMEOUT
environment variable (defaulting to 2.5 seconds in production), but not
all SQL queries are created equal. Since some may take longer out of
necessity, this PR introduces a `Model.with_statement_timeout` method
that allows you to change the SQL statement timeout only for a given
block.

* EmailMessage doesn't inherit ApplicationRecord

It inherits from `Ahoy::Message`, which inherits directly from
`ActiveRecord::Base`.

[3] pry(main)> EmailMessage.ancestors
=> [EmailMessage(id: integer, clicked_at: datetime, content: text, feedback_message_id: integer, mailer: string, sent_at: datetime, subject: text, to: text, token: string, user_id: integer, user_type: string, utm_campaign: string, utm_content: string, utm_medium: string, utm_source: string, utm_term: string),
 EmailMessage::GeneratedAssociationMethods,
 EmailMessage::GeneratedAttributeMethods,
 Ahoy::Message(id: integer, clicked_at: datetime, content: text, feedback_message_id: integer, mailer: string, sent_at: datetime, subject: text, to: text, token: string, user_id: integer, user_type: string, utm_campaign: string, utm_content: string, utm_medium: string, utm_source: string, utm_term: string),
 Kaminari::ConfigurationMethods,
 Kaminari::ActiveRecordModelExtension,
 Ahoy::Message::GeneratedAssociationMethods,
 Ahoy::Message::GeneratedAttributeMethods,
 Bullet::SaveWithBulletSupport,
 ActiveRecord::Base,
 ...

* Use milliseconds to match STATEMENT_TIMEOUT units
2021-10-15 11:53:55 -04:00
Michael Kohl
a1f512e49e
✂✂✂ Remove events (#15062)
* Remove events

* Fix schema

* Fix specs

* More removal
2021-10-15 09:31:08 -04:00
Ben Halpern
333775b831
Admin productivity: Allow admins to unpublish all posts from a user (#15054)
* Allow admins to unpublish all posts from a user

* Update app/services/moderator/unpublish_all_articles.rb

Co-authored-by: Jamie Gaskins <jamie@forem.com>

* Update app/services/moderator/unpublish_all_articles.rb

Co-authored-by: Jamie Gaskins <jamie@forem.com>

* Update app/services/moderator/unpublish_all_articles.rb

Co-authored-by: Jamie Gaskins <jamie@forem.com>

* Unset `published` irrespective of front matter

* Change to worker and make other adjustments

* Fix controller test

* Fix object name

* Update app/views/admin/users/edit.html.erb

Co-authored-by: Andy Zhao <17884966+Zhao-Andy@users.noreply.github.com>

* Update spec/requests/admin/users_spec.rb

Co-authored-by: Jamie Gaskins <jamie@forem.com>

Co-authored-by: Jamie Gaskins <jamie@forem.com>
Co-authored-by: Jamie Gaskins <jgaskins@hey.com>
Co-authored-by: Andy Zhao <17884966+Zhao-Andy@users.noreply.github.com>
2021-10-15 08:56:59 +02:00