1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge pull request #4610

drswinghead (1):
      feat(settings): add group chat local member black list
This commit is contained in:
sudden6 2017-09-19 21:23:55 +02:00
commit ed634ae0f4
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
7 changed files with 62 additions and 2 deletions

View File

@ -268,6 +268,10 @@ will alter your Tox ID. You don't need to tell your existing contacts your new
Tox ID, but you have to tell new contacts your new Tox ID. Your Tox ID can be
found in your [User Profile](#user-profile).
#### BlackList
BlackList is a feature of qTox that locally blocks a group member's messages across all your joined groups, in case someone spams a group. You need to put a members public key into the BlackList text box one per line to activate it. Currently qTox doesn't have a method to get the public key from a group member, this will be added in the future.
### Audio/Video
#### Audio Settings

View File

@ -336,6 +336,7 @@ void Settings::loadPersonal(Profile* profile)
{
typingNotification = ps.value("typingNotification", true).toBool();
enableLogging = ps.value("enableLogging", true).toBool();
blackList = ps.value("blackList").toString().split('\n');
}
ps.endGroup();
@ -686,6 +687,7 @@ void Settings::savePersonal(QString profileName, const ToxEncrypt* passkey)
{
ps.setValue("typingNotification", typingNotification);
ps.setValue("enableLogging", enableLogging);
ps.setValue("blackList", blackList.join('\n'));
}
ps.endGroup();
@ -1752,6 +1754,22 @@ void Settings::setTypingNotification(bool enabled)
}
}
QStringList Settings::getBlackList() const
{
QMutexLocker locker{&bigLock};
return blackList;
}
void Settings::setBlackList(const QStringList& blist)
{
QMutexLocker locker{&bigLock};
if (blist != blackList) {
blackList = blist;
emit blackListChanged(blackList);
}
}
QString Settings::getInDev() const
{
QMutexLocker locker{&bigLock};

View File

@ -89,6 +89,7 @@ class Settings : public QObject
// Privacy
Q_PROPERTY(bool typingNotification READ getTypingNotification WRITE setTypingNotification NOTIFY
typingNotificationChanged FINAL)
Q_PROPERTY(QStringList blackList READ getBlackList WRITE setBlackList NOTIFY blackListChanged FINAL)
// Audio
Q_PROPERTY(QString inDev READ getInDev WRITE setInDev NOTIFY inDevChanged FINAL)
@ -231,6 +232,7 @@ signals:
// Privacy
void typingNotificationChanged(bool enabled);
void dbSyncTypeChanged(Db::syncType type);
void blackListChanged(QStringList& blist);
// Audio
void inDevChanged(const QString& name);
@ -440,6 +442,8 @@ public:
// Privacy
bool getTypingNotification() const;
void setTypingNotification(bool enabled);
QStringList getBlackList() const;
void setBlackList(const QStringList& blist);
// State
QByteArray getWindowGeometry() const;
@ -618,6 +622,7 @@ private:
// Privacy
bool typingNotification;
Db::syncType dbSyncType;
QStringList blackList;
// Audio
QString inDev;

View File

@ -92,6 +92,7 @@ void PrivacyForm::showEvent(QShowEvent*)
bodyUI->nospamLineEdit->setText(Core::getInstance()->getSelfId().getNoSpamString());
bodyUI->cbTypingNotification->setChecked(s.getTypingNotification());
bodyUI->cbKeepHistory->setChecked(Settings::getInstance().getEnableLogging());
bodyUI->blackListTextEdit->setText(s.getBlackList().join('\n'));
}
void PrivacyForm::on_randomNosapamButton_clicked()
@ -118,6 +119,12 @@ void PrivacyForm::on_nospamLineEdit_textChanged()
};
}
void PrivacyForm::on_blackListTextEdit_textChanged()
{
const QStringList strlist = bodyUI->blackListTextEdit->toPlainText().split('\n');
Settings::getInstance().setBlackList(strlist);
}
void PrivacyForm::retranslateUi()
{
bodyUI->retranslateUi(this);

View File

@ -43,6 +43,7 @@ private slots:
void on_nospamLineEdit_editingFinished();
void on_randomNosapamButton_clicked();
void on_nospamLineEdit_textChanged();
void on_blackListTextEdit_textChanged();
virtual void showEvent(QShowEvent*) final override;
private:

View File

@ -36,8 +36,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>384</width>
<height>343</height>
<width>364</width>
<height>509</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
@ -117,6 +117,25 @@ If you are getting spammed with friend requests, change the NoSpam.</string>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="toolTip">
<string/>
</property>
<property name="title">
<string>BlackList</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QTextEdit" name="blackListTextEdit">
<property name="toolTip">
<string>Filter group message by group member's public key. Put public key here, one per line.</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -1692,6 +1692,12 @@ void Widget::onGroupMessageReceived(int groupnumber, int peernumber, const QStri
ToxPk author = core->getGroupPeerPk(groupnumber, peernumber);
bool isSelf = author == core->getSelfId().getPublicKey();
const Settings& s = Settings::getInstance();
if (s.getBlackList().contains(author.toString())) {
qDebug() << "onGroupMessageReceived: Filtered:" << author.toString();
return;
}
bool targeted =
!isSelf && (message.contains(nameMention) || message.contains(sanitizedNameMention));
if (targeted && !isAction) {