mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
feat(settings): add group chat local member black list
This commit is contained in:
parent
776b37f689
commit
27ecace752
|
@ -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
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
@ -1733,6 +1735,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};
|
||||
|
|
|
@ -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)
|
||||
|
@ -227,6 +228,7 @@ signals:
|
|||
// Privacy
|
||||
void typingNotificationChanged(bool enabled);
|
||||
void dbSyncTypeChanged(Db::syncType type);
|
||||
void blackListChanged(QStringList& blist);
|
||||
|
||||
// Audio
|
||||
void inDevChanged(const QString& name);
|
||||
|
@ -436,6 +438,8 @@ public:
|
|||
// Privacy
|
||||
bool getTypingNotification() const;
|
||||
void setTypingNotification(bool enabled);
|
||||
QStringList getBlackList() const;
|
||||
void setBlackList(const QStringList& blist);
|
||||
|
||||
// State
|
||||
QByteArray getWindowGeometry() const;
|
||||
|
@ -614,6 +618,7 @@ private:
|
|||
// Privacy
|
||||
bool typingNotification;
|
||||
Db::syncType dbSyncType;
|
||||
QStringList blackList;
|
||||
|
||||
// Audio
|
||||
QString inDev;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -1689,6 +1689,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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user