Commit Graph
100 Commits
Author SHA1 Message Date
evazion af4891bf4c Upgrade to ruby 2.7. 2020-02-16 18:48:41 -06:00
evazion 1385e60f8c Update ruby gems and yarn packages. 2020-02-16 13:08:23 -06:00
evazion d3bbd82d8b application record: drop execute_sql, select_value_sql methods. 2020-02-16 05:56:23 -06:00
evazion 9caa9d8117 post versions: drop unused presenter method. 2020-02-16 05:38:53 -06:00
evazion d01c6b773c application model: drop unused test_connection method. 2020-02-16 05:38:50 -06:00
evazion 1370b034d1 api: don't include can_comment_vote? on users.
This triggers multiple comment vote count(*) calls when doing things
like /posts.json?only=uploader and the current user is in the set of
uploaders.
2020-02-16 05:03:58 -06:00
evazion 835cc23f66 forum post votes: fix exploits with voting on mod-only forum posts.
* Don't allow unprivileged users to vote on mod-only forum posts.
* Don't allow unprivileged users to see votes on mod-only forum posts.
2020-02-16 04:51:23 -06:00
evazion bf4dbf1449 forum posts: replace joins with subqueries.
Using subqueries here avoids some nasty large joins.
2020-02-16 04:43:57 -06:00
evazion 7e67d3dd9c views: replace .category-N css classes with .tag-type-N
* Replace the .category-N CSS classes on tags with .tag-type-N. Before
  we were inconsistent about whether tag colors were indicated with
  .category-N or .tag-type-N. Now it's always .tag-type-N.

* Fix various places to not use Tag.category_for. Tag.category_for does
  one Redis call per tag lookup, which leads to N Redis calls on many
  pages. This was inefficient because usually we either already had the
  tags from the database, or we could fetch them easily.
2020-02-16 04:35:37 -06:00
evazion 998eece95d controllers: allow banned users to use GET actions.
Make member_only et al only apply to non-GET actions. This avoids doing
IP ban checks when simply viewing members-only pages.
2020-02-16 04:21:20 -06:00
evazion 594c4ea0c9 respond_with: fix for non-activemodel responses. 2020-02-16 04:05:09 -06:00
evazion caf54fe45a blacklists: remove ability for mods to blacklist uploaders by name. 2020-02-16 04:00:42 -06:00
evazion b591353773 /dmails: don't default to 'received' folder.
Don't make /dmails default to the received folder when no other folder
is specified. This is surprising in the API because it means
/dmails.json only shows received dmails by default, not all dmails. This
isn't necessary either since everything that links to dmails already
specifies the received folder.
2020-02-16 03:36:10 -06:00
evazion 8024d9f0ba /comment_votes: fixup creator_name reference. 2020-02-16 03:28:45 -06:00
evazion bbabaffb07 /comment_votes: make visible to banned users.
Let banned users see their own comment votes.
2020-02-16 03:24:21 -06:00
evazion a214989447 controllers: move /moderator/post/disapprovals to /post_disapprovals. 2020-02-15 07:10:45 -06:00
evazion 60ff2ae929 models: rename post/pool archives to post/pool versions. 2020-02-15 06:52:10 -06:00
evazion 51f3f7338a models: remove old post version and pool version models. 2020-02-15 06:21:00 -06:00
evazion 2564e885c8 controllers: refactor only param includes.
Add extra includes needed by the `only` param inside `respond_with`.
2020-02-15 06:17:22 -06:00
evazion 8649ff6dbe API: remove various associated fields included by default.
Remove various associated fields that were included by default on
certain endpoints. API users can use the only param to include the
full association if they need these fields.

* /artists.json: urls.
* /artist_urls.json: artist.
* /comments.json: creator_name and updater_name.
* /notes.json: creator_name.
* /pools.json: creator_name.
* /posts.json: uploader_name, children_ids, pixiv_ugoira_frame_data.
* /post_appeals.json: is_resolved.
* /post_versions.json: updater_name.
* /uploads.json: uploader_name.
2020-02-15 06:17:11 -06:00
evazion c5bcfb962f parameter builder: remove binding.pry statement. 2020-02-14 17:35:02 -06:00
evazion 1e426a50f7 controllers: standardize request format checks. 2020-02-14 17:28:25 -06:00
evazion c0cca18091 Merge pull request #4288 from BrokenEagle/nested-only-parameter
Add ability to use nested only parameter
2020-02-14 17:23:54 -06:00
evazion dd425830ca Update gems.
Fixes a showstopper bug in rack-2.2.0 that prevents puma from booting.
2020-02-10 18:45:34 -06:00
evazion be66141074 artists/summary: show urls as bulleted list. 2020-02-10 17:11:38 -06:00
evazion a6f11610bd artists/summary: remove list of top source domains.
Remove the list of most-used source domains from artist summaries. This
took up a lot of space and usually wasn't very useful. It was also slow.
We had to calculate this on every artist tag search so we could display
it in the Artist tab, even though usually the user didn't open the tab.
2020-02-10 17:11:38 -06:00
evazion 3ef4d9c7ac artists/summary: link other names to artist searches.
* Link other names to artist searches instead of to the new artist page.
* Remove the asterisk next to other names indicating the name isn't used
  as the primary name of another artist. This is almost always the case.
2020-02-10 17:11:38 -06:00
evazion 4ed716e90d Update ruby gems and yarn packages. 2020-02-10 17:11:38 -06:00
evazion aaafd230e4 Merge pull request #4291 from BrokenEagle/rework-version-views
Rework version views
2020-02-10 16:46:42 -06:00
evazion 01e42b7063 Merge pull request #4277 from BrokenEagle/fix-pawoo-source
Fix Pawoo source
2020-02-08 16:56:10 -06:00
evazion 094b9e6d07 Fix #4287: Hide Dmail notice persistently shown even after closing 2020-02-05 20:47:55 -06:00
evazion 960ed8934b wiki_pages/new: fix exception in rendering html data attributes.
Fix exception when trying to get the category_name for the html data
attributes. The wiki title is nil here and Tag.category_for couldn't
handle a nil tag name.
2020-02-05 18:36:55 -06:00
evazion 69f653b0c4 forum_topics/show: fix N+1 query patterns. 2020-02-05 18:08:39 -06:00
evazion db4c67ee86 Fix #4286: Mod dashboard: limit width of left column. 2020-02-05 16:59:54 -06:00
evazion 9322c596e2 Fix #4279: Very long tags break forum post format.
* Enable word breaks for all DText-formatted text. Ensures extremely
  long strings in comments get broken.

* Fix the author column on comments/forum posts to use a fixed 12em
  width (except on the mobile layout). Using flex-basis was wrong because
  it allowed the author column to shrink if the other column was too wide.
2020-02-05 16:49:04 -06:00
evazion 327bc46bd2 Fix #4283: Profile no longer viewable through API. 2020-02-05 15:39:53 -06:00
evazion ccb87e13b1 Fix #4282: Related tag search no longer allows the JSON/XML formats. 2020-02-05 14:38:32 -06:00
evazion 2d0e0769cb /ip_addresses: add paginator to group_by=(user|ip_addr) pages. 2020-02-05 14:28:30 -06:00
evazion 089c304992 paginator: fix page counts for relations with group by clauses.
Fix an invalid SQL exception that occurs when the paginator tries to
do a COUNT(*) to calculate the page count of a relation that already
includes a GROUP BY + COUNT(*) clause. We need to nest the whole query
inside a `SELECT COUNT(*) FROM (...)` subquery so the inner COUNT(*)
doesn't mess up the outer COUNT(*).

Fixes #4285.
2020-02-05 14:27:48 -06:00
evazion 6b3c541a8a /ip_addresses: temp fix for exception when using group_by param.
Calling next_page here raises an exception when calculating the page
count because it can't handle SQL containing a GROUP BY clause. Swallow
the exception as a temp fix.
2020-02-04 03:59:10 -06:00
evazion 96b565f61d users: temp fix exception when is_banned is inconsistent.
Fix an exception when is_banned is true but the user doesn't have a ban
record.
2020-02-04 03:51:59 -06:00
evazion fcfdd94fe9 controllers: temp fix exception in show actions.
Temp fix a regression caused by c7185724d.
2020-02-04 03:51:59 -06:00
evazion 6a729cf184 sessions/new: fix 'Missing partial static/_secondary_links' error. 2020-02-04 03:45:46 -06:00
evazion 6a3a04f6ec dmails: fix unread dmail notice when unread_dmail_count is inconsistent.
Fix an exception when the user's unread_dmail_count is nonzero but they
don't have any unread dmails. This normally shouldn't happen unless the
unread_dmail_count is inconsistent.
2020-02-04 03:45:27 -06:00
evazion f87ec2509a modreports: fix reporting inaccessible dmails and forum posts.
* Fix it being possible to report dmails belonging to other users.
* Fix it being possible to report forum posts in mod-only threads.
2020-02-03 22:11:48 -06:00
evazion a5ebbc04e8 dmails: fix shortlinks to include correct key. 2020-02-03 22:05:58 -06:00
evazion 0321b979d0 dmails: fix respond links being shown to non-owner on show page. 2020-02-03 22:05:58 -06:00
evazion df2573359d mod reports: add show page redirect. 2020-02-03 22:05:58 -06:00
evazion 6ad5a6d50c Update dtext gem. 2020-02-03 22:05:58 -06:00
evazion 3c2a379d6f uploads: replace old upload limits with new upload limits. 2020-02-03 22:05:58 -06:00
evazion 24cb920608 mod reports: include reported user and message in forum post.
Also fix it so that reports against dmails include the key in the dmail
link so that mods can view the reported dmail.
2020-02-03 04:52:12 -06:00
evazion bb2022abed mod reports: autoreport spam and autoban spammers.
* Automatically generate a mod report when a comment, forum post, or
  dmail is detected as spam.
* Automatically ban users that receive too many automatic spam reports
  within a short window of time.
* Automatically mark spam dmails as deleted.
* Change ban threshold from 10 spam reports in 24 hours to 10 reports in 1 hour.
* Change ban length from 3 days to forever.
2020-02-03 04:52:12 -06:00
evazion 170a0e8a48 dmails: remove ability to mark dmails as spam.
Instead of marking messages as spam, users can either report the message
or mark it as deleted.
2020-02-03 04:52:12 -06:00
evazion b8aa223ecb dmails: fix users being able to update other user's dmails.
Fix it being possible to mark dmails belonging to other users as read or
deleted. Anyone who had a permalink to a dmail could update the dmail.
2020-02-03 04:48:50 -06:00
evazion 73219f38ce dmails: fix security issues with dmail permalinks.
Fix a couple security issues related to dmail permalinks. Dmails have a
permalink that you can give to a Mod to let them read the dmail. This is
done with a key param that grants access when the dmail is opened by
another user. The key param had several problems:

* The key contained a full copy of the message's title and body encoded in
  base64. This meant that anyone given a dmail permalink could read the
  full dmail just by decoding the key in the link, without even having
  to open the link.

* The key was derived from the dmail's title and body. If you knew or
  could guess a dmail's title and body you could open the dmail. One
  case when this was possible was when sending dmails. You could send
  someone a dmail, take the permalink from your sent copy of the dmail,
  then increment the dmail id to open the receiver's copy of the dmail.
  Since the sent copy and the received copy both had the same title and
  body, they both had the same dmail key. This let you check whether a
  person had read your dmail, and what time they read it at.

* The key verification was done with an insecure string comparison
  rather than a secure constant-time comparison. This was potentially
  vulnerable to timing attacks.

* Opening a dmail belonging to another user would mark it as read for them.

The fix to all this is to use the dmail's id as the key instead of the
dmail's title and body. This means that old permalinks no longer work.
This is unavoidable given the issues above.

Other changes:

* The name of the 'Permalink' link is now 'Share'.
* Anyone with the 'Share' link can view the dmail, not just Mods.
2020-02-02 22:27:49 -06:00
evazion 6468df6d44 dmails: allow marking dmails as unread.
* Add ability to mark dmails as unread.
* Fix users.unread_dmail_count to not count deleted dmails.
* Fix show action so that API calls don't mark dmails as read.
* Don't show the unread dmail notice on the /dmails page itself.
* Stop using users.has_mail flag.
2020-02-01 15:49:33 -06:00
evazion 067c6a10e7 upload limits: fix point cap being exceeded. 2020-01-31 16:25:06 -06:00
evazion 76630bbf73 dmails: remove search[read] param. 2020-01-31 16:25:06 -06:00
evazion d8eba59cfa dmails: add unread folder, show only received messages by default.
* Add unread and deleted dmail folders.
* Remove dmail_folder cookie (wasn't used).
* Default to the received folder so that we don't show sent messages by default.
2020-01-31 16:24:53 -06:00
evazion f8db577c25 dmails: replace hard deletions with soft deletions.
Turn deletions into soft deletions (set the is_deleted flag) instead of
hard deletions (remove from database). The is_deleted flag actually
already existed, but it was never used before.
2020-01-31 16:24:27 -06:00
evazion 5df8d08aae dmails: allow Members to mark dmails as spam.
* Allow Members to mark dmails as spam or not spam (previously Gold only).
* Replace spam and ham endpoints with single update endpoint.
2020-01-31 02:43:08 -06:00
evazion ea45e44e10 search: remove legacy 'search[sort]' params.
Remove support for the `search[sort]` param on certain index pages. This
hasn't been used for years, and it caused the `search[order]=` param to
be added to pagination links even when the order was blank.
2020-01-31 02:43:08 -06:00
evazion edfef10dc9 Fix #1883: Add <link> elements for all paginated pages.
Add <link rel="prev"> and <link rel="next"> elements to most pages with
pagination. This should work on all index pages, but it won't work for
things like pool or forum topic show pages.

Also remove the <link rel="top"> element (wasn't useful, was just a link
back to the root url).
2020-01-31 02:43:08 -06:00
evazion c7185724d5 controllers: set @current_item globally in respond_with. 2020-01-31 02:43:08 -06:00
evazion 6b066f2cab Fix #4275: Unable to update "banned artist" entries.
Allow all users to view and edit artist entries and wiki pages belonging
to banned artists. There was little need to hide these pages from
Members, it was mainly to appease artists who didn't like us even
linking to their sites.

These restrictions also had multiple flaws:

* Banned artist information was still visible in the API.
* It was still possible to edit banned artists using the API.
* It was still possible for unprivileged users to revert banned
  artist entries or wiki pages to previous versions.
* The restrictions were inconsistent: in various places they were
  either Member-only, Gold-only, or Builder-only.
2020-01-31 02:43:08 -06:00
evazion 74d77c1e23 Update robots.txt.
* Generate /robots.txt dynamically.
* Include link to sitemap.
* Update list of allowed urls.
* Disallow crawling of non-canonical subdomains.
2020-01-31 02:43:07 -06:00
evazion e715bfad8a Fix #4278: Certain users are unable to use the report function. 2020-01-30 12:35:05 -06:00
evazion d29b88d43b models: fix apply_default_order being applied twice. 2020-01-27 17:39:58 -06:00
evazion 588280c8cc views: add embed_wiki helper.
Also remove options to configure names of wiki notice pages. These names
generally don't need to be changed and we already hardcode links to wiki
pages in other places anyway.
2020-01-27 17:14:38 -06:00
evazion af044c45db mod reports: enable reporting for members, add dmail reporting.
* Add ability to report dmails.
* Enable reports for comments, forum posts, and dmails.
* Allow Members to send reports.
* Don't allow users to report the same thing twice.
2020-01-27 17:12:39 -06:00
evazion 812918556f api: fix *_lower params to downcase input. 2020-01-27 11:29:35 -06:00
evazion a30c546417 search: fix embedded metatag to use truthy/falsy. 2020-01-27 11:29:29 -06:00
evazion f76965a6a9 Merge pull request #4273 from BrokenEagle/normalize-array-search
Add parameters for searching attributes by array with case insensitivity
2020-01-27 00:54:33 -06:00
evazion 60dae29fed Merge pull request #4272 from BrokenEagle/fix-wiki-quick-search-check
Fix title parameter checking
2020-01-27 00:52:26 -06:00
evazion 092350caf2 Update ruby gems. 2020-01-27 00:47:36 -06:00
evazion 18affeb4e9 Add new upload limit system (fix #4234). 2020-01-27 00:47:35 -06:00
evazion 3d6084338c Raise statement timeout in development mode. 2020-01-27 00:47:35 -06:00
evazion 5925d3fa62 modqueue: fix typo in page_title. 2020-01-27 00:47:35 -06:00
evazion aa442121bb views: refactor open graph / twitter <meta> tags.
* Fix og:site to og:site_name.
* Fix open graph properties to use <meta property="...">, not <meta name="...">>
* Set og:type, og:site_name, twitter:site globally (not just on post pages).
* Set og:url.
* Remove unused always-resize-images, report-server <meta> tags from
  post show pages.
2020-01-27 00:47:24 -06:00
evazion aeec46b212 views: move inline javascript to app bundle. 2020-01-26 19:16:38 -06:00
evazion 2265721cb2 forum: move inline css to stylesheet. 2020-01-26 19:16:38 -06:00
evazion c36c0b9e7a views: refactor atom feed links.
* Fix comment & forum feeds to include search params.
* Remove global post feeds (only include post feeds on post index).
2020-01-26 19:16:38 -06:00
evazion 815703a922 views: adjust more <meta> descriptions.
* Add <meta> descriptions to more pages.
* Adjust wiki/pool/forum pages to use an excerpt of the first paragraph.
2020-01-26 19:16:38 -06:00
evazion fbe39148cd users: remove opt_out_tracking account setting.
This setting doesn't do anything any more. It was only ever used to
disable tracking of some (but not all) data in Mixpanel, then later in
Matomo.
2020-01-26 19:16:38 -06:00
evazion e10bb0aab1 views: remove old matomo analytics code.
This is no longer used and shouldn't have been hardcoded anyway.
2020-01-26 19:16:38 -06:00
evazion 1a3ce17bf0 Merge pull request #4270 from BrokenEagle/universal-index-redirect
Add universal index redirect
2020-01-25 14:52:52 -06:00
evazion 688b0c5a2b Merge pull request #4271 from BrokenEagle/embedded-notes-search
Add search for embedded notes status
2020-01-25 13:40:52 -06:00
evazion fb9b2bb014 views: update seo title and description of post index page.
Change the title of the post index page to look like this:

    "Danbooru: Anime Image Board" (for the front page)
    "Kantai Collection Art | Danbooru" (for a tag search)

Change the meta description of the front page to look like this:

    Danbooru is the original anime image 'booru. Find over 3.75 million
    anime pictures categorized by over 100 million tags.

Change the meta description for a tag search to look like this:

    Find over 37,168 Azur Lane images on Danbooru. Azur Lane (碧蓝航线)
    (벽람항로) is a Chinese shipgirl-themed side-scrolling shoot 'em up
    mobile game developed by Shanghai Manjuu and Xiamen Yongshi...
2020-01-25 05:44:38 -06:00
evazion 9f40d31748 views: set twitter:title, og:title on all pages. 2020-01-25 05:10:12 -06:00
evazion 6a984de3d5 views: refactor page titles.
Refactor `page_title` helper to automatically include site name.
2020-01-25 01:52:18 -06:00
evazion 95e424ad80 views: remove unused artists/banned template. 2020-01-25 01:33:21 -06:00
evazion ec163f96a8 posts: remove unused appeal! method. 2020-01-24 23:51:37 -06:00
evazion a3e16c167f posts: remove unused undelete! method. 2020-01-24 04:08:56 -06:00
evazion fcb6f96979 forum: add /forum_topic_visits.{json,xml} endpoint.
For debugging purposes only.
2020-01-22 21:30:00 -06:00
evazion cc96f30e47 forum: fix topics being incorrectly marked as unread (again).
Second attempt at 71690cacc. Fix topics on page 2+ being still marked as
unread after the user has marked all topics as read.
2020-01-22 21:09:32 -06:00
evazion 22cb0ea322 models: replace raw LIKE queries with where_like. 2020-01-22 13:21:31 -06:00
evazion 9d71c77524 autocomplete: fix favgroup:<name> returning favgroups for other users.
* Fix favgroup:<name> autocompletion to only return favgroups for the
  current user.
* Add favgroup autocomplete to the /favorite_groups search form.
2020-01-22 11:21:16 -06:00
evazion edaf6323fd /favorite_groups: add search, creators, timestamps, edit/delete links. 2020-01-22 02:03:19 -06:00
evazion 1aadd19663 BURs: fix broken [bur:<id>] links in forum posts.
Fix bulk update requests generating invalid [bur:<id>] links in forum
posts. The id was missing because the BUR created the forum topic in a
before_create hook, which created the post before the BUR was saved so
the BUR didn't have an id yet. Fix regression caused by b4ce2d83.
2020-01-21 19:56:04 -06:00
evazion 0a3d038df9 autocomplete: fix broken wiki page autocomplete.
Fix breakage from 34368272e.
2020-01-21 18:44:02 -06:00