convertToSystemInfoFromRecall static method

RecallMessageSystemMessage convertToSystemInfoFromRecall(
  1. V2TimMessage message,
  2. V2TimUserFullInfo? operateUser,
  3. String? reason
)

Implementation

static RecallMessageSystemMessage convertToSystemInfoFromRecall(
    V2TimMessage message, V2TimUserFullInfo? operateUser, String? reason) {
  V2TimUserFullInfo revokerInfo;
  if (message.revokerInfo != null && message.revokerInfo!.userID != null && message.revokerInfo!.userID!.isNotEmpty) {
    revokerInfo = message.revokerInfo!;
  } else if (operateUser != null) {
    revokerInfo = operateUser;
  } else {
    revokerInfo = V2TimUserFullInfo(userID: message.sender, nickName: message.nickName);
  }

  final messageSender = message.sender ?? "";

  String operator = revokerInfo.nickName ?? '';
  if (operator.isEmpty) {
    operator = revokerInfo.userID ?? '';
  }

  bool isInGroup = false;
  if (message.userID != null && message.userID!.isNotEmpty) {
    isInGroup = false;
  } else if (message.groupID != null && message.groupID!.isNotEmpty) {
    isInGroup = true;
  }

  bool isRecalledBySelf = false;
  if (revokerInfo.userID == messageSender) {
    isRecalledBySelf = message.isSelf ?? false;
  }

  return RecallMessageSystemMessage(
    groupID: message.groupID ?? "",
    recallMessageOperator: operator,
    isRecalledBySelf: isRecalledBySelf,
    isInGroup: isInGroup,
    recallReason: reason ?? "",
  );
}