Skip to content

Commit f8ca800

Browse files
cfmCopilot
andauthored
Apply suggestions from code review
Co-authored-by: Copilot <[email protected]>
1 parent fabbe9d commit f8ca800

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

API2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ state "Cache and report success" as SuccessBranch {
181181
OK --> UpdateCache
182182
MultiStatus --> UpdateCache
183183
184-
UpdateCache : redis.set(event.id, OK, ttl)
184+
UpdateCache : redis.set(event.id, status, ttl)
185185
UpdateCache --> [*] : return (OK, delta)
186186
}
187187

securedrop/journalist_app/api2/events.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def handle_source_deleted(event: Event, minor: int) -> EventResult:
187187
except ValueError as exc:
188188
return EventResult(
189189
event_id=event.id,
190-
status=(EventStatusCode.InternalServerError, exc),
190+
status=(EventStatusCode.InternalServerError, str(exc)),
191191
)
192192

193193
@staticmethod
@@ -333,9 +333,11 @@ def handle_source_conversation_truncated(event: Event, minor: int) -> EventResul
333333
else:
334334
status = EventStatusCode.OK
335335

336+
db.session.refresh(source)
336337
return EventResult(
337338
event_id=event.id,
338339
status=(status, None),
340+
sources={source.uuid: source},
339341
items=deleted,
340342
)
341343

securedrop/journalist_app/api2/types.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ class SourceConversationTruncatedData(EventData):
155155
# up to and including n".
156156
upper_bound: int
157157

158+
def __post_init__(self) -> None:
159+
if self.upper_bound < 0:
160+
raise ValueError("upper_bound must be non-negative")
158161

159162
EVENT_DATA_TYPES = {
160163
EventType.REPLY_SENT: ReplySentData,

0 commit comments

Comments
 (0)