feat: Telegram bot, notifications, profile settings, 365-day refresh tokens

This commit is contained in:
Cosmo
2026-02-06 14:11:26 +00:00
parent 9e467b0448
commit afeb3adddf
7 changed files with 448 additions and 128 deletions

View File

@@ -6,23 +6,37 @@ import (
)
type User struct {
ID int64 `db:"id" json:"id"`
Email string `db:"email" json:"email"`
Username string `db:"username" json:"username"`
PasswordHash string `db:"password_hash" json:"-"`
EmailVerified bool `db:"email_verified" json:"email_verified"`
TelegramChatID sql.NullInt64 `db:"telegram_chat_id" json:"-"`
TelegramChatIDValue *int64 `db:"-" json:"telegram_chat_id"`
NotificationsEnabled bool `db:"notifications_enabled" json:"notifications_enabled"`
Timezone string `db:"timezone" json:"timezone"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
ID int64 `db:"id" json:"id"`
Email string `db:"email" json:"email"`
Username string `db:"username" json:"username"`
PasswordHash string `db:"password_hash" json:"-"`
EmailVerified bool `db:"email_verified" json:"email_verified"`
TelegramChatID sql.NullInt64 `db:"telegram_chat_id" json:"-"`
TelegramChatIDValue *int64 `db:"-" json:"telegram_chat_id"`
NotificationsEnabled bool `db:"notifications_enabled" json:"notifications_enabled"`
Timezone string `db:"timezone" json:"timezone"`
MorningReminderTime sql.NullString `db:"morning_reminder_time" json:"-"`
EveningReminderTime sql.NullString `db:"evening_reminder_time" json:"-"`
MorningTime string `db:"-" json:"morning_reminder_time"`
EveningTime string `db:"-" json:"evening_reminder_time"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}
func (u *User) ProcessForJSON() {
if u.TelegramChatID.Valid {
u.TelegramChatIDValue = &u.TelegramChatID.Int64
}
if u.MorningReminderTime.Valid {
u.MorningTime = u.MorningReminderTime.String[:5] // "09:00:00" -> "09:00"
} else {
u.MorningTime = "09:00"
}
if u.EveningReminderTime.Valid {
u.EveningTime = u.EveningReminderTime.String[:5]
} else {
u.EveningTime = "21:00"
}
}
type RegisterRequest struct {
@@ -41,6 +55,8 @@ type UpdateProfileRequest struct {
TelegramChatID *int64 `json:"telegram_chat_id,omitempty"`
NotificationsEnabled *bool `json:"notifications_enabled,omitempty"`
Timezone *string `json:"timezone,omitempty"`
MorningReminderTime *string `json:"morning_reminder_time,omitempty"`
EveningReminderTime *string `json:"evening_reminder_time,omitempty"`
}
type ChangePasswordRequest struct {