twonly-app/lib/src/database/tables/receipts.table.dart
otsmr eade1d87e6
Some checks failed
Flutter analyze & test / flutter_analyze_and_test (push) Has been cancelled
some smaller bug fixes
2026-08-06 10:16:27 +02:00

51 lines
1.6 KiB
Dart

import 'package:drift/drift.dart';
import 'package:twonly/src/database/tables/contacts.table.dart';
import 'package:twonly/src/database/tables/messages.table.dart';
@DataClassName('Receipt')
@TableIndex(name: 'idx_receipts_message_id', columns: {#messageId})
class Receipts extends Table {
TextColumn get receiptId => text()();
IntColumn get contactId =>
integer().references(Contacts, #userId, onDelete: KeyAction.cascade)();
// in case a message is deleted, it should be also deleted from the receipts table
TextColumn get messageId => text().nullable().references(
Messages,
#messageId,
onDelete: KeyAction.cascade,
)();
/// This is the protobuf 'Message'
BlobColumn get message => blob()();
BoolColumn get contactWillSendsReceipt =>
boolean().withDefault(const Constant(true))();
BoolColumn get willBeRetriedByMediaUpload =>
boolean().withDefault(const Constant(false))();
DateTimeColumn get markForRetry => dateTime().nullable()();
DateTimeColumn get markForRetryAfterAccepted => dateTime().nullable()();
DateTimeColumn get ackByServerAt => dateTime().nullable()();
IntColumn get retryCount => integer().withDefault(const Constant(0))();
DateTimeColumn get lastRetry => dateTime().nullable()();
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
@override
Set<Column> get primaryKey => {receiptId};
}
@DataClassName('ReceivedReceipt')
class ReceivedReceipts extends Table {
TextColumn get receiptId => text()();
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
@override
Set<Column> get primaryKey => {receiptId};
}