mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
Implement data model changes to support new WebDAV Push spec
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
ALTER TABLE davpush_subscriptions
|
||||
DROP public_key,
|
||||
DROP public_key_type,
|
||||
DROP auth_secret;
|
||||
@@ -0,0 +1,7 @@
|
||||
-- Old subscriptions are useless anyway
|
||||
DELETE FROM davpush_subscriptions;
|
||||
|
||||
-- Now the new columns can also be set NOT NULL
|
||||
ALTER TABLE davpush_subscriptions ADD public_key TEXT NOT NULL;
|
||||
ALTER TABLE davpush_subscriptions ADD public_key_type TEXT NOT NULL;
|
||||
ALTER TABLE davpush_subscriptions ADD auth_secret TEXT NOT NULL;
|
||||
@@ -7,7 +7,7 @@ impl SubscriptionStore for SqliteStore {
|
||||
async fn get_subscriptions(&self, topic: &str) -> Result<Vec<Subscription>, Error> {
|
||||
Ok(sqlx::query_as!(
|
||||
Subscription,
|
||||
r#"SELECT id, topic, expiration, push_resource
|
||||
r#"SELECT id, topic, expiration, push_resource, public_key, public_key_type, auth_secret
|
||||
FROM davpush_subscriptions
|
||||
WHERE (topic) = (?)"#,
|
||||
topic
|
||||
@@ -20,7 +20,7 @@ impl SubscriptionStore for SqliteStore {
|
||||
async fn get_subscription(&self, id: &str) -> Result<Subscription, Error> {
|
||||
Ok(sqlx::query_as!(
|
||||
Subscription,
|
||||
r#"SELECT id, topic, expiration, push_resource
|
||||
r#"SELECT id, topic, expiration, push_resource, public_key, public_key_type, auth_secret
|
||||
FROM davpush_subscriptions
|
||||
WHERE (id) = (?)"#,
|
||||
id
|
||||
@@ -32,11 +32,14 @@ impl SubscriptionStore for SqliteStore {
|
||||
|
||||
async fn upsert_subscription(&self, sub: Subscription) -> Result<bool, Error> {
|
||||
sqlx::query!(
|
||||
r#"INSERT OR REPLACE INTO davpush_subscriptions (id, topic, expiration, push_resource) VALUES (?, ?, ?, ?)"#,
|
||||
r#"INSERT OR REPLACE INTO davpush_subscriptions (id, topic, expiration, push_resource, public_key, public_key_type, auth_secret) VALUES (?, ?, ?, ?, ?, ?, ?)"#,
|
||||
sub.id,
|
||||
sub.topic,
|
||||
sub.expiration,
|
||||
sub.push_resource
|
||||
sub.push_resource,
|
||||
sub.public_key,
|
||||
sub.public_key_type,
|
||||
sub.auth_secret
|
||||
).execute(&self.db).await.map_err(crate::Error::from)?;
|
||||
// TODO: Correctly return whether a subscription already existed
|
||||
Ok(false)
|
||||
|
||||
Reference in New Issue
Block a user