setTitle method
setThreadTitle: sets title with title_source = manual when expectedVersion is the
thread's version, and appends thread.updated. Throws 412 version_conflict.
Implementation
JsonMap setTitle(
String principalId,
String threadId,
int expectedVersion,
String title,
) {
final thread = _writable(principalId, threadId);
if (thread['version'] != expectedVersion) {
throw FakeProblem(412, 'version_conflict', current: Map.of(thread));
}
thread
..['title'] = title
..['title_source'] = 'manual'
..['version'] = (thread['version']! as int) + 1;
append(
'thread.updated',
resource: {
'kind': 'thread',
'id': threadId,
'version': thread['version'],
},
scope: _scopeOf(threadId),
payload: {'thread': thread},
actor: principalId,
);
return thread;
}