Commit graph

6229 commits

Author SHA1 Message Date
Michael Kohl
67f68b1cc2
POC: use Sidekiq.perform_bulk for Github repos (#16293) 2022-01-26 09:11:07 +07:00
Daniel Uber
4b4d8a7234
Ensure arguments to perform_async are json safe (#16285)
* Convert symbol hash keys to strings when calling .perform_async

Fixes a warning from Sidekiq 6.4.0+ about perform_async arguments
which are not equal when passed to perform (`JSON.parse(JSON.dump(arg))`
should equal arg).

This is a safety measure to prevent passing objects (like classes, or
model instances) rather than their representations (like a class name,
or a model's attributes hash).

This warning will be an error in sidekiq 7

* Turn warning into an error in non-production environments

* Use string keys for reaction notification and article fetched

Missed these two on the first pass

* Update example argument hashes for #enqueues_on_correct_queue

Since this calls perform_async under the hood we need to pass json
safe hashes in the test cases as well.

https://github.com/forem/forem/blob/main/spec/workers/shared_examples/enqueues_on_correct_queue.rb

* Convert keys from FollowData#to_h to string before perform_async

I'm not sure enough where else (outside of notification) to_h is being
called, so I'm converting here when building args, rather than in
FollowData#to_h, which might be my next step.

* Let FollowData#to_h return a hash with string keys

Update spec to use string keys as well.

* Make to_h return string keys for ReactionData

Like FollowData, the #to_h method is only used to call
notifications (this is used to enqueue sidekiq jobs).

* Remove a key that was in the hash

Since reaction_data calls to_h, it gets string and not symbol,
keys. Call Hash#except with a key that was actually there.
2022-01-25 18:07:40 -06:00
Ben Halpern
f393de4c21
Feed Experiment round 5: Factor in sum of tag points (#16272)
* Experiment with sum of tag points

* Cast sum of points to integer
2022-01-25 17:08:31 -05:00
Sabarish Rajamohan
922a9a9e10
Added title to be displayed for stackexchange question (#16289)
* Added title to be displayed for stackexchange question

* Fix for introduced spec

* Test Case Refactoring
2022-01-25 13:24:03 -06:00
Fernando Valverde
546c3b73bd
Android Runtime Banner - Chrome Intent support (#15181)
* Android - Chrome Intent

* Remove old inline comment

* Use regex for context check

* Update banner intent + playstore URL

* Use single constant for app launch scheme launch

* Use location.href instead of location.host

* Don't display banner on Firefox (Android)

* fix linter changes
2022-01-25 09:01:59 -06:00
Arit Amana
88d0823073
Implement Unified Embeds for Speakerdeck URLs (#16276)
* complete implementation and add specs

* nudge Travis
2022-01-25 07:21:39 -05:00
yheuhtozr
cae8ea2deb
i18n key updates in app/liquid_tags (#16275) 2022-01-25 11:03:09 +07:00
Jeremy Friesen
2b3f4e1342
Refactoring cached_followed_tags (#16175)
* Refactoring cached_followed_tags

This refactor consolidates two queries and a loop into a single query.

One thing that is unclear is if we're ever really clearing the cache of
the user by id?

What follows is un-related to the refactor but appears to be related to #14937.

> First, I see we set a cache here:
>
> ebdaaaf15b/app/decorators/user_decorator.rb (L23-L34)
>
> But when I look at what busts the user cache, it doesn’t look like we’re busting it for the above cached location:
>
> ebdaaaf15b/app/services/edge_cache/bust_user.rb (L3-L22)
>
> What if anything am I missing in regards to cache busting?

* Adding some deprecated methods

* Updating documentation

* Bump for travis

* Bump for travis

* Updating comments to fix confusion

NOTE: I might be introducing more confusion, but at least
I'm addressing the prior confusion.

* Bump for travis

* Updating so we don't cache ActiveRecord objects

* Selecting only applicable attributes for caching

* Apply suggestions from code review

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

* Adjusting code based on feedback

* Bump for travis

* Bump for travis

* Update app/decorators/user_decorator.rb

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

Co-authored-by: Michael Kohl <citizen428@forem.com>
2022-01-24 19:53:48 -05:00
Ben Halpern
4960f8913f
Refactor AB Experiments and exercise all variants in rspec (#16236)
* Refactor AB Experiments and exercise all variants in rspec

* Fix test that still uses wut
2022-01-24 17:03:58 -05:00
Nick Taylor
d227bbf770
Now <viewbox /> is preserved in SVGs when using the inline-react-svg plugin (#16287) 2022-01-24 16:25:14 -05:00
Nick Taylor
382b5528c7
Now the close X SVG icon is imported via the inline-react-svg plugin for the Modal component (#16288) 2022-01-24 16:01:21 -05:00
Arit Amana
b00f68b7fe
Complete implementation and add specs (#16274) 2022-01-24 14:23:16 -05:00
Mac Siri
3f2653a14d
Prefer custom SMTP config over Sendgrid (#16216) 2022-01-24 14:11:50 -05:00
Jeremy Friesen
24ccc5ac06
Adding lightweight structure .coerce methods (#16249)
I saw the following error in Honeybadger:

```
[PROJECT_ROOT]/app/services/notifications/reactions/send.rb:61 :in `call`

    old_json_data = notification.json_data
    previous_siblings_size = notification.json_data["reaction"]["aggregated_siblings"].size if old_json_data

	notification.json_data = json_data
[PROJECT_ROOT]/app/services/notifications/reactions/send.rb:20 :in `call`
[PROJECT_ROOT]/app/workers/notifications/new_reaction_worker.rb:16 :in `perform`
[PROJECT_ROOT]/app/models/notification.rb:84 :in `send_reaction_notification_without_delay`
[PROJECT_ROOT]/app/controllers/reactions_controller.rb:136 :in `destroy_reaction`
[PROJECT_ROOT]/app/controllers/reactions_controller.rb:168 :in `handle_existing_reaction`
[PROJECT_ROOT]/app/controllers/reactions_controller.rb:77 :in `create`
```

As I was exploring the error, I saw that we were making assumptions
about the data coercion.  These are valid and somewhat stable
assumptions, but I wanted to look a little deeper into the situation.

This refactor helps consistently negotiate two situations where we're
transforming request-cycle models into lightweight data structures.  It
also begins to show a path towards a generalizable "macro" for this behavior.

Related to #2122, #9534
2022-01-24 11:32:19 -05:00
ludwiczakpawel
b9d56d1158
focus style (#16266) 2022-01-24 15:39:20 +01:00
Arit Amana
26be901758
Implement Unified Embeds for Medium URLs (#16235)
* Complete implementation and add specs

* return StandardError upon url mismatch
2022-01-24 09:19:51 -05:00
Arit Amana
59810faa7c
Implement Unified Embeds for Kotlin URLs (#16256)
* Complete implementation and add specs

* correct spec mistake

* nudge Travis
2022-01-21 15:50:16 -05:00
Arit Amana
659806b754
Implement Unified Embeds for Jsitor URLs (#16250)
* Complete implementation and add specs

* update regex
2022-01-21 14:40:14 -05:00
Daniel Uber
085c566a7b
Onboarding "improvements" (#16210)
* Don't set saw_onboarding automatically

This should be set by the onboarding checkbox update (user accepted
terms of service and code of conduct).

The issue is a PATCH request to track the last seen page is sent on
the first page, _before_ the user consents to the terms via the
checkboxes.

This issue is masked by a 422 unprocessable entity response when we
don't get a username in the patch request (next commit).

* Only validate username on the username page

Every other "last page seen" dialog was returning a 422 because the
username is only submitted in the 3rd dialog "build your profile".

Only validate the username field when it's submitted, process other
onboarding updates normally.

* Remove failing test

Since the onboarding_update action no longer sets saw
onboarding (since we send the patch before they've accepted the code
of conduct), don't test that we do.

There's a parallel test for the onboarding checkbox update later in
this file that covers the checkboxes have been accepted.

* overwrite instead of merging user_params

We now initialize it empty, no need to merge params here.
2022-01-21 10:58:05 -06:00
Michael Kohl
a0edc9ac7e
Add Settings::Base.to_h (#16241) 2022-01-21 22:23:24 +07:00
Jeremy Friesen
fc8158a5ba
Stripping tags from "tags.short_summary" column (#16248)
On the DEV.to database, I ran the following SQL:

```sql
SELECT name, short_summary FROM tags WHERE short_summary LIKE '%<%';
```

There were three tags with a `<` in them:

- changelog
- cnc2018
- javascript

This PR will tidy up our short summary as part of saving a tag.  It will
also tidy up the existing tags.
2022-01-21 09:38:26 -05:00
Nick Taylor
13fc65953b
Removed font-awesome from the admin section (#16239) 2022-01-21 08:56:22 -05:00
ludwiczakpawel
faa054fa49
fix (#16244) 2022-01-21 11:58:18 +01:00
Suzanne Aitchison
c92b3367ae
remove assignment of css variable to undefined (#16243) 2022-01-21 10:07:07 +00:00
Suzanne Aitchison
222ce06f0f
Add new tag autocomplete to editor (#16025)
* add default placeholder, remove focus on first load

* fix some bugs re autofocus and mouse click to select

* allow custom selected styles to be passed in

* operate on objects with name property rather than plain strings

* WIP main functionality in place

* set default selections, allow a max to be placed on selections

* switch help context

* bug fixes to edit mode, static suggestions

* make sure suggestion resumes when edit begins

* cleanup and docs

* update existing form test

* add component tests

* add more component test cases

* refactor max selections flow, ensure default tag data only loads once

* stop removing combobox properties now the input stays visible

* add max selections test

* refactor

* make sure input refocus happens after blur event

* update cypress tests

* some small renames and doc changes

* only fetch exact matches from added tags

* fix test, update dark theme background

* set a max height on the popover, and ensure options can be scrolled into view

* woops - max height

* Update app/javascript/article-form/components/TagsField.jsx

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

* refactors

* stop dropdown from flickering

* use ButtonNew

* remove redundant variant

* nudge PR checks

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2022-01-21 08:58:05 +00:00
ludwiczakpawel
87ff8f16a1
Color tokens (#16107) 2022-01-21 07:41:03 +01:00
Michael Kohl
6099d3640d
ListingsToolkit refactoring (#16184) 2022-01-21 09:27:10 +07:00
Jeremy Friesen
af2e1f0545
Expanding the range of followed tags we show (#16213)
The fix might be a bit of a work-around for a more general approach, but
we're fighting against the magic of the points vs. explicit_points
tension as defined in the [Follows::UpdatePointsWorker][1].

That is to say, it's possible (and happens) where I have assigned an
`explicit_points` of 1 for a tag, but the calculated `points` are less
than 1.  The calculated `points` are what we send forward in the
[AsyncInfoController][1] (by way of the
[UserDecorator#cached_followed_tags][3] method).

In DEV, I ran the following queries:

**User assigned points `>= 1` but calculated `< 1`**

985,352 records

```sql
SELECT count(id)
FROM follows
WHERE followable_type = 'ActsAsTaggableOn::Tag'
  AND points < 1
  AND explicit_points >= 1;
```

**User assigned points `>= 1` but calculated `>= 1`**

5,366,478 records

```sql
SELECT count(id)
FROM follows
WHERE followable_type = 'ActsAsTaggableOn::Tag'
  AND points >= 1
  AND explicit_points >= 1;
```

**User assigned points `>= 1` but calculated `>= 0`**

0 records.

```sql
SELECT count(id)
FROM follows
WHERE followable_type = 'ActsAsTaggableOn::Tag'
  AND points <= 0
  AND explicit_points >= 1;
```

**User assigned points `<= 0` but calculated `> 0`**

1,146 records

```sql
SELECT count(id)
FROM follows
WHERE followable_type = 'ActsAsTaggableOn::Tag'
  AND points > 0
  AND explicit_points <= 0;
```

Synthesizing that, almost 1 million tag follows of the total 6.3 million
are not showing up in the user's left navigation.  And 5.3 million are
roughly correct.

In adjusting the logic, we're now going to have more tags showing up in
the left.  And just over 1,000 might now show up that would be unexpected.

Closes #14937.

[1]:c63e0b629e/app/workers/follows/update_points_worker.rb
[2]:c63e0b629e/app/controllers/async_info_controller.rb (L40-L65)
[3]:c63e0b629e/app/decorators/user_decorator.rb (L23-L34)
2022-01-20 19:46:42 -05:00
Jeremy Friesen
711f1bb0cd
Let override of ToS and CoC show in onboarding (#16217)
* Let override of ToS and CoC show in onboarding

Prior to this commit any changes to the terms or code of conduct were
not reflected in the onboarding links.

With this commit, I'm leveraging a newly created method that first
checks if there's a page for the given slug.  If there is, use that
page's copy.

To test:

- Overwrite default /terms page on a Forem
- Navigate to /onboarding or sign up as a new user
- Click on Terms of Use link text
- Review Terms of Use

Closes #15296

* Adding spec around not passing a block
2022-01-20 19:45:39 -05:00
Julianna Tetreault
8c440885a8
Adds suggested_tags to Onboarding section in Config (#16228) 2022-01-20 11:13:40 -07:00
yheuhtozr
53564c2849
app/mailers i18n (#16191)
* app/mailers i18n

* delete ja.yml
2022-01-20 07:33:29 -07:00
Julianna Tetreault
615137a883
Remove the "Getting Started" Section from the Config (#16033)
* Removes the Getting Started section and related code from the config

* Removes the admin_manages_configuration_spec.rb

* Removes "Required" tags from Config

* Reverts removal of activateMissingKeysModal

* Removes mandatory.rb
2022-01-20 07:31:35 -07:00
yheuhtozr
71b2724faa
app/services i18n (#16189) 2022-01-20 09:25:25 -05:00
Arit Amana
ea6bd0f366
Implement Unified Embed for Tweet URLs (#16218)
* building

* complete implementation and add specs
2022-01-20 08:05:56 -05:00
ludwiczakpawel
43c188eafb
Updated indicators (#16190) 2022-01-20 06:25:10 +01:00
Michael Kohl
4f1a5b5a39
Move BlackBox to app/lib (#16183) 2022-01-20 09:37:53 +07:00
Daniel Uber
f2a8cbce7e
Remove "connect" feedback message special treatment (#16167)
* Remove special handling of "connect" feedback by name

The special casing was related to "connect" feedback having both a
reporter and an offender. Check for offender instead.

Additionally, there was special casing in the controller to rate-limit
connect feedback separately from other channels. Since connect doesn't
exist, we should not need this.

There's a small bit of functionality (when I post to feedback_messages, the
number of feedback messages increases) that was removed from the test
case, we can add that back (and "connect" type, and
offender_id attributes) since it looks like it might have been a
useful assertion.

* Add back feedback message controller creates feedback message case

This was removed in the last commit because it was in a "connect" chat
channel context, but the basic "should persist a record" test was
otherwise valid. Submit an abuse-report rather than a connect message
report.

* typo

feeedback, woops.
2022-01-19 08:32:10 -06:00
Michael Kohl
2533a438f7
Rubocop auto-correct (#16181) 2022-01-19 21:04:43 +07:00
Mac Siri
3685530969
Explicitly silence FastImage exceptions (#16176) 2022-01-19 08:56:26 -05:00
yheuhtozr
adc757f5a5
app/validators i18n (#16166) 2022-01-19 05:25:39 -05:00
Jane ♥
d5348995c1
Finishes adding all the codepen embed options available (#16102)
Co-authored-by: JaneOri <7545075+James0x57@users.noreply.github.com>
Co-authored-by: Michael Kohl <me@citizen428.net>
2022-01-19 09:23:15 +07:00
Daniel Uber
394d33e134
Select max from a subquery of two things (#16177)
* Select max from a subquery of two things

max(int, int) not a function, says postgres, once it stopped yelling
about parenthesis balancing.

* prefer greatest to select max from subquery
2022-01-18 18:21:14 -05:00
Jeremy Friesen
06f6573436
Ensuring that we don't divide by zero (#16172)
* Ensuring that we don't divide by zero

Adding one to a "always-ish greater than or equal to 0" value.  This
should resolve a flakey test and a seemingly erratic production error.

Resolves https://app.honeybadger.io/projects/66984/faults/83596547

* Favoring min over adding 1

Due to syncrhonization antics, let's not assume time is consistent
across servers.

Timey Whimey Wibbley Wobbley

* Update app/services/articles/feeds/weighted_query_strategy.rb

Co-authored-by: Daniel Uber <djuber@gmail.com>

Co-authored-by: Daniel Uber <djuber@gmail.com>
2022-01-18 17:25:15 -05:00
Dwight Scott
9375ba4932
allow approved tags to show articles and not render 404 (#16101) 2022-01-18 13:09:19 -05:00
yheuhtozr
617d66c4e5
app/liquid_tags i18n (#16125) 2022-01-18 11:28:38 -05:00
Jeremy Friesen
5ec47d99dc
Ensuring we don't track views of author or unpublished (#16143)
* Ensuring we don't track views of author or unpublished

Prior to this commit, I was surprised to learn that we:

1) Tracked an author's view of their article.
2) Tracked views of an unpublished article.

This came up from a Forem creator asking if they could reset the view
counter.  Or trigger the reset on publication.

I think a general business logic policy of don't track views for the
author and don't track views for unpublished articles is a reasonable
default.

Were we to pursue the clear views on publication, we'd need to consider
something that went from unpublished -> published -> unpublished ->
published.  Without a more explicit state machine, triggering a
busineiss logic behavior seems a bit unexpected.

In other words, I wrote an article.  There are 20 views when I realize
that I need to unpublished it.  I make the changes in the unpublished
state, and re-publish.  I'd assume that those 20 views would still be
"recorded" and counted towards my article's view counts.

* Adjusting condition structure

Prior to this commit, the `if` clause was rather far to the right.  This
helps make the if clause more pronounced.
2022-01-18 11:23:18 -05:00
Jamie Gaskins
dd8aeee58e
Move work from template to controller (#16092)
* Move work from template to controller

* Render only the final result with the template
2022-01-18 11:21:25 -05:00
Julianna Tetreault
46d40b2f54
Resolves rubocop violations in weighted_query_strategy.rb (#16164) 2022-01-18 09:11:41 -07:00
Michael Kohl
19d6a26f7b
Update remaining Crayons icons (#16100)
Co-authored-by: Nick Taylor <nick@forem.com>
2022-01-18 13:41:04 +07:00
Michael Kohl
9cc01b2c30
Remove unused Users::ProfileImageGenerator::BACKGROUND_HEXES (#16132) 2022-01-18 10:32:52 +07:00