fix(js): fix not defined recipients

master
Romain J 6 months ago
parent 86697143b6
commit a5fc2623bf
No known key found for this signature in database
GPG Key ID: 3227578329C2A3A7
  1. 7
      .github/dependabot.yml
  2. 87
      .github/workflows/ci.yml
  3. 0
      .idea/sonarlint/issuestore/8/9/899ce9c202bf7bb5480e72836c3edc773c9c4244
  4. 0
      .idea/sonarlint/issuestore/a/5/a5dc085793ad7a9c90ce7a0624500212ae09a943
  5. 6
      .idea/sonarlint/issuestore/index.pb
  6. 14
      README.rst
  7. 12
      chat/libs/templatetags/utils.py
  8. 4
      chat/static/js/components/message.js
  9. 13
      chat/templates/guild/channels/details.html
  10. 24
      chat/templates/layouts/components/message/block.html

@ -1,7 +0,0 @@
version: 2
updates:
# Update Github actions in workflows
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"

@ -1,87 +0,0 @@
name: CI
# Enable Buildkit and let compose use it to speed up image building
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
on:
pull_request:
branches: [ "master", "main" ]
paths-ignore: [ "docs/**" ]
push:
branches: [ "master", "main" ]
paths-ignore: [ "docs/**" ]
jobs:
linter:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
# Run all pre-commit hooks on all the files.
# Getting only staged files can be tricky in case a new PR is opened
# since the action is run on a branch in detached head state
- name: Install and Run Pre-commit
uses: pre-commit/action@v2.0.3
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v1
# With no caching at all the entire ci process takes 4m 30s to complete!
pytest:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: postgres
env:
# postgres://user:password@host:port/database
DATABASE_URL: "postgres://postgres:postgres@localhost:5432/postgres"
steps:
- name: Checkout Code Repository
uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v1
- name: Get pip cache dir
id: pip-cache-location
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache pip Project Dependencies
uses: actions/cache@v2
with:
# Get the location of pip cache dir
path: ${{ steps.pip-cache-location.outputs.dir }}
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('**/local.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/local.txt
- name: Test with pytest
run: pytest

@ -5,8 +5,6 @@ X
(chat/static/images/icons/circle_plus.svg,7/1/710beb2266b3babcf8a315e4692012e33057d270
F
.github/dependabot.yml,0/9/091aff741808a09242f252264b14f4a9adaa5305
H
.github/workflows/ci.yml,8/9/899ce9c202bf7bb5480e72836c3edc773c9c4244
Q
!chat/templates/account/login.html,9/3/930a721a34c460ca4d389cf27470804b2d1ecb1d
c
@ -36,6 +34,4 @@ B
V
&chat/libs/templatetags/qr_generator.py,7/a/7a7f2347c6fcd297de4ae8b927d4e209a2c0f861
Y
)chat/templates/layouts/parts/sidebar.html,e/a/eabbd5a8b009dae85951e8d6a0cac8957aacfcf5
Q
!chat/libs/templatetags/abs_url.py,a/5/a5dc085793ad7a9c90ce7a0624500212ae09a943
)chat/templates/layouts/parts/sidebar.html,e/a/eabbd5a8b009dae85951e8d6a0cac8957aacfcf5

@ -40,21 +40,13 @@ Running type checking and linter with:
$ make style
Test coverage
Run development
^^^^^^^^^^^^^
To run the tests, check your test coverage, and generate an HTML coverage report::
To run the development server:
$ coverage run -m pytest
$ coverage html
$ open htmlcov/index.html
$ make gulp
Running tests with py.test
~~~~~~~~~~~~~~~~~~~~~~~~~~
::
$ pytest
Live reloading and Sass CSS compilation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@ -0,0 +1,12 @@
from django import template
register = template.Library()
@register.filter
def replace(value, arg: str):
if len(arg.split('|')) != 2:
return value
what, to = arg.split('|')
return str(value).replace(what, to)

@ -21,9 +21,9 @@ function createAttachments(attachments) {
for (let attachment in attachments) {
block += `
<li>
<a target="_blank" class="link" href="${ attachment.file.url }">
<a target="_blank" class="link" href="${attachment.file.url}">
${boldExtension(attachment.file.name)}
<span>(${ attachment.file.size })</span>
<span>(${attachment.file.size})</span>
</a>
</li>`
}

@ -1,5 +1,7 @@
{% extends "layouts/base.html" %}
{% load i18n %}
{% load utils %}
{% block title %}{{ room_name.name }} - {{ APP_NAME }}{% endblock %}
@ -81,6 +83,15 @@
function send_message() {
if (!window.recipients) {
UIkit.notification({
message: '{% trans "Please wait few seconds..." %}',
pos: 'top-right',
status: 'primary'
});
return
}
for (const [recipient_id, recipient_pubKey] of Object.entries(recipients)) {
const sharedKey = nacl.box.before(nacl.util.decodeBase64(recipient_pubKey), usableKeyPair.secretKey);
@ -90,7 +101,7 @@
nacl.util.decodeUTF8(textarea.value),
nonce,
sharedKey
)
);
const message = {box, nonce};
ws.send(JSON.stringify({

@ -1,3 +1,4 @@
{% load utils %}
{% load define %}
{% load static %}
{% load debug %}
@ -51,13 +52,22 @@
<div class="uk-comment-body">
<p id="{{ message.id }}">{% trans "Loading..." %}</p>
<script>
window.addEventListener('load', () => {
document.getElementById("{{ message.id }}").innerText = (
decipher(
{box: '{{ message.content }}', nonce: '{{ message.nonce }}'},
'{{ message.author.id }}'
)
);
document.addEventListener('DOMContentLoaded', () => {
function _decipher_message_{{ message.id|replace:"-|_" }}() {
document.getElementById("{{ message.id }}").innerText = (
decipher(
{box: '{{ message.content }}', nonce: '{{ message.nonce }}'},
'{{ message.author.id }}'
)
);
}
(async () => {
while (!window.hasOwnProperty("recipients"))
await new Promise(resolve => setTimeout(resolve, 100));
_decipher_message_{{ message.id|replace:"-|_" }}();
})();
});
</script>
</div>

Loading…
Cancel
Save