Skip to content

Commit

Permalink
fix local key/task queue, logs (#1236)
Browse files Browse the repository at this point in the history
  • Loading branch information
benny-conn authored Oct 23, 2023
1 parent e7e9338 commit c355c6d
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 41 deletions.
1 change: 1 addition & 0 deletions autosocial/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func addFarcasterProfileToUser(ctx context.Context, n *farcaster.NeynarAPI, addr
}
u, err := n.UserByAddress(ctx, a.Address())
if err != nil {
logrus.Error(err)
continue
}
if u.Fid.String() == "" {
Expand Down
75 changes: 44 additions & 31 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
version: "3.9"
version: '3.9'
services:
redis:
image: "redis:6"
image: 'redis:6'
ports:
- "6379:6379"
- '6379:6379'
postgres:
build:
context: "docker/postgres"
dockerfile: "DOCKERFILE"
context: 'docker/postgres'
dockerfile: 'DOCKERFILE'
args:
- PGHOST=${PGHOST}
- PGPORT=${PGPORT}
Expand All @@ -16,18 +16,18 @@ services:
- PGDATABASE=${PGDATABASE}
- PGTESTUSER=${PGTESTUSER}
ports:
- "5432:5432"
- '5432:5432'
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
- POSTGRES_USER=postgres
- POSTGRES_DB=postgres
volumes:
- "${PWD}/docker/postgres/postgres.conf:/etc/postgresql/postgresql.conf"
command: ["-c", "config-file=/etc/postgresql/postgresql.conf"]
- '${PWD}/docker/postgres/postgres.conf:/etc/postgresql/postgresql.conf'
command: ['-c', 'config-file=/etc/postgresql/postgresql.conf']
postgres_indexer:
build:
context: "."
dockerfile: "docker/postgres_indexer/DOCKERFILE"
context: '.'
dockerfile: 'docker/postgres_indexer/DOCKERFILE'
args:
- PGHOST=${PGHOST}
- PGPORT=${PGPORT}
Expand All @@ -36,39 +36,52 @@ services:
- PGDATABASE=${PGDATABASE}
- PGTESTUSER=${PGTESTUSER}
ports:
- "5433:5432"
- '5433:5432'
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
- POSTGRES_USER=postgres
- POSTGRES_DB=postgres
task-emulator:
image: ghcr.io/aertje/cloud-tasks-emulator:latest
ports:
- "8123:8123"
- '8123:8123'
expose:
- "8123"
command: [
"-host", "0.0.0.0",
"-port", "8123",
"-queue", "projects/gallery-local/locations/here/queues/feedbot",
"-queue", "projects/gallery-local/locations/here/queues/feed-event",
"-queue", "projects/gallery-local/locations/here/queues/token-processing",
"-queue", "projects/gallery-local/locations/here/queues/indexer-refreshes",
"-queue", "projects/gallery-local/locations/here/queues/wallet-validate",
"-queue", "projects/gallery-local/locations/here/queues/push-notifications",
"-queue", "projects/gallery-local/locations/here/queues/email",
]
- '8123'
command:
[
'-host',
'0.0.0.0',
'-port',
'8123',
'-queue',
'projects/gallery-local/locations/here/queues/feedbot',
'-queue',
'projects/gallery-local/locations/here/queues/feed-event',
'-queue',
'projects/gallery-local/locations/here/queues/token-processing',
'-queue',
'projects/gallery-local/locations/here/queues/indexer-refreshes',
'-queue',
'projects/gallery-local/locations/here/queues/wallet-validate',
'-queue',
'projects/gallery-local/locations/here/queues/push-notifications',
'-queue',
'projects/gallery-local/locations/here/queues/email',
'-queue',
'projects/gallery-local/locations/here/queues/autosocial',
]
pubsub-emulator:
image: gcr.io/google.com/cloudsdktool/google-cloud-cli:emulators
expose:
- "8085"
- '8085'
ports:
- "8085:8085"
command: [
"/bin/bash",
"-c",
"gcloud beta emulators pubsub start --host-port=0.0.0.0:8085 --project=gallery-local"
]
- '8085:8085'
command:
[
'/bin/bash',
'-c',
'gcloud beta emulators pubsub start --host-port=0.0.0.0:8085 --project=gallery-local',
]

# Uncomment if you want to run tokenprocessing locally as a container
# tokenprocessing:
Expand Down
1 change: 0 additions & 1 deletion publicapi/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,6 @@ func (api UserAPI) CreateUser(ctx context.Context, authenticator auth.Authentica
})
if err != nil {
logger.For(ctx).Errorf("failed to dispatch event: %s", err)
return userID, galleryID, err
}

err = task.CreateTaskForAutosocialProcessUsers(ctx, task.AutosocialProcessUsersMessage{
Expand Down
8 changes: 5 additions & 3 deletions secrets/local/local/app-local-autosocial.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
NEYNAR_API_KEY: ENC[AES256_GCM,data:lOgGUa7gpiGp/yU8IqzRnaZDpAO4ePG+2/3hRHwLPb7ghZFe,iv:diiA6IRDT9Jah88i7NYuSffeHLJJHomwekm6wt/dRQQ=,tag:/96dvAyKKe6XtgnQdWSLmQ==,type:str]
AUTOSOCIAL_QUEUE: ENC[AES256_GCM,data:P9KDiiVbxOedlUWH5GcedvjT//DSOXE0qvZXmVcnF70HHKRbAdaRGcn173h9yGkB0KQFT0ujPg==,iv:KEoQ0D0mD9Z2GFMeYLaL3lOWeH9Uwv59hgsFZ1FNCwc=,tag:KrJBwJW/giCRn86EKEUDEQ==,type:str]
AUTOSOCIAL_URL: ENC[AES256_GCM,data:5NXPZ1PPlLBEkbo76JUNmXl98F54Jhv64UgSdHOwVeU=,iv:QOatTDOPaJtvq7oUo5aaQsl3tjheSh+vgpdVTCe6h68=,tag:gV4COGfBpyirxvFcs6u0gQ==,type:str]
NEYNAR_API_KEY: ENC[AES256_GCM,data:I5XxTPpPbYCmXkH2dhNMtaPSAJzvnY1WOTw5USQEZ1BKuLuV,iv:SejOjG7SxuNt8PmAOZi2Qh32ZfrQ2njN3J+ByXTDmiM=,tag:WczFOF3+ucW5pBVN1yKzSg==,type:str]
sops:
kms: []
gcp_kms:
Expand All @@ -8,8 +10,8 @@ sops:
azure_kv: []
hc_vault: []
age: []
lastmodified: "2023-09-26T23:09:31Z"
mac: ENC[AES256_GCM,data:Tmfg6f3r26QtTfTfxkNArwE+Rb2PFk3Q1aOi1F9jv71ofJwgBcUhllyIHbYEdKpaKCK/LlLLI/qfF+LDiMGYnAemaiTUcaU6UOWYSKMTRll3/IicSir245bW334HAZvk89MPXG49W22SrxuXwcZDug4mesQP1Sg9s4YUcVqRXbQ=,iv:J0M+WJtfiijQ1pj1FYABv3CuW2uw+iSAxCSOEM+ttl0=,tag:wlc/RloBcwrox4lWhVkB+Q==,type:str]
lastmodified: "2023-10-23T18:57:01Z"
mac: ENC[AES256_GCM,data:Yo7MCeulEensGk+1xj0Oy8j86fsCNusA4V/glN6KevqrvDAv9kQLLWtCceDRC9wmV3L2h5o2e/DZtxi7XihtuEaTSdSOnnJfPmpZDIwos3641ypO4B8Vjs7IU5VOB88+QEqLRgp4nRPUvKrzV3VC2mN66qmLLxaDcipiYemMZFY=,iv:tT/ulsRk1awwA51JoT0uVV6lhMGz9ecr2Mr4sLuCagg=,tag:Qz6BPv2X4eEnuQnFOyvW3Q==,type:str]
pgp: []
unencrypted_suffix: _unencrypted
version: 3.7.3
6 changes: 3 additions & 3 deletions secrets/local/local/app-local-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ RPC_URL: ENC[AES256_GCM,data:Qt54Eru5hohZXpV2pUCx/0+dg7CpVK7bHYEGye/fej+WV2HxjGo
GCLOUD_USER_PREF_BUCKET: ENC[AES256_GCM,data:+abxLn4GAtNR/PRAjg==,iv:pywnL1YJzPfgEyHVvCJeJc83WaScMhL81QNCJasTzac=,tag:+91RyaN4clWzmXURuXqxMA==,type:str]
EMAIL_QUEUE: ENC[AES256_GCM,data:DZlQknhz+9UvLcin3j4iamhRp4y0ZrsRmcuhEArrXtBro1b58ov6T1PnSHw43pUgc5c=,iv:KrJQSR1FnwVA9Ue0cJTzqmLwz7DG/dF8LvI1aNWMic4=,tag:Bba+2d2hH3vaABLqPc1knQ==,type:str]
AUTOSOCIAL_QUEUE: ENC[AES256_GCM,data:VPxQ8izFihl26rbrTe/sBgb3x+IvIobtPWKcDTUGuqAXlwgT4LNxVs4biB3fsP02nsJ7Z5SKug==,iv:CzPRmkSIt6rxkQ9GmWQl1UEbFTnuKZzqO92Jp+gf3MI=,tag:sFqz7HLDHc/6+CFDJZSJLg==,type:str]
AUTOSOCIAL_URL: ENC[AES256_GCM,data:qCx4KiFSi3l7grzCAjU=,iv:m2asHtCG3V5WtUI+/sW34DtteP+sw2ogSLFG7d4L5IU=,tag:pnquIO4OYPKc15ZoVtwbDw==,type:str]
AUTOSOCIAL_URL: ENC[AES256_GCM,data:Jx2v/E4x841LeDjmiUUmTT70IBfJmmzbhmCUTd/aqUM=,iv:n8NkhZosTCwo0AEXuRvQoVvlzBcEdWa1Swa2gWIA8yU=,tag:BH5wARsJ4w31HFkVfMBN7w==,type:str]
sops:
kms: []
gcp_kms:
Expand All @@ -53,8 +53,8 @@ sops:
azure_kv: []
hc_vault: []
age: []
lastmodified: "2023-10-03T19:58:39Z"
mac: ENC[AES256_GCM,data:bjQXDq+03Aw7pkZUHBbYf+KKmkTtmn2TDB5Hgkaj0aLBILtXO/x1dQcsqs3iSAMgIJIELKfHj5Ff2pe04VZSnaHwhYwZXyiJvdwDLMmYDlH/QZqnvNxrQlmxhOe8JnP8tQLwsHdVAbSGF77yzaoYtoVG/79gEeUvH5+HimwpP4s=,iv:ZxKRHRVLBwlZSnt7+ioPJWURlit5eEBo7IGcCSP6x/E=,tag:pz8bqAOABfAxc0PZhNHrKQ==,type:str]
lastmodified: "2023-10-23T18:41:58Z"
mac: ENC[AES256_GCM,data:8BrdTVeD9/Gb4YZF8ds94zTFb1UrU/eCtZ4POBUJYdYLgddFCXezomJQNr0QJrOI/pAc6ObKa31yuVpZTkYGc9yC6uNMWF+oVMdtzlJkXuRIG6zlBmaBGZr0MIWWk3P5RY6zGGpBIHbHTCIFrMscXRxIizss63XxTzIsqPTpev8=,iv:epX4hH8qJWhDtSdIfhD2IeLIZUPf8/LrPJPpe9p6Wng=,tag:y31wz30w9UDBgaeub9VW6Q==,type:str]
pgp: []
unencrypted_suffix: _unencrypted
version: 3.7.3
9 changes: 9 additions & 0 deletions service/farcaster/neynar.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"

"github.com/mikeydub/go-gallery/env"
Expand Down Expand Up @@ -111,6 +112,14 @@ func (n *NeynarAPI) UserByAddress(ctx context.Context, address persist.Address)
return NeynarUser{}, err
}

if resp.StatusCode != http.StatusOK {
bs, err := io.ReadAll(resp.Body)
if err != nil {
return NeynarUser{}, err
}
return NeynarUser{}, fmt.Errorf("neynar returned status %d (%s)", resp.StatusCode, bs)
}

defer resp.Body.Close()

var neynarResp NeynarUserByVerificationResponse
Expand Down
7 changes: 4 additions & 3 deletions service/socialauth/socialauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package socialauth

import (
"context"
"fmt"
"net/http"

"github.com/mikeydub/go-gallery/db/gen/coredb"
Expand Down Expand Up @@ -72,11 +73,11 @@ type FarcasterAuthenticator struct {
func (a FarcasterAuthenticator) Authenticate(ctx context.Context) (*SocialAuthResult, error) {
api := farcaster.NewNeynarAPI(a.HTTPClient)
user, err := a.Queries.GetUserByAddressAndL1(ctx, coredb.GetUserByAddressAndL1Params{
Address: a.Address,
Address: persist.Address(persist.ChainETH.NormalizeAddress(a.Address)),
L1Chain: persist.L1Chain(persist.ChainETH),
})
if err != nil {
return nil, err
return nil, fmt.Errorf("get user by address and l1: %w", err)
}

if user.ID != a.UserID {
Expand All @@ -88,7 +89,7 @@ func (a FarcasterAuthenticator) Authenticate(ctx context.Context) (*SocialAuthRe

fu, err := api.UserByAddress(ctx, a.Address)
if err != nil {
return nil, err
return nil, fmt.Errorf("get user by address: %w", err)
}

return &SocialAuthResult{
Expand Down

0 comments on commit c355c6d

Please sign in to comment.