diff --git a/core/lib/context.py b/core/lib/context.py
index c4607ad..40b560d 100644
--- a/core/lib/context.py
+++ b/core/lib/context.py
@@ -23,6 +23,7 @@ def construct_query(index, net, channel, src, num, size, type=None, nicks=None):
"type",
"net",
"src",
+ "tokens",
]
if index == "int":
fields.append("mtype")
diff --git a/core/lib/opensearch.py b/core/lib/opensearch.py
index abe0912..55b60c3 100644
--- a/core/lib/opensearch.py
+++ b/core/lib/opensearch.py
@@ -448,10 +448,11 @@ def query_results(
results_parsed = dedup_list(results_parsed, dedup_fields)
if settings.ENCRYPTION:
- encrypt_list(results_parsed, settings.ENCRYPTION_KEY)
+ encrypt_list(request.user, results_parsed, settings.ENCRYPTION_KEY)
- if settings.HASHING:
- hash_list(results_parsed)
+ if not request.user.has_perm("view_plain"):
+ if settings.HASHING:
+ hash_list(request.user, results_parsed)
# process_list(reqults)
diff --git a/core/migrations/0007_perms.py b/core/migrations/0007_perms.py
new file mode 100644
index 0000000..816264d
--- /dev/null
+++ b/core/migrations/0007_perms.py
@@ -0,0 +1,22 @@
+# Generated by Django 4.0.6 on 2022-08-16 18:04
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('core', '0006_contentblock_page'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Perms',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ],
+ options={
+ 'permissions': (('bypass_hashing', 'Can bypass field hashing'), ('bypass_blacklist', 'Can bypass the blacklist'), ('bypass_encryption', 'Can bypass field encryption'), ('post_irc', 'Can post to IRC'), ('post_discord', 'Can post to Discord')),
+ },
+ ),
+ ]
diff --git a/core/models.py b/core/models.py
index fbef7a1..4b2721e 100644
--- a/core/models.py
+++ b/core/models.py
@@ -104,15 +104,12 @@ class ContentBlock(models.Model):
super().save(*args, **kwargs)
-class Role(models.Model):
- name = models.CharField(max_length=255, unique=True)
- description = models.CharField(max_length=1024, null=True, blank=True)
- permission = models.CharField(max_length=255)
-
- def __str__(self):
- return self.name
-
-
-class ContentPermission(models.Model):
- inherit = models.ForeignKey("self", null=True, blank=True, on_delete=models.PROTECT)
- roles = models.ManyToManyField(Role, blank=True)
+class Perms(models.Model):
+ class Meta:
+ permissions = (
+ ("bypass_hashing", "Can bypass field hashing"),
+ ("bypass_blacklist", "Can bypass the blacklist"),
+ ("bypass_encryption", "Can bypass field encryption"),
+ ("post_irc", "Can post to IRC"),
+ ("post_discord", "Can post to Discord"),
+ )
diff --git a/core/templates/modals/context_table.html b/core/templates/modals/context_table.html
index e720018..16dded2 100644
--- a/core/templates/modals/context_table.html
+++ b/core/templates/modals/context_table.html
@@ -82,6 +82,10 @@
+ {% elif item.type == 'topic' %}
+
+
+
{% else %}
{{ item.type }}
{% endif %}
diff --git a/core/templates/ui/drilldown/drilldown.html b/core/templates/ui/drilldown/drilldown.html
index e3418ba..ef2bf9b 100644
--- a/core/templates/ui/drilldown/drilldown.html
+++ b/core/templates/ui/drilldown/drilldown.html
@@ -49,15 +49,9 @@
populateSearch(field, value);
});
}
- var plain_fields = ["ts", "date", "time", "sentiment", "version_sentiment", "tokens", "num_chans", "num_users", "tokens", "src", "exemption", "hidden"];
function populateSearch(field, value) {
var queryElement = document.getElementById('query');
- if (!plain_fields.includes(field)) {
- if (!value.startsWith("|") && !value.endsWith("|")) {
- value = `|${value}|`;
- }
- }
var present = true;
if (present == true) {
var combinations = [`${field}: "${value}"`,
diff --git a/core/templates/ui/drilldown/table_results_partial.html b/core/templates/ui/drilldown/table_results_partial.html
index 68fcc6f..72a5844 100644
--- a/core/templates/ui/drilldown/table_results_partial.html
+++ b/core/templates/ui/drilldown/table_results_partial.html
@@ -122,6 +122,7 @@
Hidden {{ row.cells.hidden }} similar result{% if row.cells.hidden > 1%}s{% endif %}
|
+
{% else %}
+ {% elif cell == 'topic' %}
+
+
+
{% else %}
{{ cell }}
{% endif %}
@@ -238,16 +243,16 @@
class="has-text-grey is-underlined"
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-post="{% url 'modal_context' %}"
- hx-vals='{"net": "|{{ row.cells.net|escapejs }}|",
- "num": "|{{ row.cells.num|escapejs }}|",
+ hx-vals='{"net": "{{ row.cells.net|escapejs }}",
+ "num": "{{ row.cells.num|escapejs }}",
"src": "{{ row.cells.src|escapejs }}",
- "channel": "|{{ row.cells.channel|escapejs }}|",
+ "channel": "{{ row.cells.channel|escapejs }}",
"time": "{{ row.cells.time|escapejs }}",
"date": "{{ row.cells.date|escapejs }}",
"index": "{{ params.index }}",
- "type": "|{{ row.cells.type }}|",
+ "type": "{{ row.cells.type }}",
"mtype": "{{ row.cells.mtype }}",
- "nick": "|{{ row.cells.nick|escapejs }}|",
+ "nick": "{{ row.cells.nick|escapejs }}",
"dedup": "{{ params.dedup }}"}'
hx-target="#modals-here"
hx-trigger="click"
@@ -281,7 +286,7 @@