mirror of
https://github.com/makayabou/asg-server.git
synced 2026-05-02 17:43:36 +02:00
Added: timezone support
This commit is contained in:
parent
2b132b67f2
commit
ce15a6ce53
@ -16,16 +16,16 @@ Authorization: Basic IUGFXE:v4ejpbeydvjo1h
|
||||
|
||||
{
|
||||
"message": "Test",
|
||||
"ttl": {{$randomInt 0 86400}},
|
||||
"ttl": 60,
|
||||
"phoneNumbers": [
|
||||
"79990001234"
|
||||
]
|
||||
}
|
||||
|
||||
###
|
||||
GET {{baseUrl}}/api/3rdparty/v1/message/pRl1wf_yez5TikJb_xemU HTTP/1.1
|
||||
GET {{baseUrl}}/api/3rdparty/v1/message/iZo6T9hw7wTuKLQUIP29I HTTP/1.1
|
||||
Authorization: Basic IUGFXE:v4ejpbeydvjo1h
|
||||
|
||||
###
|
||||
GET {{baseUrl}}/api/mobile/v1/message HTTP/1.1
|
||||
Authorization: Bearer KuvE4LBXzvy8QO2ZXDDMP
|
||||
Authorization: Bearer KuvE4LBXzvy8QO2ZXDDMP
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE `messages`
|
||||
ADD `valid_until` datetime;
|
||||
ADD `valid_until` datetime(3) DEFAULT NULL;
|
||||
-- +goose StatementEnd
|
||||
---
|
||||
-- +goose Down
|
||||
|
||||
@ -9,10 +9,15 @@ services:
|
||||
container_name: sms-gateway
|
||||
environment:
|
||||
- DEBUG=1
|
||||
- HTTP__LISTEN=:3000
|
||||
env_file:
|
||||
- .env
|
||||
ports:
|
||||
- "4000:3000"
|
||||
- "3000:3000"
|
||||
- "3456:2345"
|
||||
volumes:
|
||||
- "../..:/app"
|
||||
- "/tmp/sms-gateway/go-cache:/go/pkg"
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
restart: 'no'
|
||||
@ -16,15 +16,16 @@ type Config struct {
|
||||
}
|
||||
|
||||
type HTTP struct {
|
||||
Listen string `yaml:"listen"`
|
||||
Listen string `yaml:"listen" envconfig:"HTTP__LISTEN"`
|
||||
}
|
||||
|
||||
type Database struct {
|
||||
Host string `yaml:"host"`
|
||||
Port int `yaml:"port"`
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
Database string `yaml:"database"`
|
||||
Host string `yaml:"host" envconfig:"DATABASE__HOST"`
|
||||
Port int `yaml:"port" envconfig:"DATABASE__PORT"`
|
||||
User string `yaml:"user" envconfig:"DATABASE__USER"`
|
||||
Password string `yaml:"password" envconfig:"DATABASE__PASSWORD"`
|
||||
Database string `yaml:"database" envconfig:"DATABASE__DATABASE"`
|
||||
Timezone string `yaml:"timezone" envconfig:"DATABASE__TIMEZONE"`
|
||||
}
|
||||
|
||||
type FCMConfig struct {
|
||||
@ -41,6 +42,7 @@ var defaultConfig = Config{
|
||||
User: "sms",
|
||||
Password: "sms",
|
||||
Database: "sms",
|
||||
Timezone: "UTC",
|
||||
},
|
||||
FCM: FCMConfig{
|
||||
CredentialsJSON: "",
|
||||
|
||||
@ -32,6 +32,7 @@ var Module = fx.Module(
|
||||
User: cfg.Database.User,
|
||||
Password: cfg.Database.Password,
|
||||
Database: cfg.Database.Database,
|
||||
Timezone: cfg.Database.Timezone,
|
||||
}
|
||||
}),
|
||||
fx.Provide(func(cfg Config) services.PushServiceConfig {
|
||||
|
||||
@ -14,6 +14,7 @@ type Config struct {
|
||||
User string
|
||||
Password string
|
||||
Database string
|
||||
Timezone string
|
||||
}
|
||||
|
||||
// Helper function to set default values
|
||||
|
||||
@ -3,6 +3,7 @@ package db
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
|
||||
sql "github.com/go-sql-driver/mysql"
|
||||
"gorm.io/driver/mysql"
|
||||
@ -33,7 +34,7 @@ func makeConfig(params Params) *gorm.Config {
|
||||
func makeDSN(cfg Config) string {
|
||||
cfg = configDefault(cfg)
|
||||
return fmt.Sprintf(
|
||||
"%s:%s@tcp(%s:%d)/%s?charset=utf8mb4,utf8&parseTime=true&tls=preferred",
|
||||
cfg.User, cfg.Password, cfg.Host, cfg.Port, cfg.Database,
|
||||
"%s:%s@tcp(%s:%d)/%s?charset=utf8mb4,utf8&parseTime=true&loc=%s&tls=preferred",
|
||||
cfg.User, cfg.Password, cfg.Host, cfg.Port, cfg.Database, url.QueryEscape(cfg.Timezone),
|
||||
)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user