Skip to content

Commit 60847c9

Browse files
committed
types: Make sender_id on Outbox required.
As v27.157 has been out for well over a few weeks. And write a migration to strip any outbox messages that don't have it, as noted we should in a1fad7c's TODOs and in #3998.
1 parent 74ae528 commit 60847c9

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

src/boot/store.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,12 @@ const migrations: {| [string]: (GlobalState) => GlobalState |} = {
292292
},
293293
}),
294294

295+
// Make `sender_id` on `Outbox` required.
296+
'29': state => ({
297+
...state,
298+
outbox: state.outbox.filter(o => o.sender_id !== undefined),
299+
}),
300+
295301
// TIP: When adding a migration, consider just using `dropCache`.
296302
};
297303

src/message/getHtmlPieceDescriptors.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ export default (
3434
});
3535
}
3636

37-
// TODO(#3764): Use sender_id, not sender_email. Needs making
38-
// Outbox#sender_id required; which needs a migration to drop Outbox
39-
// values that lack it; which is fine once the release that adds it
40-
// has been out for a few weeks.
37+
// TODO(#3764): Use sender_id, not sender_email.
4138
const shouldGroupWithPrev =
4239
!diffRecipient
4340
&& !diffDays

src/types.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,7 @@ export type Outbox = $ReadOnly<{|
184184

185185
// The remaining fields are modeled on `Message`.
186186

187-
// TODO(#3764): Make sender_id required. Needs a migration to drop Outbox
188-
// values that lack it; which is fine once the release that adds it has
189-
// been out for a few weeks.
190-
// (Also drop the hack line about it in MessageLike.)
191-
sender_id?: UserId,
187+
sender_id: UserId,
192188

193189
/* eslint-disable flowtype/generic-spacing */
194190
...SubsetProperties<
@@ -241,7 +237,6 @@ export type MessageLike =
241237
| $ReadOnly<{|
242238
// $Shape<T> is unsound, per Flow docs, but $ReadOnly<$Shape<T>> is not
243239
...$Shape<{| [$Keys<Message>]: void |}>,
244-
sender_id?: UserId, // TODO: Drop this once required in Outbox.
245240
...Outbox,
246241
|}>;
247242

0 commit comments

Comments
 (0)