Added option to use blocklists for POP3

pull/207/head
M66B 3 years ago
parent d730ed8909
commit 9ca4808a72

@ -2763,6 +2763,8 @@ class Core {
boolean notify_known = prefs.getBoolean("notify_known", false);
boolean download_eml = prefs.getBoolean("download_eml", false);
boolean download_plain = prefs.getBoolean("download_plain", false);
boolean check_blocklist = prefs.getBoolean("check_blocklist", false);
boolean use_blocklist_pop = prefs.getBoolean("use_blocklist_pop", false);
boolean pro = ActivityBilling.isPro(context);
boolean force = jargs.optBoolean(5, false);
@ -3052,7 +3054,26 @@ class Core {
// No reply_domain
// No MX check
// No blocklist
if (check_blocklist && use_blocklist_pop) {
message.blocklist = DnsBlockList.isJunk(context,
imessage.getHeader("Received"));
if (message.blocklist == null || !message.blocklist) {
List<Address> senders = new ArrayList<>();
if (message.reply != null)
senders.addAll(Arrays.asList(message.reply));
if (message.from != null)
senders.addAll(Arrays.asList(message.from));
message.blocklist = DnsBlockList.isJunk(context, senders);
}
if (Boolean.TRUE.equals(message.blocklist)) {
EntityLog.log(context, account.name + " POP blocklist=" +
MessageHelper.formatAddresses(message.from));
continue;
}
}
if (message.from != null) {
EntityContact badboy = null;

@ -102,6 +102,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
private SwitchCompat swCheckMx;
private SwitchCompat swCheckBlocklist;
private SwitchCompat swUseBlocklist;
private SwitchCompat swUseBlocklistPop;
private RecyclerView rvBlocklist;
private AdapterBlocklist badapter;
@ -115,7 +116,8 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
"sync_nodate", "sync_unseen", "sync_flagged", "delete_unseen", "sync_kept",
"gmail_thread_id", "outlook_thread_id", "subject_threading",
"sync_folders", "sync_folders_poll", "sync_shared_folders", "subscriptions",
"check_authentication", "check_tls", "check_reply_domain", "check_mx", "check_blocklist", "use_blocklist",
"check_authentication", "check_tls", "check_reply_domain", "check_mx",
"check_blocklist", "use_blocklist", "use_blocklist_pop",
"tune_keep_alive"
};
@ -177,6 +179,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
swCheckMx = view.findViewById(R.id.swCheckMx);
swCheckBlocklist = view.findViewById(R.id.swCheckBlocklist);
swUseBlocklist = view.findViewById(R.id.swUseBlocklist);
swUseBlocklistPop = view.findViewById(R.id.swUseBlocklistPop);
rvBlocklist = view.findViewById(R.id.rvBlocklist);
grpExempted = view.findViewById(R.id.grpExempted);
@ -454,6 +457,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("check_blocklist", checked).apply();
swUseBlocklist.setEnabled(checked);
swUseBlocklistPop.setEnabled(checked);
}
});
@ -464,6 +468,13 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
}
});
swUseBlocklistPop.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("use_blocklist_pop", checked).apply();
}
});
rvBlocklist.setHasFixedSize(false);
rvBlocklist.setLayoutManager(new LinearLayoutManager(getContext()));
badapter = new AdapterBlocklist(getContext(), DnsBlockList.getListsAvailable());
@ -575,6 +586,8 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
swCheckBlocklist.setChecked(prefs.getBoolean("check_blocklist", false));
swUseBlocklist.setChecked(prefs.getBoolean("use_blocklist", false));
swUseBlocklist.setEnabled(swCheckBlocklist.isChecked());
swUseBlocklistPop.setChecked(prefs.getBoolean("use_blocklist_pop", false));
swUseBlocklistPop.setEnabled(swCheckBlocklist.isChecked());
}
private String formatHour(Context context, int minutes) {

@ -926,6 +926,18 @@
app:layout_constraintTop_toBottomOf="@id/tvCheckBlocklistWarning"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swUseBlocklistPop"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_use_blocklist_pop3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swUseBlocklist"
app:switchPadding="12dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvBlocklist"
android:layout_width="0dp"
@ -935,7 +947,7 @@
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swUseBlocklist" />
app:layout_constraintTop_toBottomOf="@id/swUseBlocklistPop" />
</eu.faircode.email.ConstraintLayoutEx>
</androidx.cardview.widget.CardView>
</eu.faircode.email.ConstraintLayoutEx>

@ -378,6 +378,7 @@
<string name="title_advanced_check_mx">Check sender email addresses on synchronizing messages</string>
<string name="title_advanced_check_blocklist">Check if the sender\'s domain name is on a spam block list</string>
<string name="title_advanced_use_blocklist">Move messages from domains on a block list to the spam folder</string>
<string name="title_advanced_use_blocklist_pop3">Skip messages from domains on a block list (POP3 only)</string>
<string name="title_advanced_tune_keep_alive">Automatically tune the keep-alive interval</string>
<string name="title_advanced_keyboard">Show keyboard by default</string>

Loading…
Cancel
Save