|
4 | 4 | "context" |
5 | 5 | "strings" |
6 | 6 | "time" |
| 7 | + |
| 8 | + "github.com/openclaw/discrawl/internal/store/storedb" |
7 | 9 | ) |
8 | 10 |
|
9 | 11 | type AttachmentListOptions struct { |
@@ -241,29 +243,24 @@ func (s *Store) ExpandAttachmentChannelIDs(ctx context.Context, channelIDs []str |
241 | 243 | } |
242 | 244 |
|
243 | 245 | func (s *Store) UpdateAttachmentMedia(ctx context.Context, update AttachmentMediaUpdate) error { |
244 | | - _, err := s.db.ExecContext(ctx, ` |
245 | | - update message_attachments |
246 | | - set media_path = ?, |
247 | | - content_sha256 = ?, |
248 | | - content_size = ?, |
249 | | - fetched_at = ?, |
250 | | - fetch_status = ?, |
251 | | - fetch_error = ?, |
252 | | - updated_at = ? |
253 | | - where attachment_id = ? |
254 | | - `, nullable(update.MediaPath), nullable(update.ContentSHA256), update.ContentSize, nullable(update.FetchedAt), |
255 | | - update.FetchStatus, update.FetchError, time.Now().UTC().Format(timeLayout), update.AttachmentID) |
256 | | - return err |
| 246 | + return s.q.UpdateAttachmentMedia(ctx, storedb.UpdateAttachmentMediaParams{ |
| 247 | + MediaPath: nullString(update.MediaPath), |
| 248 | + ContentSha256: nullString(update.ContentSHA256), |
| 249 | + ContentSize: update.ContentSize, |
| 250 | + FetchedAt: nullString(update.FetchedAt), |
| 251 | + FetchStatus: update.FetchStatus, |
| 252 | + FetchError: update.FetchError, |
| 253 | + UpdatedAt: time.Now().UTC().Format(timeLayout), |
| 254 | + AttachmentID: update.AttachmentID, |
| 255 | + }) |
257 | 256 | } |
258 | 257 |
|
259 | 258 | func (s *Store) UpdateAttachmentFetchStatus(ctx context.Context, attachmentID, fetchedAt, status, message string) error { |
260 | | - _, err := s.db.ExecContext(ctx, ` |
261 | | - update message_attachments |
262 | | - set fetched_at = ?, |
263 | | - fetch_status = ?, |
264 | | - fetch_error = ?, |
265 | | - updated_at = ? |
266 | | - where attachment_id = ? |
267 | | - `, nullable(fetchedAt), status, message, time.Now().UTC().Format(timeLayout), attachmentID) |
268 | | - return err |
| 259 | + return s.q.UpdateAttachmentFetchStatus(ctx, storedb.UpdateAttachmentFetchStatusParams{ |
| 260 | + FetchedAt: nullString(fetchedAt), |
| 261 | + FetchStatus: status, |
| 262 | + FetchError: message, |
| 263 | + UpdatedAt: time.Now().UTC().Format(timeLayout), |
| 264 | + AttachmentID: attachmentID, |
| 265 | + }) |
269 | 266 | } |
0 commit comments