feat: support export media

This commit is contained in:
Rogee
2024-09-05 14:28:11 +08:00
parent 25234937d4
commit 7d1c9764b5
3 changed files with 52 additions and 45 deletions

View File

@@ -20,10 +20,11 @@ import (
)
type DBChannel struct {
UUID int64
Username string
Title string
MinID int
UUID int64
Username string
Title string
MinID int
ExportMedia bool
}
func NewDBChannel(uuid int64, username, title string) *DBChannel {
@@ -68,13 +69,14 @@ func (c *DBChannel) Get(ctx context.Context) error {
if errors.Is(err, qrm.ErrNoRows) {
// create new channel with default value
m = model.Channels{
UUID: c.UUID,
Username: c.Username,
Title: c.Title,
MinID: 0,
Offset: 0,
CreatedAt: lo.ToPtr(time.Now()),
UpdatedAt: lo.ToPtr(time.Now()),
UUID: c.UUID,
Username: c.Username,
Title: c.Title,
MinID: 0,
Offset: 0,
ExportMedia: false,
CreatedAt: lo.ToPtr(time.Now()),
UpdatedAt: lo.ToPtr(time.Now()),
}
if _, err := tbl.INSERT(tbl.AllColumns.Except(tbl.ID)).MODEL(m).ExecContext(ctx, db); err != nil {
@@ -85,6 +87,7 @@ func (c *DBChannel) Get(ctx context.Context) error {
}
}
c.MinID = int(m.MinID)
c.ExportMedia = m.ExportMedia
return nil
}