~emersion/soju-dev

soju: handleUserDelete: delete the correct user v1 APPLIED

Eyal Sawady: 1
 handleUserDelete: delete the correct user

 1 files changed, 1 insertions(+), 1 deletions(-)
#493248 .build.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/soju-dev/patches/22210/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH soju] handleUserDelete: delete the correct user Export this patch

Prior to this, we deleted the user issuing the deletion rather than the
user which should've been deleted.
---
I found this bug the hard way. Hooray for backups!

This bug was introduced in fa16337d97f9e2edbae2860470f2427a4847821d
(Switch DB API to user IDs), because "username" was turned into
dc.user.ID rather than u.ID. This mistake was probably made because
u.Username was normally used for non-dc.user usernames prior to that
commit.
 service.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/service.go b/service.go
index 01e27d9..3b92af9 100644
--- a/service.go
+++ b/service.go
@@ -699,7 +699,7 @@ func handleUserDelete(dc *downstreamConn, params []string) error {

	u.stop()

	if err := dc.srv.db.DeleteUser(dc.user.ID); err != nil {
	if err := dc.srv.db.DeleteUser(u.ID); err != nil {
		return fmt.Errorf("failed to delete user: %v", err)
	}

-- 
2.31.1
builds.sr.ht
soju/patches/.build.yml: SUCCESS in 1m42s

[handleUserDelete: delete the correct user][0] from [Eyal Sawady][1]

[0]: https://lists.sr.ht/~emersion/soju-dev/patches/22210
[1]: mailto:ecs@d2evs.net

✓ #493248 SUCCESS soju/patches/.build.yml https://builds.sr.ht/~emersion/job/493248