-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #224 from enpitut2018/feature/push_yell
Feature/push yell
- Loading branch information
Showing
5 changed files
with
148 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,108 +1,108 @@ | ||
# This file is auto-generated from the current state of the database. Instead | ||
# of editing this file, please use the migrations feature of Active Record to | ||
# incrementally modify your database, and then regenerate this schema definition. | ||
# | ||
# Note that this schema.rb definition is the authoritative source for your | ||
# database schema. If you need to create the application database on another | ||
# system, you should be using db:schema:load, not running all the migrations | ||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations | ||
# you'll amass, the slower it'll run and the greater likelihood for issues). | ||
# | ||
# It's strongly recommended that you check this file into your version control system. | ||
|
||
ActiveRecord::Schema.define(version: 20181213203003) do | ||
|
||
create_table "audio_tests", force: :cascade do |t| | ||
t.datetime "created_at", null: false | ||
t.datetime "updated_at", null: false | ||
end | ||
|
||
create_table "contributions", force: :cascade do |t| | ||
t.integer "user_id", null: false | ||
t.integer "task_id", null: false | ||
t.datetime "finished_at" | ||
t.boolean "finality", default: false, null: false | ||
t.datetime "created_at", null: false | ||
t.datetime "updated_at", null: false | ||
t.boolean "status", default: true, null: false | ||
t.index ["task_id"], name: "index_contributions_on_task_id" | ||
t.index ["user_id"], name: "index_contributions_on_user_id" | ||
end | ||
|
||
create_table "groups", force: :cascade do |t| | ||
t.integer "parent_id" | ||
t.string "name", null: false | ||
t.integer "user_id", null: false | ||
t.integer "importance" | ||
t.datetime "deadline" | ||
t.datetime "created_at", null: false | ||
t.datetime "updated_at", null: false | ||
t.boolean "public", default: true, null: false | ||
end | ||
|
||
create_table "jwt_blacklists", force: :cascade do |t| | ||
t.string "jti", null: false | ||
t.datetime "exp", null: false | ||
t.index ["jti"], name: "index_jwt_blacklists_on_jti" | ||
end | ||
|
||
create_table "oauths", force: :cascade do |t| | ||
t.integer "user_id" | ||
t.string "access_token" | ||
t.string "access_token_secret" | ||
t.datetime "created_at", null: false | ||
t.datetime "updated_at", null: false | ||
end | ||
|
||
create_table "tasks", force: :cascade do |t| | ||
t.string "name", null: false | ||
t.datetime "deadline", null: false | ||
t.integer "importance", null: false | ||
t.text "note" | ||
t.integer "status", default: 1, null: false | ||
t.datetime "start_time" | ||
t.datetime "finish_time" | ||
t.datetime "created_at", null: false | ||
t.datetime "updated_at", null: false | ||
t.integer "user_id" | ||
t.integer "urgency" | ||
t.integer "priority" | ||
t.integer "group_id", null: false | ||
t.integer "clap", default: 0, null: false | ||
t.index ["deadline"], name: "index_tasks_on_deadline" | ||
end | ||
|
||
create_table "users", force: :cascade do |t| | ||
t.string "email", default: "", null: false | ||
t.string "encrypted_password", default: "", null: false | ||
t.string "reset_password_token" | ||
t.datetime "reset_password_sent_at" | ||
t.datetime "remember_created_at" | ||
t.integer "sign_in_count", default: 0, null: false | ||
t.datetime "current_sign_in_at" | ||
t.datetime "last_sign_in_at" | ||
t.string "current_sign_in_ip" | ||
t.string "last_sign_in_ip" | ||
t.datetime "created_at", null: false | ||
t.datetime "updated_at", null: false | ||
t.string "confirmation_token" | ||
t.datetime "confirmed_at" | ||
t.datetime "confirmation_sent_at" | ||
t.string "unconfirmed_email" | ||
t.string "failed_attempts", default: "0", null: false | ||
t.string "unlock_token" | ||
t.datetime "locked_at" | ||
t.string "provider" | ||
t.string "uid" | ||
t.string "username" | ||
t.string "endpoint" | ||
t.string "key" | ||
t.string "auth" | ||
t.string "encoding" | ||
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true | ||
t.index ["email"], name: "index_users_on_email", unique: true | ||
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true | ||
t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true | ||
end | ||
|
||
end | ||
# This file is auto-generated from the current state of the database. Instead | ||
# of editing this file, please use the migrations feature of Active Record to | ||
# incrementally modify your database, and then regenerate this schema definition. | ||
# | ||
# Note that this schema.rb definition is the authoritative source for your | ||
# database schema. If you need to create the application database on another | ||
# system, you should be using db:schema:load, not running all the migrations | ||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations | ||
# you'll amass, the slower it'll run and the greater likelihood for issues). | ||
# | ||
# It's strongly recommended that you check this file into your version control system. | ||
|
||
ActiveRecord::Schema.define(version: 20181213203003) do | ||
|
||
create_table "audio_tests", force: :cascade do |t| | ||
t.datetime "created_at", null: false | ||
t.datetime "updated_at", null: false | ||
end | ||
|
||
create_table "contributions", force: :cascade do |t| | ||
t.integer "user_id", null: false | ||
t.integer "task_id", null: false | ||
t.datetime "finished_at" | ||
t.boolean "finality", default: false, null: false | ||
t.datetime "created_at", null: false | ||
t.datetime "updated_at", null: false | ||
t.boolean "status", default: true, null: false | ||
t.index ["task_id"], name: "index_contributions_on_task_id" | ||
t.index ["user_id"], name: "index_contributions_on_user_id" | ||
end | ||
|
||
create_table "groups", force: :cascade do |t| | ||
t.integer "parent_id" | ||
t.string "name", null: false | ||
t.integer "user_id", null: false | ||
t.integer "importance" | ||
t.datetime "deadline" | ||
t.datetime "created_at", null: false | ||
t.datetime "updated_at", null: false | ||
t.boolean "public", default: true, null: false | ||
end | ||
|
||
create_table "jwt_blacklists", force: :cascade do |t| | ||
t.string "jti", null: false | ||
t.datetime "exp", null: false | ||
t.index ["jti"], name: "index_jwt_blacklists_on_jti" | ||
end | ||
|
||
create_table "oauths", force: :cascade do |t| | ||
t.integer "user_id" | ||
t.string "access_token" | ||
t.string "access_token_secret" | ||
t.datetime "created_at", null: false | ||
t.datetime "updated_at", null: false | ||
end | ||
|
||
create_table "tasks", force: :cascade do |t| | ||
t.string "name", null: false | ||
t.datetime "deadline", null: false | ||
t.integer "importance", null: false | ||
t.text "note" | ||
t.integer "status", default: 1, null: false | ||
t.datetime "start_time" | ||
t.datetime "finish_time" | ||
t.datetime "created_at", null: false | ||
t.datetime "updated_at", null: false | ||
t.integer "user_id" | ||
t.integer "urgency" | ||
t.integer "priority" | ||
t.integer "group_id", null: false | ||
t.integer "clap", default: 0, null: false | ||
t.index ["deadline"], name: "index_tasks_on_deadline" | ||
end | ||
|
||
create_table "users", force: :cascade do |t| | ||
t.string "email", default: "", null: false | ||
t.string "encrypted_password", default: "", null: false | ||
t.string "reset_password_token" | ||
t.datetime "reset_password_sent_at" | ||
t.datetime "remember_created_at" | ||
t.integer "sign_in_count", default: 0, null: false | ||
t.datetime "current_sign_in_at" | ||
t.datetime "last_sign_in_at" | ||
t.string "current_sign_in_ip" | ||
t.string "last_sign_in_ip" | ||
t.datetime "created_at", null: false | ||
t.datetime "updated_at", null: false | ||
t.string "confirmation_token" | ||
t.datetime "confirmed_at" | ||
t.datetime "confirmation_sent_at" | ||
t.string "unconfirmed_email" | ||
t.string "failed_attempts", default: "0", null: false | ||
t.string "unlock_token" | ||
t.datetime "locked_at" | ||
t.string "provider" | ||
t.string "uid" | ||
t.string "username" | ||
t.string "endpoint" | ||
t.string "key" | ||
t.string "auth" | ||
t.string "encoding" | ||
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true | ||
t.index ["email"], name: "index_users_on_email", unique: true | ||
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true | ||
t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
##################################################################################### | ||
##################################################################################### | ||
#第一引数のclientにはcurrent_user.idとかでユーザーモデルを検索した結果のActiveRecordsを | ||
#第二引数のbodyには{name: "hoge"}みたいな形でjsonっぽく書いた文字列を渡してください | ||
##################################################################################### | ||
##################################################################################### | ||
|
||
def notification(client, body) | ||
payload = { | ||
endpoint: client.endpoint, # ブラウザでregistration.pushManager.getSubscription()で取得したsubscriptionのendpoint | ||
p256dh: client.key, # 同じくsubscriptionのp256dh | ||
auth: client.auth, # 同じくsubscriptionのauth | ||
ttl: 86400, # 任意の値 | ||
vapid: { | ||
subject: 'https://task-driver.sukiyaki.party', # APPサーバのコンタクト用URIとか('mailto:' もしくは 'https://') | ||
public_key: ENV['VAPID_PUBLIC_KEY'], | ||
private_key: ENV['VAPID_SECRET_KEY'] | ||
}, | ||
message: { | ||
title: "task", | ||
body: body | ||
}.to_json | ||
} | ||
Webpush.payload_send(payload) #送信 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters