Skip to content

Commit

Permalink
moved it
Browse files Browse the repository at this point in the history
  • Loading branch information
supreme2580 committed Jan 27, 2025
1 parent f71e4db commit 2abf7b1
Show file tree
Hide file tree
Showing 4 changed files with 7,110 additions and 2,515 deletions.
30 changes: 30 additions & 0 deletions backend/routes/indexer/worlds.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ package indexer
import (
"context"
"encoding/hex"
"fmt"
"image"
"image/color"
"image/png"
"net/http"
"os"
"strconv"
"strings"
"time"

"github.com/keep-starknet-strange/art-peace/backend/core"
Expand Down Expand Up @@ -394,6 +397,33 @@ func processCanvasPixelPlacedEvent(event IndexerEvent) {
return
}

// Check milestones
milestones := []int{1, 100, 1000, 10000, 50000, 100000, 1000000, 10000000, 100000000, 1000000000}
for _, milestone := range milestones {
if *totalPixelsPlaced == milestone {
// Get world name for notification
worldName, err := core.PostgresQueryOne[string]("SELECT name FROM Worlds WHERE world_id = $1", canvasId)
if err != nil {
PrintIndexerError("processCanvasPixelPlacedEvent", "Failed to query world name", canvasIdHex, placedBy, posHex, colorHex, err)
continue
}

// Send milestone notification
_, err = http.Post(
"http://localhost:3001/Art%20Peace%20Achievement%20Bot/message",
"application/json",
strings.NewReader(fmt.Sprintf(`{
"userId": "user",
"userName": "User",
"text": "%s world just reached %d pixels, view the world on art peace here https://art-peace.net/worlds/%d"
}`, *worldName, milestone, canvasId)),
)
if err != nil {
PrintIndexerError("processCanvasPixelPlacedEvent", "Failed to send milestone notification", canvasIdHex, placedBy, posHex, colorHex, err)
}
}
}

lastPixelPlacedTime, err := core.PostgresQueryOne[*time.Time]("SELECT time FROM WorldsPixels WHERE world_id = $1 ORDER BY time DESC LIMIT 1", canvasId)
if err != nil {
PrintIndexerError("processCanvasPixelPlacedEvent", "Failed to query lastPixelPlacedTime", canvasIdHex, placedBy, posHex, colorHex, err)
Expand Down
2 changes: 2 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ FROM node:21.7.1-alpine
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
RUN corepack prepare pnpm@latest --activate

RUN apk add --no-cache bash git jq curl

WORKDIR /app
COPY ./frontend/package.json ./frontend/pnpm-lock.yaml ./
COPY ./frontend/patches ./patches
RUN pnpm install
COPY ./frontend ./
COPY ./configs/canvas.config.json ./src/configs/canvas.config.json
Expand Down
Loading

0 comments on commit 2abf7b1

Please sign in to comment.