Commit 61ba9df7 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Store emailAddress when it's invalid

parent 512276ed
Pipeline #22349 passed with stage
in 33 minutes and 8 seconds
......@@ -100,7 +100,7 @@ void DKIMCheckPolicyJob::compareWithDefaultRules()
deleteLater();
}
void DKIMCheckPolicyJob::dmarcPolicyResult(const MessageViewer::DMARCPolicyJob::DMARCResult &value)
void DKIMCheckPolicyJob::dmarcPolicyResult(const MessageViewer::DMARCPolicyJob::DMARCResult &value, const QString &emailAddress)
{
if (value.isValid()) {
if (mCheckResult.status == DKIMCheckSignatureJob::DKIMStatus::EmailNotSigned) {
......@@ -109,6 +109,8 @@ void DKIMCheckPolicyJob::dmarcPolicyResult(const MessageViewer::DMARCPolicyJob::
//TODO verify it.
mCheckResult.sdid = value.mSource;
}
} else {
//Store invalid emailAddress
}
Q_EMIT result(mCheckResult);
deleteLater();
......
......@@ -52,7 +52,7 @@ Q_SIGNALS:
private:
void compareWithDefaultRules();
void dmarcPolicyResult(const MessageViewer::DMARCPolicyJob::DMARCResult &value);
void dmarcPolicyResult(const MessageViewer::DMARCPolicyJob::DMARCResult &value, const QString &emailAddress);
MessageViewer::DKIMCheckSignatureJob::CheckSignatureResult mCheckResult;
QString mEmailAddress;
DKIMCheckPolicy mPolicy;
......
......@@ -42,7 +42,7 @@ bool DMARCPolicyJob::start()
{
if (!canStart()) {
qCWarning(MESSAGEVIEWER_DKIMCHECKER_LOG) << " Impossible to start DMARCPolicyJob" << mEmailAddress;
Q_EMIT result({});
Q_EMIT result({}, mEmailAddress);
deleteLater();
return false;
}
......@@ -56,7 +56,7 @@ bool DMARCPolicyJob::start()
checkSubDomain(domainName);
});
if (!job->start()) {
Q_EMIT result({});
Q_EMIT result({}, mEmailAddress);
deleteLater();
return false;
}
......@@ -83,7 +83,7 @@ void DMARCPolicyJob::slotCheckSubDomain(const QList<QByteArray> &lst, const QStr
DMARCInfo info;
if (info.parseDMARC(QString::fromLocal8Bit(ba))) {
if ((info.version() != QLatin1String("DMARC1")) || info.policy().isEmpty() || (info.percentage() > 100 || info.percentage() < 0)) {
Q_EMIT result({});
Q_EMIT result({}, mEmailAddress);
deleteLater();
return;
} else {
......@@ -94,12 +94,12 @@ void DMARCPolicyJob::slotCheckSubDomain(const QList<QByteArray> &lst, const QStr
//TODO verify it !
val.mDomain = domainName;
val.mSource = domainName;
Q_EMIT result(val);
Q_EMIT result(val, mEmailAddress);
deleteLater();
return;
}
}
Q_EMIT result({});
Q_EMIT result({}, mEmailAddress);
}
void DMARCPolicyJob::checkSubDomain(const QString &domainName)
......@@ -111,17 +111,17 @@ void DMARCPolicyJob::checkSubDomain(const QString &domainName)
connect(job, &MessageViewer::DMARCRecordJob::success, this, &DMARCPolicyJob::slotCheckSubDomain);
connect(job, &MessageViewer::DMARCRecordJob::error, this, [this](const QString &err, const QString &domainName) {
qCWarning(MESSAGEVIEWER_DKIMCHECKER_LOG) << "error: " << err << " domain " << domainName;
Q_EMIT result({});
Q_EMIT result({}, mEmailAddress);
deleteLater();
});
if (!job->start()) {
Q_EMIT result({});
Q_EMIT result({}, mEmailAddress);
deleteLater();
return;
}
} else {
//Invalid
Q_EMIT result({});
Q_EMIT result({}, mEmailAddress);
deleteLater();
return;
}
......@@ -144,7 +144,7 @@ void DMARCPolicyJob::slotCheckDomain(const QList<QByteArray> &lst, const QString
val.mPolicy = info.policy();
val.mDomain = domainName;
val.mSource = domainName;
Q_EMIT result(val);
Q_EMIT result(val, mEmailAddress);
deleteLater();
return;
}
......
......@@ -61,7 +61,7 @@ public:
void setEmailAddress(const QString &emailAddress);
Q_SIGNALS:
void result(const MessageViewer::DMARCPolicyJob::DMARCResult &value);
void result(const MessageViewer::DMARCPolicyJob::DMARCResult &value, const QString &emailAddress);
private:
void checkSubDomain(const QString &domainName);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment