私聊功能未完成
This commit is contained in:
+34
-9
@@ -9,15 +9,16 @@ import (
|
||||
)
|
||||
|
||||
type listOptions struct {
|
||||
Limit int
|
||||
Offset int
|
||||
NodeID string
|
||||
Since *time.Time
|
||||
Until *time.Time
|
||||
MinLat *float64
|
||||
MaxLat *float64
|
||||
MinLng *float64
|
||||
MaxLng *float64
|
||||
Limit int
|
||||
Offset int
|
||||
NodeID string
|
||||
ChannelID string
|
||||
Since *time.Time
|
||||
Until *time.Time
|
||||
MinLat *float64
|
||||
MaxLat *float64
|
||||
MinLng *float64
|
||||
MaxLng *float64
|
||||
}
|
||||
|
||||
type mapReportViewportOptions struct {
|
||||
@@ -264,6 +265,27 @@ func (s *store) ListTextMessages(opts listOptions) ([]textMessageRecord, error)
|
||||
return rows, s.listAppendRows(opts, &rows).Error
|
||||
}
|
||||
|
||||
func (s *store) ListBotDirectTextMessages(botNodeNum, targetNodeNum int64, opts listOptions) ([]textMessageRecord, error) {
|
||||
opts = normalizeListOptions(opts)
|
||||
var rows []textMessageRecord
|
||||
q := s.db.Model(&textMessageRecord{}).
|
||||
Where("(from_num = ? AND packet_to_num = ?) OR (from_num = ? AND packet_to_num = ?)", botNodeNum, targetNodeNum, targetNodeNum, botNodeNum).
|
||||
Order("created_at DESC").
|
||||
Order("id DESC").
|
||||
Limit(opts.Limit).
|
||||
Offset(opts.Offset)
|
||||
if opts.ChannelID != "" {
|
||||
q = q.Where("channel_id = ?", opts.ChannelID)
|
||||
}
|
||||
if opts.Since != nil {
|
||||
q = q.Where("created_at >= ?", *opts.Since)
|
||||
}
|
||||
if opts.Until != nil {
|
||||
q = q.Where("created_at <= ?", *opts.Until)
|
||||
}
|
||||
return rows, q.Find(&rows).Error
|
||||
}
|
||||
|
||||
func (s *store) ListDiscardDetails(opts listOptions) ([]discardDetailsRecord, error) {
|
||||
opts = normalizeListOptions(opts)
|
||||
var rows []discardDetailsRecord
|
||||
@@ -328,6 +350,9 @@ func (s *store) listAppendRows(opts listOptions, dest any) *gorm.DB {
|
||||
if opts.NodeID != "" {
|
||||
q = q.Where("from_id = ?", opts.NodeID)
|
||||
}
|
||||
if opts.ChannelID != "" {
|
||||
q = q.Where("channel_id = ?", opts.ChannelID)
|
||||
}
|
||||
if opts.Since != nil {
|
||||
q = q.Where("created_at >= ?", *opts.Since)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user