Skip to content

Commit

Permalink
Add Rake task for generate VAPID key (mastodon#4195)
Browse files Browse the repository at this point in the history
* Add Rake task for generate VAPID key

* edit config/initializers/vapid.rb
  • Loading branch information
ykzts authored and Gargron committed Jul 14, 2017
1 parent 489d162 commit 0fa9dd8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .env.production.sample
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ OTP_SECRET=
# You should only generate this once per instance. If you later decide to change it, all push subscription will
# be invalidated, requiring the users to access the website again to resubscribe.
#
# ruby -e "require 'webpush'; vapid_key = Webpush.generate_key; puts vapid_key.private_key; puts vapid_key.public_key;"
# Generate with `rake mastodon:webpush:generate_vapid_key` task (`docker-compose run --rm web rake mastodon:webpush:generate_vapid_key` if you use docker compose)
#
# For more information visit https://rossta.net/blog/using-the-web-push-api-with-vapid.html
VAPID_PRIVATE_KEY=
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/vapid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# You should only generate this once per instance. If you later decide to change it, all push subscription will
# be invalidated, requiring the users to access the website again to resubscribe.
#
# ruby -e "require 'webpush'; vapid_key = Webpush.generate_key; puts vapid_key.private_key; puts vapid_key.public_key;"
# Generate with `rake mastodon:webpush:generate_vapid_key` task (`docker-compose run --rm web rake mastodon:webpush:generate_vapid_key` if you use docker compose)
#
# For more information visit https://rossta.net/blog/using-the-web-push-api-with-vapid.html

Expand Down
9 changes: 9 additions & 0 deletions lib/tasks/mastodon.rake
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ namespace :mastodon do
end
end

namespace :webpush do
desc 'Generate VAPID key'
task generate_vapid_key: :environment do
vapid_key = Webpush.generate_key
puts "VAPID_PRIVATE_KEY=#{vapid_key.private_key}"
puts "VAPID_PUBLIC_KEY=#{vapid_key.public_key}"
end
end

namespace :maintenance do
desc 'Update counter caches'
task update_counter_caches: :environment do
Expand Down

0 comments on commit 0fa9dd8

Please sign in to comment.