mirror of
https://github.com/christianselig/apollo-backend
synced 2024-12-22 22:35:27 +00:00
Set device pinged at
This commit is contained in:
parent
50cdc3aafa
commit
905235a8ff
3 changed files with 5 additions and 3 deletions
|
@ -83,8 +83,8 @@ func (a *api) Routes() *mux.Router {
|
|||
r.HandleFunc("/v1/device/{apns}/accounts", a.upsertAccountsHandler).Methods("POST")
|
||||
r.HandleFunc("/v1/device/{apns}/account/{redditID}", a.disassociateAccountHandler).Methods("DELETE")
|
||||
|
||||
r.HandleFunc("/v1/receipt", a.checkReceiptHandler)
|
||||
r.HandleFunc("/v1/receipt/{apns}", a.checkReceiptHandler)
|
||||
r.HandleFunc("/v1/receipt", a.checkReceiptHandler).Methods("POST")
|
||||
r.HandleFunc("/v1/receipt/{apns}", a.checkReceiptHandler).Methods("POST")
|
||||
|
||||
r.Use(a.loggingMiddleware)
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/christianselig/apollo-backend/internal/domain"
|
||||
"github.com/dustin/go-humanize/english"
|
||||
|
@ -26,6 +27,8 @@ func (a *api) upsertDeviceHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
d.LastPingedAt = time.Now().Unix()
|
||||
|
||||
if err := a.deviceRepo.CreateOrUpdate(ctx, d); err != nil {
|
||||
a.errorResponse(w, r, 500, err.Error())
|
||||
return
|
||||
|
|
|
@ -58,7 +58,6 @@ func (p *postgresDeviceRepository) GetByAPNSToken(ctx context.Context, token str
|
|||
}
|
||||
|
||||
func (p *postgresDeviceRepository) CreateOrUpdate(ctx context.Context, dev *domain.Device) error {
|
||||
fmt.Println(dev)
|
||||
query := `
|
||||
INSERT INTO devices (apns_token, sandbox, last_pinged_at)
|
||||
VALUES ($1, $2, $3)
|
||||
|
|
Loading…
Reference in a new issue