upsertMessage method
Implementation
Future<void> upsertMessage(LocalityEvent message, {String? password}) async {
final key = password ?? _defaultPassword;
final encryptedPayload = PayloadCipher.encodePayload(
message.payload,
nonce: Nonce.fromString(message.uuid),
chaCha20: ChaCha20(ChaCha20Key.fromString(key))
);
final messageMap = message.toMap();
messageMap[LocalityEvent.columnPayload] = encryptedPayload;
await _database.insert(
LocalityEvent.tableName,
messageMap,
conflictAlgorithm: ConflictAlgorithm.replace,
);
}