Commit Graph

11055 Commits

Author SHA1 Message Date
evazion
2dfec29da7 uploads: mark old columns as ignored.
Mark old columns as ignored in preparation for dropping them. Make the
rating and tag_string nullable so they don't have to be set when
creating uploads and can be ignored too.
2022-02-03 14:07:09 -06:00
evazion
054b0b4d0a uploads: add thumbnail view to /uploads listing.
Add a thumbnail view to the /uploads listing. You can click on images to
resume the upload, or go to the post if it's already been posted.
2022-02-02 01:50:34 -06:00
evazion
92a4d045e2 media assets: add thumbnail view to /media_assets page.
Add a thumbnail view to the /media_assets page. This page lets you see
all images uploaded to Danbooru by all users (although you can't see who
the uploader is). Also add a link to this page in the subnav bar on the
upload page.
2022-02-02 01:12:56 -06:00
evazion
317d369c6a uploads: fixup bug in 2d47ae70b causing disk uploads to fail.
Fix a nil dereference error when uploading files from disk.
2022-02-01 13:53:52 -06:00
evazion
38ebda7415 uploads: fix errors not being shown for failed disk uploads.
Fix the error message not being shown if an upload from disk failed for
whatever reason, for example because it was a corrupt or unsupported file.
2022-02-01 13:39:08 -06:00
evazion
c4852b3486 rails: fix deprecated #to_s(:format) method.
Fix this deprecation:

    Deprecate passing a format to #to_s in favor of #to_formatted_s in
    Array, Range, Date, DateTime, Time, BigDecimal, Float and, Integer.

https://guides.rubyonrails.org/7_0_release_notes.html#active-support-deprecations
2022-02-01 13:19:50 -06:00
evazion
6d2a2eee59 Fix #4017: Artist tag in upload page should account for aliases
Disallow creating artist entries for aliased tags. Add a fix script to
move existing artist entries for tags that have been aliased.
2022-02-01 12:33:45 -06:00
evazion
2d47ae70b0 Fix #4392: Automatically add artist tag to tagbox on upload page 2022-02-01 09:47:13 -06:00
evazion
8cdc11a3e1 Fix #4983: Weird result for status:DELETED. 2022-02-01 01:59:09 -06:00
evazion
7435f2e516 Fix #4969: Tag changes made by replacements wipe out edits done at the same time.
Lock the post during replacement to ensure we have the latest version of
the tags and to ensure nobody else can modify the post until after the
replacement is finished.
2022-02-01 01:16:00 -06:00
evazion
60a13fd2d5 Fix #4913: Invalid replacements created if an error is raised during replacement
Perform the replacement in a before_create callback so that it runs in a
transaction and if it fails, the transaction will rollback and the
replacement record won't be created.

Doing the replacement in a transaction isn't great because, for one
thing, it could hold the transaction open a long time, which isn't good
for the database. And two, if the transaction rolls back, the database
changes will be undone, but if the replacement file has already been saved
to disk, then it won't be undone, which could result in a dangling file.
2022-02-01 01:14:41 -06:00
evazion
770a6c339a Fix #4972: Display report counters in user profiles
* Add ability to search modreports by reported user.
* Display "received:N submitted:N" modreport counters in profiles.
2022-01-31 21:58:14 -06:00
evazion
bb65a95a86 Fix #4981: ruffle broken :(
* Switch to the official Ruffle NPM package.
* Fix `core.ruffle.$hash.js` not being imported.
2022-01-31 14:39:30 -06:00
evazion
2bb5ad78fb tests: fix broken tests.
* Fix a bug where creating posts failed if IQDB wasn't configured.
* Fix broken Skeb test caused by changed URL.
* Fix broken IP geolocation tests caused by API returning different data.
* Fix broken post regeneration tests.
2022-01-31 14:17:14 -06:00
evazion
65b7c08e33 post replacements: refactor and fix tests.
* Move replacement tests from test/unit/upload_service_test.rb to
  test/functional/post_replacement_controller_test.rb
* Move UploadService::Replacer to PostReplacementProcessor.
* Fix a minor bug where if you used the API to replace a post with a file,
  the replacement would fail unless you passed an empty string for the
  replacement_url.
2022-01-31 14:17:14 -06:00
evazion
61c043c6b1 posts: normalize Unicode to NFC form in post sources.
Fix strings like "pokémon" (NFD form) and "pokémon" (NFC form) being
considered different strings in sources.

Also add a fix script to fix existing sources. There were only 15 posts
with unnormalized sources.
2022-01-31 14:16:49 -06:00
evazion
0132c5f0a5 media assets: fix md5 leak in media assets.
Fix unprivileged users being able to see images and MD5 hashes of media
assets belonging to censored posts.
2022-01-30 23:23:55 -06:00
evazion
2fe058eccf uploads: fix tag warnings not being shown after upload.
Fix the warnings about not having enough tags, or not having an artist
or copyright tag, not being shown after creating a new post.
2022-01-30 22:39:54 -06:00
evazion
4ad554e28b uploads: show videos and ugoiras on upload page.
* On the upload page, show the video when uploading a video or ugoira.
* On the upload page, show the filesize and resolution beneath the
  image, instead of above it.
* On the media asset show page, show the full video or ugoira instead of
  just the thumbnail.
2022-01-30 22:39:54 -06:00
evazion
5d2996d0c2 media assets: add media asset preview component.
Add a view component for rendering thumbnails for media assets.

This lets us properly show thumbnails on the upload listing page and the
media assets listing page, including support for high pixel density thumbnails
and video length icons for videos.

Fixes not being able to see thumbnails on the /media_assets page.

This is mostly copy/pasted from the post preview component. FIXME: don't duplicate code.
2022-01-30 22:39:54 -06:00
evazion
43c4158d36 uploads: merge tags when a duplicate is uploaded (fix #3130).
Automatically merge tags when uploading a duplicate.

There are two cases:

* You try to upload an image, but it's already on Danbooru. In this case
  you'll be immediately redirected to the original post, before you
  can start tagging the upload.

* You're uploading an image, it wasn't a dupe when you first opened the
  upload page, but you got sniped while tagging it. In this case your tags
  will be merged with the original post, and you will be redirected to the
  original post.

There are a few corner cases:

* If you don't have permission to edit the original post, for example
  because it's banned or has a censored tag, then your tags won't be
  merged and will be silently ignored.

* Only the tags, rating, and parent ID will be merged. The source and
  artist commentary won't be merged. This is so that if an artist uploads
  the exact same file to multiple sites, the new source won't override
  the original source.

* Some tags might be contradictory. For example, the new post might
  be tagged translation_request, but the original post might already be
  translated. It's up to the user to fix these things afterwards.
2022-01-30 03:14:22 -06:00
evazion
dadd6aed47 uploads: fix not being able to change the source field during upload.
Fix not being able to change the post's source when submitting the
upload. For example, if you were uploading a Twitter image from a direct
Twitter image URL, and you tried to change the source to the tweet URL
on the upload page before creating the post, then the source would be
ignored when the post was created.
2022-01-30 03:13:49 -06:00
evazion
892c3899a8 uploads: fix more tests. 2022-01-29 23:23:29 -06:00
evazion
810c3da939 favgroups: fix typo in new favgroup dialog. 2022-01-29 15:59:44 -06:00
evazion
09d6c602be uploads: fix long filenames not word-wrapping.
Fix a bug where, when uploading a file from disk, if the filename was
too long, it wouldn't get word-wrapped and could break out of the
containing element.
2022-01-29 05:14:49 -06:00
evazion
e1d4de1c22 uploads: fix double paste bug.
Fix a bug where, when pasting an URL directly into the URL field, the
URL would be pasted twice, which would cause the upload to fail because
the URL was invalid.
2022-01-29 05:14:49 -06:00
evazion
11b7bcac91 uploads: fix broken tests.
* Fix broken upload tests.
* Fix uploads to return an error if both a file and a source are given
  at the same time, or if neither are given. Also fix the error message
  in this case so that it doesn't include "base" at the start of the string.
* Fix uploads to percent-encode any Unicode characters in the source URL.
* Add a max filesize validation to media assets.
2022-01-29 05:14:49 -06:00
evazion
5d0c14d2bd uploads: fix file upload component colors in dark mode.
Fix the file upload component blending into the background in dark mode.
2022-01-28 21:15:08 -06:00
evazion
21dcf53dcb uploads: show similar images for disk uploads.
Fix the upload page so that it shows similar images (IQDB matches) for
files uploaded from your computer. Before this only worked for files
uploaded from a source.
2022-01-28 21:07:06 -06:00
evazion
c0730630af uploads: fixup issues causing Rails to fail to boot.
* Fix `UploadService is not a class` error.
* Update list of available job classes (remove UploadPreprocessorDelayedStartJob,
  UploadServiceDelayedStartJob, add ProcessUploadJob).
2022-01-28 04:32:20 -06:00
evazion
abdab7a0a8 uploads: rework upload process.
Rework the upload process so that files are saved to Danbooru first
before the user starts tagging the upload.

The main user-visible change is that you have to select the file first
before you can start tagging it. Saving the file first lets us fix a
number of problems:

* We can check for dupes before the user tags the upload.
* We can perform dupe checks and show preview images for users not using the bookmarklet.
* We can show preview images without having to proxy images through Danbooru.
* We can show previews of videos and ugoira files.
* We can reliably show the filesize and resolution of the image.
* We can let the user save files to upload later.
* We can get rid of a lot of spaghetti code related to preprocessing
  uploads. This was the cause of most weird "md5 confirmation doesn't
  match md5" errors.

(Not all of these are implemented yet.)

Internally, uploading is now a two-step process: first we create an upload
object, then we create a post from the upload. This is how it works:

* The user goes to /uploads/new and chooses a file or pastes an URL into
  the file upload component.
* The file upload component calls `POST /uploads` to create an upload.
* `POST /uploads` immediately returns a new upload object in the `pending` state.
* Danbooru starts processing the upload in a background job (downloading,
  resizing, and transferring the image to the image servers).
* The file upload component polls `/uploads/$id.json`, checking the
  upload `status` until it returns `completed` or `error`.
* When the upload status is `completed`, the user is redirected to /uploads/$id.
* On the /uploads/$id page, the user can tag the upload and submit it.
* The upload form calls `POST /posts` to create a new post from the upload.
* The user is redirected to the new post.

This is the data model:

* An upload represents a set of files uploaded to Danbooru by a user.
  Uploaded files don't have to belong to a post. An upload has an
  uploader, a status (pending, processing, completed, or error), a
  source (unless uploading from a file), and a list of media assets
  (image or video files).

* There is a has-and-belongs-to-many relationship between uploads and
  media assets. An upload can have many media assets, and a media asset
  can belong to multiple uploads. Uploads are joined to media assets
  through a upload_media_assets table.

  An upload could potentially have multiple media assets if it's a Pixiv
  or Twitter gallery. This is not yet implemented (at the moment all
  uploads have one media asset).

  A media asset can belong to multiple uploads if multiple people try
  to upload the same file, or if the same user tries to upload the same
  file more than once.

New features:

* On the upload page, you can press Ctrl+V to paste an URL and immediately upload it.
* You can save files for upload later. Your saved files are at /uploads.

Fixes:

* Improved error messages when uploading invalid files, bad URLs, and
  when forgetting the rating.
2022-01-28 04:13:22 -06:00
evazion
f11c46b4f8 uploads: stop pruning uploads. 2022-01-28 04:13:22 -06:00
evazion
6fbca01a23 css: make footer sticky. 2022-01-28 04:13:22 -06:00
evazion
c292c457ca Merge pull request #4977 from ZipFile/svg-favicon
Add svg favicon
2022-01-26 01:33:39 -06:00
evazion
c4775d96a9 uploads: add upload_media_assets table.
Add a join table that allows multiple media assets (images or videos) to
be attached to uploads. This is for a future ability to upload multiple
files at once.
2022-01-25 16:10:53 -06:00
ZipFile
f926956697 Add svg favicon 2022-01-25 19:42:24 +00:00
evazion
a1d650848b forum: fix undelete option not appearing in menu.
Fix the option to undelete forum posts not appearing in the context menu
for Moderators.
2022-01-25 12:43:55 -06:00
evazion
5c97595c6a posts: fix post view counts not being recorded.
Broken by the upgrade to webpacker-6.0.0.rc.6. Webpacker now defaults to
loading the Javascript bundle with `<script src="..." defer>`, which
means Javascript won't be loaded until after the page loads, which broke
the code that records view counts because it uses jQuery and jQuery
wasn't loaded yet.
2022-01-24 01:53:30 -06:00
evazion
0213f8d76a css: remove image-rendering: smooth.
Contrary to its name, `image-rendering: smooth` resulted in pixelated
edges when images were downscaled to fit the browser window. This only
affected Firefox because other browsers don't support `smooth`.
2022-01-22 22:04:30 -06:00
evazion
f02f3fcc6f css: fix text sizes in desktop mode on mobile.
Disable font boosting on mobile. By default, when desktop mode is
enabled on mobile, mobile browsers will automagically increase the size
of text. Usually they do so poorly, making things like headers smaller
than body text, which breaks the layout.

Fixes regression in d6b1302e0.
2022-01-22 21:33:34 -06:00
evazion
893fa1e948 css: fix <input> margins.
Fix regression in d6b1302e0. Fixes the related tags list having extra
space between tags because of default margins around the <input> checkboxes.
2022-01-22 18:29:33 -06:00
evazion
d2a24e6b10 Fix #4971: NoMethodError when trying to display some modreports.
Delete modreports for hard-deleted comments. There were a total of six
invalid modreports for deleted comments.
2022-01-22 18:12:07 -06:00
evazion
90be15e0b5 Fix #4973: Wiki pages json index returns 404.
Fix regression introduced in 0db20e0ca. Setting `format: false` on the
wiki pages resource disabled format negotiation on all wiki page routes,
not just the show page, which meant /wiki_pages.json no longer worked.

The fix to monkey patch the internal Rails method that parses the file
extension from the URL, and have it ignore everything but the .html,
.json, .js, and .xml extensions. This is really hacky and may break in
future Rails releases.
2022-01-22 16:52:20 -06:00
evazion
a4279ceff2 css: hide "*" next to required form fields.
Fix regression in d6b1302e.
2022-01-22 00:08:14 -06:00
evazion
56722df753 forum: delete posts when topic is deleted.
Fix it so that when a forum topic is deleted, all posts in the topic are
deleted too. Also make it so that when a forum topic is undeleted, all
posts in it are undeleted too.

Before when a topic was deleted, only the topic itself was marked as
deleted, not the posts inside the topic. This meant that when a spam
topic was deleted, the OP wouldn't be marked as deleted, so any
modreports against it wouldn't be marked as handled.

Also change it so that it's not possible to undelete a post in a deleted
topic, or to delete the OP of a topic without deleting the topic itself.

Finally, add a fix script to delete all active posts in deleted topics,
and to undelete all deleted OPs in active topics.
2022-01-21 22:35:20 -06:00
evazion
befdb87bd5 Merge pull request #4970 from GiantFrog/master
Fix bug with configurable upload limits
2022-01-21 18:40:21 -06:00
GiantFrog
d69256cf75 Fix bug where env variables need to be ints 2022-01-21 16:55:08 -07:00
evazion
2fff563027 css: fix <li> line-height. 2022-01-20 21:50:48 -06:00
evazion
8d9cee5ad0 modreports: don't allow reporting content more than 1 year old.
Don't allow users to report comments, forum posts, or dmails that are
more than 1 year old.
2022-01-20 21:50:31 -06:00
evazion
5fd0d498a4 modreports: log modaction when report is handled or rejected. 2022-01-20 21:28:29 -06:00