Commit 3b9a66cb authored by Laurent Montel's avatar Laurent Montel 😁

Improve block mail traking

parent d13af9db
......@@ -3197,7 +3197,7 @@ void ViewerPrivate::slotAddToWhiteList()
}
}
void ViewerPrivate::slotMailTrackingFound()
void ViewerPrivate::slotMailTrackingFound(const MessageViewer::BlockMailTrackingUrlInterceptor::MailTrackerBlackList &blacklist)
{
mMailTrackingWarning->animatedShow();
}
......
......@@ -39,6 +39,7 @@
#include <ksharedconfig.h>
#include <QPointer>
#include <QUrl>
#include <viewer/webengine/blockmailtrackingurlinterceptor/blockmailtrackingurlinterceptor.h>
#include <QObject>
#include <QTimer>
......@@ -435,7 +436,7 @@ private Q_SLOTS:
void slotMessageIsNotAScam();
void slotAddToWhiteList();
void slotFormSubmittedForbidden();
void slotMailTrackingFound();
void slotMailTrackingFound(const MessageViewer::BlockMailTrackingUrlInterceptor::MailTrackerBlackList &blacklist);
/** Show hide all fields specified inside this function */
void toggleFullAddressList();
......
......@@ -21,6 +21,7 @@
#include "blockmailtrackingurlinterceptor.h"
#include <QWebEngineUrlRequestInfo>
#include <QDebug>
using namespace MessageViewer;
BlockMailTrackingUrlInterceptor::BlockMailTrackingUrlInterceptor(QObject *parent)
......@@ -36,41 +37,43 @@ MessageViewer::BlockMailTrackingUrlInterceptor::~BlockMailTrackingUrlInterceptor
bool BlockMailTrackingUrlInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
{
//Test Url
//TODO
const QUrl urlRequestUrl(info.requestUrl());
if (urlRequestUrl.url().contains(QLatin1String("foo"))) {
return true;
//qDebug() << " bool BlockMailTrackingUrlInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)"<<urlRequestUrl;
for (int i = 0; i < mBackList.size(); ++i) {
if (urlRequestUrl.url().contains(mBackList.at(i).mPattern)) {
Q_EMIT mailTrackingFound(mBackList.at(i));
return true;
}
}
return false;
}
void BlockMailTrackingUrlInterceptor::initializeList()
{
// mBackList = QVector<MailTrackerBlackList>{
// {QStringLiteral("Sidekick"), QStringLiteral("t.signaux"), QStringLiteral("http://getsidekick.com") },
// {QStringLiteral("Sidekick"), QStringLiteral("t.sidekickopen"), QStringLiteral("http://getsidekick.com")},
// {QStringLiteral("Sidekick"), QStringLiteral("t.sigopn"), QStringLiteral("http://getsidekick.com")},
// {QStringLiteral("Banana Tag"), QStringLiteral("bl-1.com"), QStringLiteral("http://bananatag.com")},
// {QStringLiteral("Boomerang"), QStringLiteral("mailstat.us/tr"), QStringLiteral("http://boomeranggmail.com")},
// {QStringLiteral("Cirrus Inisght"), QStringLiteral("tracking.cirrusinsight.com"), QStringLiteral("http://cirrusinsight.com")},
// {QStringLiteral("Yesware"), QStringLiteral("app.yesware.com"), QStringLiteral("http://yesware.com")},
// {QStringLiteral("Yesware"), QStringLiteral("t.yesware.com"), QStringLiteral("http://yesware.com")},
// {QStringLiteral("Streak"), QStringLiteral("mailfoogae.appspot.com"), QStringLiteral("http://streak.com")},
// {QStringLiteral("LaunchBit"), QStringLiteral("launchbit.com/taz-pixel',url:'http://launchbit.com")},
// {QStringLiteral("MailChimp"), QStringLiteral("list-manage.com/track"), QStringLiteral("http://mailchimp.com")},
// {QStringLiteral("Postmark"), QStringLiteral("cmail1.com/t"), QStringLiteral("http://postmarkapp.com")},
// {QStringLiteral("iContact"), QStringLiteral("click.icptrack.com/icp/',url:'http://icontact.com")},
// {QStringLiteral("Infusionsoft"), QStringLiteral("infusionsoft.com/app/emailOpened"), QStringLiteral("http://infusionsoft.com")},
// {QStringLiteral("Intercom"), QStringLiteral("via.intercom.io/o"), QStringLiteral("http://intercom.io")},
// {QStringLiteral("Mandrill"), QStringLiteral("mandrillapp.com/track"), QStringLiteral("http://mandrillapp.com")},
// {QStringLiteral("Hubspot"), QStringLiteral("t.hsms06.com"), QStringLiteral("http://hubspot.com")},
// {QStringLiteral("RelateIQ"), QStringLiteral("app.relateiq.com/t.png"), QStringLiteral("http://relateiq.com")},
// {QStringLiteral("RJ Metrics"), QStringLiteral("go.rjmetrics.com"), QStringLiteral("http://rjmetrics.com")},
// {QStringLiteral("Mixpanel"), QStringLiteral("api.mixpanel.com/track"), QStringLiteral("http://mixpanel.com")},
// {QStringLiteral("Front App"), QStringLiteral("web.frontapp.com/api"), QStringLiteral("http://frontapp.com")},
// {QStringLiteral("Mailtrack.io"), QStringLiteral("mailtrack.io/trace"), QStringLiteral("http://mailtrack.io")},
// {QStringLiteral("ToutApp"), QStringLiteral("go.toutapp.com"), QStringLiteral("http://toutapp.com")},
// {QStringLiteral("Outreach"), QStringLiteral("app.outreach.io"), QStringLiteral("http://outreach.io")}
// };
mBackList = {
{QStringLiteral("Sidekick"), QStringLiteral("t.signaux"), QStringLiteral("http://getsidekick.com") },
{QStringLiteral("Sidekick"), QStringLiteral("t.sidekickopen"), QStringLiteral("http://getsidekick.com")},
{QStringLiteral("Sidekick"), QStringLiteral("t.sigopn"), QStringLiteral("http://getsidekick.com")},
{QStringLiteral("Banana Tag"), QStringLiteral("bl-1.com"), QStringLiteral("http://bananatag.com")},
{QStringLiteral("Boomerang"), QStringLiteral("mailstat.us/tr"), QStringLiteral("http://boomeranggmail.com")},
{QStringLiteral("Cirrus Inisght"), QStringLiteral("tracking.cirrusinsight.com"), QStringLiteral("http://cirrusinsight.com")},
{QStringLiteral("Yesware"), QStringLiteral("app.yesware.com"), QStringLiteral("http://yesware.com")},
{QStringLiteral("Yesware"), QStringLiteral("t.yesware.com"), QStringLiteral("http://yesware.com")},
{QStringLiteral("Streak"), QStringLiteral("mailfoogae.appspot.com"), QStringLiteral("http://streak.com")},
{QStringLiteral("LaunchBit"), QStringLiteral("launchbit.com/taz-pixel"), QStringLiteral("http://launchbit.com")},
{QStringLiteral("MailChimp"), QStringLiteral("list-manage.com/track"), QStringLiteral("http://mailchimp.com")},
{QStringLiteral("Postmark"), QStringLiteral("cmail1.com/t"), QStringLiteral("http://postmarkapp.com")},
{QStringLiteral("iContact"), QStringLiteral("click.icptrack.com/icp/"), QStringLiteral("http://icontact.com")},
{QStringLiteral("Infusionsoft"), QStringLiteral("infusionsoft.com/app/emailOpened"), QStringLiteral("http://infusionsoft.com")},
{QStringLiteral("Intercom"), QStringLiteral("via.intercom.io/o"), QStringLiteral("http://intercom.io")},
{QStringLiteral("Mandrill"), QStringLiteral("mandrillapp.com/track"), QStringLiteral("http://mandrillapp.com")},
{QStringLiteral("Hubspot"), QStringLiteral("t.hsms06.com"), QStringLiteral("http://hubspot.com")},
{QStringLiteral("RelateIQ"), QStringLiteral("app.relateiq.com/t.png"), QStringLiteral("http://relateiq.com")},
{QStringLiteral("RJ Metrics"), QStringLiteral("go.rjmetrics.com"), QStringLiteral("http://rjmetrics.com")},
{QStringLiteral("Mixpanel"), QStringLiteral("api.mixpanel.com/track"), QStringLiteral("http://mixpanel.com")},
{QStringLiteral("Front App"), QStringLiteral("web.frontapp.com/api"), QStringLiteral("http://frontapp.com")},
{QStringLiteral("Mailtrack.io"), QStringLiteral("mailtrack.io/trace"), QStringLiteral("http://mailtrack.io")},
{QStringLiteral("ToutApp"), QStringLiteral("go.toutapp.com"), QStringLiteral("http://toutapp.com")},
{QStringLiteral("Outreach"), QStringLiteral("app.outreach.io"), QStringLiteral("http://outreach.io")}
};
}
......@@ -46,8 +46,8 @@ public:
bool interceptRequest(QWebEngineUrlRequestInfo &info) override;
Q_SIGNALS:
//Add info about company
void mailTrackingFound();
void mailTrackingFound(const MessageViewer::BlockMailTrackingUrlInterceptor::MailTrackerBlackList &);
private:
void initializeList();
QVector<MailTrackerBlackList> mBackList;
......
......@@ -22,6 +22,7 @@
#include "messageviewer_export.h"
#include <WebEngineViewer/WebEngineView>
#include <boost/function.hpp>
#include <viewer/webengine/blockmailtrackingurlinterceptor/blockmailtrackingurlinterceptor.h>
class QPrinter;
class KActionCollection;
namespace WebEngineViewer {
......@@ -91,7 +92,7 @@ Q_SIGNALS:
void openUrl(const QUrl &url);
void messageMayBeAScam();
void formSubmittedForbidden();
void mailTrackingFound();
void mailTrackingFound(const MessageViewer::BlockMailTrackingUrlInterceptor::MailTrackerBlackList &);
/// Emitted when the user right-clicks somewhere
/// @param url if an URL was under the cursor, this parameter contains it. Otherwise empty
/// @param point position where the click happened, in local coordinates
......
......@@ -38,13 +38,21 @@ MailTrackingWarningWidget::~MailTrackingWarningWidget()
}
void MailTrackingWarningWidget::addTracker()
void MailTrackingWarningWidget::addTracker(const MessageViewer::BlockMailTrackingUrlInterceptor::MailTrackerBlackList &tracker)
{
blackListFound item = mBackLists.value(tracker.mCompanyName);
if (item.url.isEmpty()) {
item.url = tracker.mCompanyUrl;
mBackLists.insert(tracker.mCompanyName, item);
} else {
item.number = item.number + 1;
mBackLists.insert(tracker.mCompanyName, item);
}
//show info
}
void MailTrackingWarningWidget::hideAndClear()
{
//TODO clear !
mBackLists.clear();
setVisible(false);
}
......@@ -22,6 +22,9 @@
#define MAILTRACKINGWARNINGWIDGET_H
#include <KMessageWidget>
#include <QMap>
#include <viewer/webengine/blockmailtrackingurlinterceptor/blockmailtrackingurlinterceptor.h>
namespace MessageViewer {
class MailTrackingWarningWidget : public KMessageWidget
......@@ -30,8 +33,14 @@ class MailTrackingWarningWidget : public KMessageWidget
public:
explicit MailTrackingWarningWidget(QWidget *parent = nullptr);
~MailTrackingWarningWidget();
void addTracker();
void addTracker(const MessageViewer::BlockMailTrackingUrlInterceptor::MailTrackerBlackList &);
void hideAndClear();
private:
struct blackListFound {
QString url;
int number = 1;
};
QMap<QString, blackListFound> mBackLists;
};
}
......
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