Skip to content

Commit b10677e

Browse files
gnpricechrisbobbe
authored andcommitted
api [nfc]: Require appid for addApnsToken route
This is required for current servers, since server-8. The original binding for this route didn't mark it as required because it was based on the reverse-engineered binding in zulip-mobile, and that one hadn't been updated for server-8. Now that the endpoint has API docs, we can use the information they tell us.
1 parent 397a938 commit b10677e

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

lib/api/route/notifications.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ Future<void> addFcmToken(ApiConnection connection, {
1313
/// https://zulip.com/api/add-apns-token
1414
Future<void> addApnsToken(ApiConnection connection, {
1515
required String token,
16-
String? appid,
16+
required String appid,
1717
}) {
1818
return connection.post('addApnsToken', (_) {}, 'users/me/apns_device_token', {
1919
'token': RawParameter(token),
20-
if (appid != null) 'appid': RawParameter(appid),
20+
'appid': RawParameter(appid),
2121
});
2222
}

test/api/route/notifications_test.dart

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void main() {
3131
group('addApnsToken', () {
3232
Future<void> checkAddApnsToken(FakeApiConnection connection, {
3333
required String token,
34-
required String? appid,
34+
required String appid,
3535
}) async {
3636
connection.prepare(json: {});
3737
await addApnsToken(connection, token: token, appid: appid);
@@ -40,17 +40,11 @@ void main() {
4040
..url.path.equals('/api/v1/users/me/apns_device_token')
4141
..bodyFields.deepEquals({
4242
'token': token,
43-
if (appid != null) 'appid': appid,
43+
'appid': appid,
4444
});
4545
}
4646

47-
test('no appid', () {
48-
return FakeApiConnection.with_((connection) async {
49-
await checkAddApnsToken(connection, token: 'asdf', appid: null);
50-
});
51-
});
52-
53-
test('with appid', () {
47+
test('smoke', () {
5448
return FakeApiConnection.with_((connection) async {
5549
await checkAddApnsToken(connection, token: 'asdf', appid: 'qwer');
5650
});

0 commit comments

Comments
 (0)