mirror of
https://github.com/Lynnesbian/FediBooks/
synced 2024-11-25 08:38:59 +00:00
request and store web push credentials
This commit is contained in:
parent
be0a843c1a
commit
802120540a
2 changed files with 12 additions and 4 deletions
|
@ -18,9 +18,9 @@ CREATE TABLE IF NOT EXISTS `bots` (
|
|||
`handle` VARCHAR(128) PRIMARY KEY,
|
||||
`user_id` INT NOT NULL,
|
||||
`credentials_id` INT NOT NULL,
|
||||
`push_private_key` VARCHAR(256) NOT NULL,
|
||||
`push_public_key` VARCHAR(256) NOT NULL,
|
||||
`push_secret` VARCHAR(256),
|
||||
`push_private_key` BINARY(128) NOT NULL,
|
||||
`push_public_key` BINARY(128) NOT NULL,
|
||||
`push_secret` BINARY(16)),
|
||||
`enabled` BOOLEAN DEFAULT 1,
|
||||
`replies_enabled` BOOLEAN DEFAULT 1,
|
||||
`post_frequency` SMALLINT UNSIGNED DEFAULT 30,
|
||||
|
|
10
webui.py
10
webui.py
|
@ -304,7 +304,15 @@ def bot_create():
|
|||
credentials_id = c.lastrowid
|
||||
mysql.connection.commit()
|
||||
|
||||
c.execute("INSERT INTO `bots` (handle, user_id, credentials_id) VALUES (%s, %s, %s)", (handle, session['user_id'], credentials_id))
|
||||
# get webpush url
|
||||
privated, publicd = client.push_subscription_generate_keys()
|
||||
private = privated['privkey']
|
||||
public = publicd['pubkey']
|
||||
secret = privated['auth']
|
||||
# replace fedibooks.com with cfg['base_uri'] on release
|
||||
client.push_subscription_set("https://fedibooks.com/push/{}".format(handle), publicd, mention_events = True)
|
||||
|
||||
c.execute("INSERT INTO `bots` (handle, user_id, credentials_id, push_public_key, push_private_key, push_secret) VALUES (%s, %s, %s, %s, %s, %s)", (handle, session['user_id'], credentials_id, public, private, secret))
|
||||
mysql.connection.commit()
|
||||
c.close()
|
||||
|
||||
|
|
Loading…
Reference in a new issue