Commit Graph

10417 Commits

Author SHA1 Message Date
evazion
01dbd34d68 docker: use prebuilt docker images for quickstart script.
Use the prebuilt Docker images instead of building them locally in the
Docker Compose script. This is faster, but it means that local changes
to the code will be ignored.
2021-05-21 06:46:06 -05:00
evazion
6ca88f7e19 docker: fix issues with quickstart docker compose script.
* Fix installing the wrong Docker package on Ubuntu.
* Fix the package install steps asking for confirmation.
* Fix missing sudo calls in a couple places.
2021-05-21 06:44:04 -05:00
evazion
bafd341df0 docker: fix the Docker quickstart not working with Ubuntu 18.04.
Fix the quickstart command in the README not working for Ubuntu 18.04.
This was because the Docker Compose file was set to version 3.7, but
Ubuntu 18.04 ships an older version of Docker Compose that only supports
version 3.4.
2021-05-19 01:10:03 -05:00
evazion
24ead500f0 users: use sudo mode when changing email addresses.
When a user tries to change their email, redirect them to the confirm
password page (like Github's sudo mode) instead of having them re-enter
their password on the change email page. This is the same thing we do
when a user updates their API keys. This way we have can use the same
confirm password authentication flow for everything that needs a
password.
2021-05-19 01:10:03 -05:00
evazion
12eacbe76f Merge pull request #4800 from nonamethanks/fix-skeb
Skeb: add support for multi-image posts and fix tests
2021-05-17 12:16:21 -05:00
nonamethanks
1bc266a3db Skeb: add support for multi-image posts and fix tests 2021-05-16 12:50:39 +02:00
evazion
efcfb9a440 users: don't show upgrade notice to banned users.
No point in shilling Danbooru Gold to banned users.
2021-05-15 04:36:22 -05:00
evazion
90a4ac3bf5 users: reword ban notice messages.
* Show the ban length instead of the ban expiration date in ban notices.
* Fix the ban notice to not say "Your account has been temporarily
  banned" when it's a permanent ban.
2021-05-15 04:36:22 -05:00
evazion
8ca757244a users: rename recent_ban to active_ban. 2021-05-15 04:36:22 -05:00
evazion
2537145b02 users: disallow banned users from changing email or deleting account.
This is to prevent people from wiping their email address after they've
been banned and reusing it to verify a new account.
2021-05-15 04:36:22 -05:00
GlassedSilver
4cf62c520c Script unflat (#4798)
Added fix script to unflatten data w/o symlinking
2021-05-15 02:58:56 -05:00
evazion
ffbf7f1ccf tests: fix broken tests. 2021-05-15 02:48:13 -05:00
evazion
cb8cbed0ec views: fix deprecated keyword argument warnings in current_page?. 2021-05-15 02:48:13 -05:00
evazion
ca8bfb9149 Update Ruby gems and Yarn packages. 2021-05-15 02:48:13 -05:00
evazion
e36fb6fee3 /status: show HTTP request headers and client IP.
Show the HTTP request headers and the client IP on the /status page.
This is for debugging request headers added by reverse proxies such as
Cloudflare and Nginx, and for making sure the client IP is correctly set
by the X-Forwarded-For header.
2021-05-06 00:32:24 -05:00
evazion
ba5a2dcd79 Merge pull request #4794 from nonamethanks/fix-skeb
Skeb: fix broken strategy
2021-05-05 05:08:52 -05:00
evazion
0a199e73c5 Merge pull request #4782 from nonamethanks/feat-nicoseiga-spoiler
Nicoseiga: auto-add spoiler tags to commentary
2021-05-05 05:07:13 -05:00
nonamethanks
e95731d58f Skeb: fix broken strategy 2021-05-04 21:18:12 +02:00
evazion
d825bb144b docker: add rake task for building Docker image.
Add a Rake task for building a Docker image. Usage:

* bin/rails danbooru:docker:build
* sudo docker run --rm -it danbooru
2021-05-02 17:42:11 -05:00
evazion
ca34d502c8 docker: include git hash in Docker image.
Put the Git hash of the current commit inside the Docker image built by
Docker Hub. The hash is stored in the REVISION file in the root directory.
2021-05-02 17:40:12 -05:00
evazion
50cb3ef53a /status: fix exception when git hash not present. 2021-04-30 19:30:50 -05:00
evazion
de5ade7641 Add bcrypt_pbkdf gem.
Add the bcrypt_pbkdf gem. This is required to be able to use manually
configured SSH keys with the SFTP storage manager.
2021-04-30 04:59:17 -05:00
evazion
f0ff32bb68 docker: fix missing TLS certs in Docker image.
Fix the ca-certificates package not being installed inside the base
Docker image. This caused uploads from HTTPS sites to fail because TLS
certificates couldn't be validated.
2021-04-30 03:54:38 -05:00
evazion
0593edaabf config: allow specifying location of Danbooru config file.
Allow specifying the location of the `config/danbooru_local_config.rb`
file with the DANBOORU_CONFIG_FILE environment variable. For example:

    DANBOORU_CONFIG_FILE=/etc/danbooru/danbooru_local_config.rb bin/rails server

This is useful in Kubernetes because it lets us mount a directory
containing the config file without it clobbering everything else in the
config/ directory.
2021-04-30 00:06:36 -05:00
evazion
f78d10a591 Fix #4625: Cannot Sign Up on local Danbooru instance: Error ActionController::InvalidAuthenticityToken
Bug: if someone ran server with RAILS_ENV=production, but tried to
access the site under http://, then logging in didn't work. This was
because we set the `secure` flag on cookies when running in the
production environment, because we assumed that in production you were
using HTTPS. If you weren't using HTTPS, then the `secure` flag
prevented session cookies from being sent under http://.

The default now is to use http:// instead of https:// for the
`canonical_url` option.

If you run a Danbooru instance, and you use HTTPS, you will have to
change the `canonical_url` config option to "https://www.mybooru.com".
2021-04-11 17:51:10 -05:00
evazion
9b0fcec7d0 Update Ruby gems and Yarn packages. 2021-04-06 15:51:01 -05:00
nonamethanks
cb6196c259 Nicoseiga: auto-add spoiler tags to commentary 2021-04-06 14:08:49 +02:00
evazion
a2f3ba695c Revert "fix vote buttons."
This reverts commit a0b6047d00.
2021-04-02 03:58:14 -05:00
evazion
243b3264e9 posts: fix posts with .jpeg file extension.
There used to be about 1000 posts with a .jpeg file extension instead of
.jpg. These posts have been fixed manually, so we no longer have to
check for this any more.
2021-04-02 02:41:54 -05:00
evazion
26496bba8d posts: fix error when viewing nonexistent post IDs. 2021-04-01 18:24:26 -05:00
evazion
d58a0bf1e4 Fix #4781: Danbooru Javascript object is broken.
Downgrade Webpack from 5.28.0 to 5.26.3. Breakage was introduced at
5.27.0. It's unclear if this is a regression of issue 12742 in Webpack
or if we're doing something else wrong.

hxxps://github.com-webpack-webpack-issues-12742
hxxps://github.com-webpack-webpack-issues-12851
2021-04-01 03:10:44 -05:00
evazion
a0b6047d00 fix vote buttons. 2021-03-31 23:20:49 -05:00
evazion
fff68e1d16 ruffle: fix issue with ruffle falsely triggering keyboard shortcuts.
Fix issue mentioned in 55980c6fb with Javascript spazzing out on Flash
posts and randomly triggering keyboard shortcuts.

The bug was calling `javascript_pack_tag` twice. This caused the
runtime Javascript chunk to be loaded twice, caused a lot of Javascript
errors that somehow resulted in keyboard shortcuts being triggered.

The fix is to combine both calls into `javascript_pack_tag "application", "flash"`.

hxxps://github.com.rails.webpacker.issues.2932
2021-03-31 22:10:04 -05:00
evazion
946b4cc960 Update CHANGELOG.md. 2021-03-31 21:32:01 -05:00
evazion
4deb8aeea2 uploads: disallow uploading new Flash files.
Flash is dead. It's no longer supported by browsers, it's not
well-supported by emulators, and only two Flash posts were uploaded in
the last year anyway. Old Flash files will continue to exist, but new
Flash uploads will no longer be allowed.
2021-03-31 20:47:35 -05:00
evazion
55980c6fbf Add Ruffle support for Flash files.
Allow viewing Flash posts with the Ruffle emulator.

Known issues:

* Many flash files aren't fully supported.
* In development it sometimes spazzes out and starts triggering random
  keyboard shortcuts when you press any key. This doesn't happen with
  the browser extension.
* We have to put the .wasm file in the public/packs/js directory because
  Ruffle is hardcoded to search for it there.
* If you're running Nginx, you need to make sure you're serving the
  right MIME type for .wasm files or it won't work.
* We're using Some Random Guy's unofficial NPM package for Ruffle, since the
  Ruffle project doesn't publish an official package themselves. We
  should build our own package.

References:

* https://github.com/ruffle-rs/ruffle
* https://github.com/ruffle-rs/ruffle/wiki/Using-Ruffle#configure-webassembly-mime-type
* https://www.npmjs.com/package/ruffle-mirror
2021-03-31 20:20:22 -05:00
evazion
a062c040cb saved searches: fail gracefully when Redis is disabled.
Just make saved searches return nothing when Redis is disabled.
2021-03-30 05:35:42 -05:00
evazion
d59b0234ac config: disable Redis by default.
Fixes Docker containers and development installs that don't have Redis
installed from throwing errors about failing to connect to Redis.

Downstream boorus who do use Redis will need to uncomment this line or
set `redis_url` manually in their config to enable Redis again.
2021-03-30 05:34:49 -05:00
evazion
247934ad83 db: add non-null constraints to all non-optional columns.
Add non-null constraints to all columns that are non-optional. Now the
only columns that are nullable are optional columns.
2021-03-30 04:52:01 -05:00
evazion
803efe8501 Don't use secure cookes on non-HTTPS deployments.
Fixes not being able to login or signup when running in production mode
on a non-HTTPS site.
2021-03-30 03:58:34 -05:00
evazion
172265b4ef Merge pull request #4772 from nonamethanks/fix-alias-implication
Tag Aliases: automatically remove redundant implications
2021-03-30 00:40:11 -05:00
evazion
857776db9e Merge pull request #4779 from nonamethanks/fix-typo
Tag implications: fix typo in validate error
2021-03-30 00:33:45 -05:00
evazion
b3c1c753b3 comments: allow admins to remove comment votes (fix #4640)
Allow admins to remove comment votes by other users. This is done by
clicking the comment score to get to the comment vote list, then
clicking the Remove button on every vote.
2021-03-30 00:10:25 -05:00
evazion
6b91e55283 comments: allow votes to be soft deleted.
Make it so that when a user removes their own vote, the vote is soft
deleted (the is_deleted flag is set) instead of hard deleted.

Changes:

* Add is_deleted flag to comment votes.
* Relax uniqueness constraint so you can have multiple deleted votes on
  the same comment. You can still only have one active vote on the comment.
* Add `soft_delete` method to Deletable concern.
2021-03-30 00:10:22 -05:00
evazion
55129b1819 Rework Dockerfile.
* Optimize Dockerfile to minimize size of the Docker image.
* Specify exact versions of important dependencies (Ruby, Node, Vips) to
  ensure our dependencies are up to date and locked to known versions.
* Install Vips from source because the version that ships with Ubuntu is too old.
* Install FFmpeg from source because otherwise using the Ubuntu package
  pulls in tons of video libraries we don't need, bloating the image.
2021-03-29 06:00:37 -05:00
evazion
6f6a73edd2 Fix "Blocked host" error in development environment.
Fix custom hostnames being blocked in the development environment.
2021-03-29 03:01:06 -05:00
evazion
6404aa9aa9 Log to stdout in development and production.
Always log to stdout instead of logging to files in `log/{development,production}.log`.

For development, logging to files wasn't really useful, and could
generate multi-gigabyte log files if you weren't paying attention. For
production, most systems these days (such as Docker and Systemd) prefer
that you write your logs to stdout so they can manage them.

Fixes the Docker image writing logs inside the container, which never
got rotated and could fill up the container.
2021-03-29 03:01:02 -05:00
evazion
12436c4aa9 Fix IpAddressType autoload warning.
Fix Rails complaining about IpAddressType not being reloaded by hot
reloading:

    DEPRECATION WARNING: Initialization autoloaded the constant IpAddressType.

    Being able to do this is deprecated. Autoloading during initialization is going
    to be an error condition in future versions of Rails.

    Reloading does not reboot the application, and therefore code executed during
    initialization does not run again. So, if you reload IpAddressType, for example,
    the expected changes won't be reflected in that stale Class object.

    This autoloaded constant has been unloaded.

    In order to autoload safely at boot time, please wrap your code in a reloader
    callback this way:

        Rails.application.reloader.to_prepare do
        # Autoload classes and modules needed at boot time here.
        end

    That block runs when the application boots, and every time there is a reload.
    For historical reasons, it may run twice, so it has to be idempotent.

    Check the "Autoloading and Reloading Constants" guide to learn more about how
    Rails autoloads and reloads.
2021-03-29 03:01:02 -05:00
evazion
e2704f6a7b Danbooru::Http: redirect POST to GET on 302.
When a POST request returns a 302 redirect, follow the redirect with a
GET request instead of with a POST request.

HTTP standards leave it unspecified whether a POST request that returns
a 302 redirect should be followed with a GET or with a POST. A GET is
what most browsers use, which means it's what most servers expect.

Fixes the /tagme Discord command not working because when we uploaded
the image to DeepDanbooru, the POST request returned a 302 redirect,
which the server expected us to follow with a GET, not with a POST.

Ref:

* https://stackoverflow.com/questions/17605915/what-is-the-correct-behavior-expected-of-an-http-post-302-redirect-to-get
2021-03-29 03:01:02 -05:00
evazion
07720b04a5 Update Ruby gems and Yarn packages. 2021-03-29 03:01:02 -05:00