Skip to content

Commit b70d02a

Browse files
committed
feat: add strictMode checking disconnect response against call states
1 parent 729ec23 commit b70d02a

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

lib/src/models/config/ck_configuration.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class CKConfiguration {
1212
final CKTimer timer;
1313
final bool notifyOnCallEnd;
1414
final Map<CKCallAction, String> icons;
15+
final bool strictMode;
1516
// final bool repostOnClick;
1617

1718
const CKConfiguration({
@@ -21,12 +22,13 @@ class CKConfiguration {
2122
this.timer = const CKTimer(),
2223
this.notifyOnCallEnd = true,
2324
this.icons = const {},
25+
this.strictMode = true,
2426
// this.repostOnClick = true,
2527
});
2628

2729
@override
2830
String toString() {
2931
// return 'CKConfiguration{sounds: $sounds, capabilities: $capabilities, attributes: $attributes, timer: $timer, notifyOnCallEnd: $notifyOnCallEnd, repostOnClick: $repostOnClick}';
30-
return 'CKConfiguration{sounds: $sounds, capabilities: $capabilities, attributes: $attributes, timer: $timer, notifyOnCallEnd: $notifyOnCallEnd, icons: $icons}';
32+
return 'CKConfiguration{sounds: $sounds, capabilities: $capabilities, attributes: $attributes, timer: $timer, notifyOnCallEnd: $notifyOnCallEnd, icons: $icons, strictMode: $strictMode}';
3133
}
3234
}

lib/web_callkit_web.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,14 @@ class WebCallkitWeb extends WebCallkitPlatform {
222222
printDebug("Call with uuid: $uuid not found.", tag: tag);
223223
return;
224224
}
225-
final validResponses = validCallStateDisconnectResponses[call.state] ?? CKDisconnectResponse.values;
226-
if (!validResponses.contains(response)) {
227-
printWarning("Invalid response for call state: ${call.state}", tag: tag);
228-
return;
225+
if (_configuration.strictMode) {
226+
final validResponses = validCallStateDisconnectResponses[call.state] ?? CKDisconnectResponse.values;
227+
if (!validResponses.contains(response)) {
228+
printWarning("Invalid response for call state: ${call.state}", tag: tag);
229+
return;
230+
}
231+
} else {
232+
printDebug("Strict mode disabled. Ignoring valid disconnect call state check.", tag: tag);
229233
}
230234
_callManager.removeCall(uuid, response: response);
231235
}

0 commit comments

Comments
 (0)