reject method
void
reject(
- SystemMessage message, {
- String? reason,
})
Implementation
void reject(SystemMessage message, {String? reason}) async {
if (message.status == SystemMessageStatus.init &&
message.fromAccount?.isNotEmpty == true) {
NIMResult<void>? result;
if (message.type == SystemMessageType.addFriend) {
result = await ContactRepo.acceptAddFriend(message.fromAccount!, false);
} else if (message.type == SystemMessageType.applyJoinTeam) {
result = await ContactRepo.rejectTeamApply(
message.targetId!, message.fromAccount!, reason ?? '');
} else if (message.type == SystemMessageType.teamInvite) {
result = await ContactRepo.rejectTeamInvite(
message.targetId!, message.fromAccount!, reason ?? '');
}
if (result?.isSuccess == true) {
var index =
systemMessages.indexWhere((e) => e.messageId == message.messageId);
if (index >= 0) {
ContactRepo.setVerifyStatus(
message.messageId!, SystemMessageStatus.declined);
message.status = SystemMessageStatus.declined;
systemMessages[index] = message;
notifyListeners();
}
}
}
}