diff options
Diffstat (limited to 'vendor/go.mau.fi/whatsmeow/store/sqlstore')
-rw-r--r-- | vendor/go.mau.fi/whatsmeow/store/sqlstore/container.go | 3 | ||||
-rw-r--r-- | vendor/go.mau.fi/whatsmeow/store/sqlstore/store.go | 27 | ||||
-rw-r--r-- | vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrade.go | 2 |
3 files changed, 18 insertions, 14 deletions
diff --git a/vendor/go.mau.fi/whatsmeow/store/sqlstore/container.go b/vendor/go.mau.fi/whatsmeow/store/sqlstore/container.go index b7c0a7c4..8a26fc53 100644 --- a/vendor/go.mau.fi/whatsmeow/store/sqlstore/container.go +++ b/vendor/go.mau.fi/whatsmeow/store/sqlstore/container.go @@ -181,7 +181,8 @@ const ( adv_key, adv_details, adv_account_sig, adv_account_sig_key, adv_device_sig, platform, business_name, push_name) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15) - ON CONFLICT (jid) DO UPDATE SET platform=$12, business_name=$13, push_name=$14 + ON CONFLICT (jid) DO UPDATE + SET platform=excluded.platform, business_name=excluded.business_name, push_name=excluded.push_name ` deleteDeviceQuery = `DELETE FROM whatsmeow_device WHERE jid=$1` ) diff --git a/vendor/go.mau.fi/whatsmeow/store/sqlstore/store.go b/vendor/go.mau.fi/whatsmeow/store/sqlstore/store.go index 01ec2056..abea5fe2 100644 --- a/vendor/go.mau.fi/whatsmeow/store/sqlstore/store.go +++ b/vendor/go.mau.fi/whatsmeow/store/sqlstore/store.go @@ -67,7 +67,7 @@ var _ store.ContactStore = (*SQLStore)(nil) const ( putIdentityQuery = ` INSERT INTO whatsmeow_identity_keys (our_jid, their_id, identity) VALUES ($1, $2, $3) - ON CONFLICT (our_jid, their_id) DO UPDATE SET identity=$3 + ON CONFLICT (our_jid, their_id) DO UPDATE SET identity=excluded.identity ` deleteAllIdentitiesQuery = `DELETE FROM whatsmeow_identity_keys WHERE our_jid=$1 AND their_id LIKE $2` deleteIdentityQuery = `DELETE FROM whatsmeow_identity_keys WHERE our_jid=$1 AND their_id=$2` @@ -108,7 +108,7 @@ const ( hasSessionQuery = `SELECT true FROM whatsmeow_sessions WHERE our_jid=$1 AND their_id=$2` putSessionQuery = ` INSERT INTO whatsmeow_sessions (our_jid, their_id, session) VALUES ($1, $2, $3) - ON CONFLICT (our_jid, their_id) DO UPDATE SET session=$3 + ON CONFLICT (our_jid, their_id) DO UPDATE SET session=excluded.session ` deleteAllSessionsQuery = `DELETE FROM whatsmeow_sessions WHERE our_jid=$1 AND their_id LIKE $2` deleteSessionQuery = `DELETE FROM whatsmeow_sessions WHERE our_jid=$1 AND their_id=$2` @@ -259,7 +259,7 @@ const ( getSenderKeyQuery = `SELECT sender_key FROM whatsmeow_sender_keys WHERE our_jid=$1 AND chat_id=$2 AND sender_id=$3` putSenderKeyQuery = ` INSERT INTO whatsmeow_sender_keys (our_jid, chat_id, sender_id, sender_key) VALUES ($1, $2, $3, $4) - ON CONFLICT (our_jid, chat_id, sender_id) DO UPDATE SET sender_key=$4 + ON CONFLICT (our_jid, chat_id, sender_id) DO UPDATE SET sender_key=excluded.sender_key ` ) @@ -279,7 +279,8 @@ func (s *SQLStore) GetSenderKey(group, user string) (key []byte, err error) { const ( putAppStateSyncKeyQuery = ` INSERT INTO whatsmeow_app_state_sync_keys (jid, key_id, key_data, timestamp, fingerprint) VALUES ($1, $2, $3, $4, $5) - ON CONFLICT (jid, key_id) DO UPDATE SET key_data=$3, timestamp=$4, fingerprint=$5 + ON CONFLICT (jid, key_id) DO UPDATE + SET key_data=excluded.key_data, timestamp=excluded.timestamp, fingerprint=excluded.fingerprint ` getAppStateSyncKeyQuery = `SELECT key_data, timestamp, fingerprint FROM whatsmeow_app_state_sync_keys WHERE jid=$1 AND key_id=$2` ) @@ -301,7 +302,7 @@ func (s *SQLStore) GetAppStateSyncKey(id []byte) (*store.AppStateSyncKey, error) const ( putAppStateVersionQuery = ` INSERT INTO whatsmeow_app_state_version (jid, name, version, hash) VALUES ($1, $2, $3, $4) - ON CONFLICT (jid, name) DO UPDATE SET version=$3, hash=$4 + ON CONFLICT (jid, name) DO UPDATE SET version=excluded.version, hash=excluded.hash ` getAppStateVersionQuery = `SELECT version, hash FROM whatsmeow_app_state_version WHERE jid=$1 AND name=$2` deleteAppStateVersionQuery = `DELETE FROM whatsmeow_app_state_version WHERE jid=$1 AND name=$2` @@ -435,11 +436,11 @@ const ( ` putPushNameQuery = ` INSERT INTO whatsmeow_contacts (our_jid, their_jid, push_name) VALUES ($1, $2, $3) - ON CONFLICT (our_jid, their_jid) DO UPDATE SET push_name=$3 + ON CONFLICT (our_jid, their_jid) DO UPDATE SET push_name=excluded.push_name ` putBusinessNameQuery = ` INSERT INTO whatsmeow_contacts (our_jid, their_jid, business_name) VALUES ($1, $2, $3) - ON CONFLICT (our_jid, their_jid) DO UPDATE SET business_name=$3 + ON CONFLICT (our_jid, their_jid) DO UPDATE SET business_name=excluded.business_name ` getContactQuery = ` SELECT first_name, full_name, push_name, business_name FROM whatsmeow_contacts WHERE our_jid=$1 AND their_jid=$2 @@ -470,23 +471,25 @@ func (s *SQLStore) PutPushName(user types.JID, pushName string) (bool, string, e return false, "", nil } -func (s *SQLStore) PutBusinessName(user types.JID, businessName string) error { +func (s *SQLStore) PutBusinessName(user types.JID, businessName string) (bool, string, error) { s.contactCacheLock.Lock() defer s.contactCacheLock.Unlock() cached, err := s.getContact(user) if err != nil { - return err + return false, "", err } if cached.BusinessName != businessName { _, err = s.db.Exec(putBusinessNameQuery, s.JID, user, businessName) if err != nil { - return err + return false, "", err } + previousName := cached.BusinessName cached.BusinessName = businessName cached.Found = true + return true, previousName, nil } - return nil + return false, "", nil } func (s *SQLStore) PutContactName(user types.JID, firstName, fullName string) error { @@ -643,7 +646,7 @@ func (s *SQLStore) GetAllContacts() (map[types.JID]types.ContactInfo, error) { const ( putChatSettingQuery = ` INSERT INTO whatsmeow_chat_settings (our_jid, chat_jid, %[1]s) VALUES ($1, $2, $3) - ON CONFLICT (our_jid, chat_jid) DO UPDATE SET %[1]s=$3 + ON CONFLICT (our_jid, chat_jid) DO UPDATE SET %[1]s=excluded.%[1]s ` getChatSettingsQuery = ` SELECT muted_until, pinned, archived FROM whatsmeow_chat_settings WHERE our_jid=$1 AND chat_jid=$2 diff --git a/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrade.go b/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrade.go index 37bd7c29..4a4b2ca7 100644 --- a/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrade.go +++ b/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrade.go @@ -239,7 +239,7 @@ func upgradeV2(tx *sql.Tx, container *Container) error { if err != nil { return err } - if container.dialect == "postgres" { + if container.dialect == "postgres" || container.dialect == "pgx" { _, err = tx.Exec(fillSigKeyPostgres) } else { _, err = tx.Exec(fillSigKeySQLite) |