~sircmpwn/sr.ht-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH meta.sr.ht] api: fix webhooks being called with outdated data

Details
Message ID
<20220804103023.141010-1-ch@bitfehler.net>
DKIM signature
pass
Download raw message
Patch: +3 -2
When a user updates their profile, the database gets updated
accordingly, but the webhooks get called with data retrieved before the
update.

Make the update statement return the new values and apply them to the
user object that gets passed to the webhooks.
---
 api/graph/schema.resolvers.go | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/api/graph/schema.resolvers.go b/api/graph/schema.resolvers.go
index d81a4ba..5c2ed91 100644
--- a/api/graph/schema.resolvers.go
+++ b/api/graph/schema.resolvers.go
@@ -121,13 +121,14 @@ func (r *mutationResolver) UpdateUser(ctx context.Context, input map[string]inte
		var err error

		if len(input) != 0 {
			_, err = query.
			err = query.
				Where(database.WithAlias(user.Alias(), `id`)+"= ?",
					auth.ForContext(ctx).UserID).
				Set(database.WithAlias(user.Alias(), `updated`),
					sq.Expr(`now() at time zone 'utc'`)).
				Suffix(`RETURNING url, location, bio`).
				RunWith(tx).
				ExecContext(ctx)
				ScanContext(ctx, &user.URL, &user.Location, &user.Bio)
			if err != nil {
				return err
			}
-- 
2.37.1
Details
Message ID
<20220804165230.wnnpxjtto2l7we26@thinkpad>
In-Reply-To
<20220804103023.141010-1-ch@bitfehler.net> (view parent)
DKIM signature
pass
Download raw message
On 08/04, Conrad Hoffmann wrote:
>When a user updates their profile, the database gets updated
>accordingly, but the webhooks get called with data retrieved before the
>update.
>
>Make the update statement return the new values and apply them to the
>user object that gets passed to the webhooks.

I believe this will resolve this ticket:

https://todo.sr.ht/~sircmpwn/meta.sr.ht/192
Details
Message ID
<CM6J0DLW7C0I.W415YFQSW6QN@taiga>
In-Reply-To
<20220804103023.141010-1-ch@bitfehler.net> (view parent)
DKIM signature
pass
Download raw message
Thanks!

To git@git.sr.ht:~sircmpwn/meta.sr.ht
   085a966..9d9fed0  master -> master
Reply to thread Export thread (mbox)