submit method
Future<DVContentVersion<T> >
submit(
- DVContentVersion<
T> version, { - required String to,
- required Object? as,
Asks to to review version, freezing it. The request is sent through
DV.Notifications after the transition commits.
Implementation
Future<DVContentVersion<T>> submit(
DVContentVersion<T> version, {
required String to,
required Object? as,
}) async {
final String actor = await _authorize(
as,
DVContentAction.edit,
version.document,
);
_expect(version, 'submit', const <DVContentState>{
DVContentState.draft,
DVContentState.approved,
});
return _transactions((DVContext context) async {
final DVContentVersion<T> moved = await _move(
version,
actor,
<String, Object?>{
'state': DVContentState.review.name,
'reviewer': to,
..._cleared(const <String>[
'approved_by',
'approved_at',
'approved_revision',
'approved_digest',
'note',
]),
},
);
context.afterCommit(() async {
try {
await _notify(
to,
DVNotificationMessage(
title: 'Review requested',
body: '$actor asked you to review ${moved.documentId}.',
data: <String, String>{
'kind': kind,
'document': moved.documentId,
'version': moved.id,
},
),
);
} catch (error) {
_report(
DVContentReport._(
DVContentReportKind.notificationFailed,
'the review request for ${moved.id} to $to could not be sent: '
'$error',
versionId: moved.id,
),
);
}
});
return moved;
});
}