Commit Graph

2707 Commits

Author SHA1 Message Date
Peter Bhat Harkins b45d175083 add brakeman
Wrote ignore notes and specs for the security assumptions implied.
Removed TZ from moderations table; everything is Chicago time, best time.
2023-12-17 20:22:47 -06:00
Peter Bhat Harkins e77495999e specs for previous 2023-12-13 12:12:29 -06:00
Peter Bhat Harkins ff19562026 add threading headers to reply notifications 2023-12-13 11:47:01 -06:00
Peter Bhat Harkins 9500e23ef1
Normalize rfc-editor.org links #1225 #1223 2023-12-06 09:26:28 -06:00
Peter Bhat Harkins d8ea92a140 set up db the reasonable way 2023-12-06 09:21:51 -06:00
Peter Bhat Harkins 1f4547d2b9 automate a bit with bin/setup 2023-12-06 08:50:04 -06:00
Peter Bhat Harkins 35925eb0e1
Merge pull request #1229 from internethostage/feature/bring_tag_colors_to_edit_form
Feature - Bring tag colors to edit form
2023-12-05 12:09:49 -06:00
Cristian Guerrero e801eae40d Remove unused css 2023-12-05 12:09:14 -05:00
Cristian Guerrero ccbda01634 Add the tag css details from data to the js generated tag entries
Also change div to a so that we can reuse the tag css styling
2023-12-05 12:09:14 -05:00
Cristian Guerrero 0b4b34afad Add the tag css classes to dropdown options data 2023-12-05 12:07:08 -05:00
Peter Bhat Harkins aa060669d5 wrap message IDs with <> in References header; #1227 2023-12-04 09:26:36 -06:00
Peter Bhat Harkins ff34ce9872 fix #1227 email Date header, bug from 4dd0fe8 2023-12-04 09:11:47 -06:00
Micah Magruder 348d754428 Add rfc-editor info links to spec test 2023-12-01 16:51:06 -05:00
Micah Magruder 3327c4be9b Normalize rfc-editor.org links 2023-12-01 16:39:51 -05:00
Peter Bhat Harkins 8722f4229c missing migration in schema; standardrb generated file 2023-11-22 11:17:57 -06:00
Peter Bhat Harkins 3d4b2c2b2d fix #1224 email reply to whom 2023-11-22 11:08:08 -06:00
Peter Bhat Harkins bc27b2c929 fix exception on anon viewing reply form 2023-11-22 10:13:58 -06:00
Peter Bhat Harkins 88c7a4a972
Merge pull request #1218 from joancodes/feature/add-email-visibility-toggle
Add profile toggle value to optionally show your e-mail address to authenticated users
2023-11-15 15:20:11 +00:00
Peter Bhat Harkins 8078e5d576 run migrations before tests 2023-11-15 09:16:46 -06:00
Robey Pointer 974daaf04c Add "user_is_author" to a story's json 2023-11-15 13:24:33 +00:00
Joan Nyambura 5e60757ebe feature/add-email-visibilty-toggle: Updated email visibility settings and conditions in UI
Added hint for email visibility to logged-in users and adjusted conditions for email display to users who have opted to show their email.
2023-11-08 19:32:13 +03:00
Peter Bhat Harkins d73262d79a match count to stories queried 2023-11-01 16:43:32 -05:00
Peter Bhat Harkins 11bad8f847
Merge pull request #1204 from thiagofportella/master
Display unsave link for previously saved stories
2023-11-01 10:34:13 -05:00
Joan Nyambura c8692b1ea8 Remove unnecessary conditional and schema changes 2023-10-24 11:22:14 +03:00
Peter Bhat Harkins 169c7ea80e
Merge pull request #1214 from JuanVqz/fix-comment-failing-test
Fix comment failing test
2023-10-12 07:11:46 -05:00
Juan Vasquez 642d888ec8 Fix comment failing test
This is the error I'm seeing [in the latest commit](5338e5a4b3)

Seems to be related to a MySQL flag `sql_mode=only_full_group_by` enabled by default.

```ruby
(byebug) Comment.where(user: user).group(:thread_id).order("id desc").limit(20).pluck(:thread_id)
*** ActiveRecord::StatementInvalid Exception: Mysql2::Error:
Expression #1 of ORDER BY clause is not in GROUP BY clause and
contains nonaggregated column 'lobsters_test.comments.id' which is not
functionally dependent on columns in GROUP BY clause;
this is incompatible with sql_mode=only_full_group_by

nil
```

I don't think is a good idea disabling that flag, so, I just updated the query.

Old query
```ruby
(byebug) Comment.where(user: user).group(:thread_id).order("id desc").limit(20)

(byebug) Comment.where(user: user).group(:thread_id).order("id desc").limit(20).to_sql
"SELECT `comments`.* FROM `comments` WHERE `comments`.`user_id` = 1 GROUP BY `comments`.`thread_id` ORDER BY id desc LIMIT 20"
```

New query
```ruby
(byebug) Comment.where(user: user).select(:thread_id).order("id desc").limit(20)

(byebug) Comment.where(user: user).select(:thread_id).order("id desc").limit(20).to_sql
"SELECT `comments`.`thread_id` FROM `comments` WHERE `comments`.`user_id` = 1 ORDER BY id desc LIMIT 20"

(byebug) Comment.where(user: user).select(:thread_id).order("id desc").limit(20).pluck(:thread_id)
[1]
```

```mysql
mysql> explain SELECT DISTINCT `comments`.* FROM `comments` WHERE `comments`.`user_id` = 1 ORDER BY `comments`.`thread_id` DESC LIMIT 20;
+----+-------------+----------+------------+------+---------------------------+---------------------------+---------+-------+------+----------+----------------+
| id | select_type | table    | partitions | type | possible_keys             | key                       | key_len | ref   | rows | filtered | Extra          |
+----+-------------+----------+------------+------+---------------------------+---------------------------+---------+-------+------+----------+----------------+
|  1 | SIMPLE      | comments | NULL       | ref  | index_comments_on_user_id | index_comments_on_user_id | 8       | const |    1 |   100.00 | Using filesort |
+----+-------------+----------+------------+------+---------------------------+---------------------------+---------+-------+------+----------+----------------+
1 row in set, 1 warning (0.01 sec)

mysql> explain SELECT comments.* FROM comments WHERE comments.user_id = 1 GROUP BY comments.thread_id ORDER BY comments.thread_id DESC LIMIT 20;
ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'lobsters_dev.comments.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
```

Links:
  * https://stackoverflow.com/questions/41887460/select-list-is-not-in-group-by-clause-and-contains-nonaggregated-column-inc
  * https://stackoverflow.com/questions/54547279/mysql-contains-nonaggregated-column-error-when-using-group-rails-5-2
  * https://gitlab.com/gitlab-org/gitlab-foss/-/issues/48428
2023-10-11 22:53:55 -06:00
thiagofportella 36bf8c38b7
test: create new memoized helpers for validation of save and unsave links in deleted stories 2023-10-09 11:22:07 -03:00
Peter Bhat Harkins 3c22b187bf revert cookie change for csrf issue 2023-10-07 07:18:10 -05:00
Peter Bhat Harkins d13c6c4676 comments: fewer db round trips on creation
Writes a vote directly to avoid vote_thusly doing round trips to check if one
exists, etc.

Removes redundant transactions from controllers from #899. Rails already creates
a transaction for the .save.

Unifies Story cache updating. Previously recalculate_hotness! was called twice
on comment creation. Moves comment counting into the db.

Shorter transaction should reduce the frequence of
lobsters/lobsters-ansible/issues/39 but seems unlikely to eliminate it as the
create + upvote transactions for stories + comments still read/write from
stories, comments, and votes.
2023-10-06 23:32:31 -05:00
Peter Bhat Harkins d806f7a60d enable page caching 2023-10-06 22:28:16 -05:00
Peter Bhat Harkins d316c3bcf5
Fix search failing test #1213 2023-10-06 19:16:58 -05:00
Peter Bhat Harkins bcf47356ca
re-fix search pagination #1217 2023-10-06 19:15:30 -05:00
Juan Vasquez 3ad1c3eedc Fix current page pagination
The page wasn't updated with the current page value, it allways was one.

```ruby
@search.to_param
=> { page: 1, what: "comments", ...}
```

Fixes https://github.com/lobsters/lobsters/issues/1208
2023-10-06 16:07:14 -06:00
Peter Bhat Harkins 230bc08f9d
Update git clone URL #1216 2023-10-06 11:01:31 -05:00
Nick Hammond 2cb2628293
Fix git clone URL
Update git clone url to the preferred github, git user style.
2023-10-05 16:02:19 -05:00
Juan Vasquez c060132eaa Fix search failing test
This PR is just for fixing the latest merge that introduces a failing
test.

When initializing a new Search model it has some default values,
specially the results_count one.
5338e5a4b3/app/models/search.rb (L42)

When doing Search.new({}, nil) in the ignore_searx method
5338e5a4b3/app/controllers/search_controller.rb (L30)

It takes the -1 value by default which in this if/else statement

5338e5a4b3/app/views/search/index.html.erb (L40)

is rendering this else block

5338e5a4b3/app/views/search/index.html.erb (L157-L167)

and that doesn't render the 0 results but it renders the Search hints:

if that is the decired behaviour then this PR is solving it.
2023-10-04 18:59:24 -06:00
Peter Bhat Harkins 9b6060041f placeholder for lobsters.dev 2023-10-04 12:20:00 -05:00
Peter Bhat Harkins 233d0c8b42 fix 2023-10-04 11:06:23 -05:00
Peter Bhat Harkins 099efa2274 configure hsts for preload 2023-10-04 10:57:25 -05:00
Peter Bhat Harkins 7acaf2d508 /about: break out examples of codebase use 2023-10-04 10:07:44 -05:00
Peter Bhat Harkins 2037b82d7e cache no longer needed since f489c8ae3 2023-10-04 08:37:02 -05:00
Peter Bhat Harkins 8f65acd2dd add super_diff for better test output 2023-10-04 08:31:39 -05:00
Peter Bhat Harkins 5338e5a4b3 ignore garbage searches from searx 2023-10-02 09:05:22 -05:00
Peter Bhat Harkins 4184d1e053 search: prevent potential sql injection 2023-10-01 17:56:39 -05:00
Peter Bhat Harkins 26f5a84cb4 sort deleted comments to bottom 2023-09-27 11:08:37 -05:00
Peter Bhat Harkins ea4edf3a26 RIP twitter 2023-09-27 07:42:41 -05:00
Peter Bhat Harkins 734476b73d bare searching for username; missing commenter explanation 2023-09-26 21:29:04 -05:00
Peter Bhat Harkins 078e454e37 give bad/malicious bots an error page instead of me a 500 email
I could change action_on_unpermitted_parameters to :log, but if someone is
doing weird things I'd rather be a little paranoid and drop the whole request
instead of ignore bits that aren't clear and try to proceed.
2023-09-26 10:33:55 -05:00
Peter Bhat Harkins 7d2dd9d347 search by commenter 2023-09-25 10:02:07 -05:00
Peter Bhat Harkins 9104efa999 explain why some searches are invalid 2023-09-25 09:49:28 -05:00