diff --git a/database/puppet.go b/database/puppet.go index f22fd1d..6e0a567 100644 --- a/database/puppet.go +++ b/database/puppet.go @@ -33,9 +33,8 @@ func newPuppet(qh *dbutil.QueryHelper[*Puppet]) *Puppet { } const ( - deleteAllPuppetsForUserQuery = "DELETE FROM puppet WHERE receiver=$1" - getPuppetQuery = "SELECT id, receiver, phone, contact_id, name, name_set, avatar_hash, avatar_mxc, avatar_set, avatar_update_ts, contact_info_set FROM puppet WHERE id=$1 AND receiver=$2" - insertPuppetQuery = ` + getPuppetQuery = "SELECT id, receiver, phone, contact_id, name, name_set, avatar_hash, avatar_mxc, avatar_set, avatar_update_ts, contact_info_set FROM puppet WHERE id=$1 AND receiver=$2" + insertPuppetQuery = ` INSERT INTO puppet (id, receiver, phone, contact_id, name, name_set, avatar_hash, avatar_mxc, avatar_set, avatar_update_ts, contact_info_set) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) ` @@ -46,10 +45,6 @@ const ( ` ) -func (pq *PuppetQuery) DeleteAllForUser(ctx context.Context, userID int) error { - return pq.Exec(ctx, deleteAllPuppetsForUserQuery, userID) -} - func (pq *PuppetQuery) Get(ctx context.Context, key Key) (*Puppet, error) { return pq.QueryOne(ctx, getPuppetQuery, key.ID, key.Receiver) } diff --git a/puppet.go b/puppet.go index 25f95df..48431ab 100644 --- a/puppet.go +++ b/puppet.go @@ -60,20 +60,6 @@ func (br *GMBridge) GetPuppetByMXID(mxid id.UserID) *Puppet { return br.GetPuppetByKey(key, "") } -func (br *GMBridge) DeleteAllPuppetsForUser(userID int) { - br.puppetsLock.Lock() - defer br.puppetsLock.Unlock() - err := br.DB.Puppet.DeleteAllForUser(context.Background(), userID) - if err != nil { - br.ZLog.Err(err).Msg("Failed to delete all ghosts for user from database") - } - for key, puppet := range br.puppetsByKey { - if puppet.Receiver == userID { - delete(br.puppetsByKey, key) - } - } -} - func (br *GMBridge) GetPuppetByKey(key database.Key, phone string) *Puppet { br.puppetsLock.Lock() defer br.puppetsLock.Unlock() diff --git a/user.go b/user.go index 0fece90..12d05bd 100644 --- a/user.go +++ b/user.go @@ -783,7 +783,6 @@ func (user *User) ResetState() { for _, portal := range portals { portal.Delete(context.TODO()) } - user.bridge.DeleteAllPuppetsForUser(user.RowID) user.PhoneID = "" go func() { user.zlog.Debug().Msg("Cleaning up portal rooms in background")