Compare commits

..

No commits in common. "main" and "main" have entirely different histories.
main ... main

23 changed files with 42 additions and 85 deletions

View File

@ -28,10 +28,6 @@ class ChatService(BaseService):
"is_final": channel_message["is_final"],
},
)
await self.app.create_task(
self.services.notification.create_channel_message(message_uid)
)
async def send(self, user_uid, channel_uid, message, is_final=True):

View File

@ -1,6 +1,6 @@
from snek.system.model import now
from snek.system.service import BaseService
from snek.system.markdown import strip_markdown
class NotificationService(BaseService):
mapper_name = "notification"
@ -33,8 +33,6 @@ class NotificationService(BaseService):
channel_message = await self.services.channel_message.get(
uid=channel_message_uid
)
if not channel_message["is_final"]:
return
user = await self.services.user.get(uid=channel_message["user_uid"])
self.app.db.begin()
async for channel_member in self.services.channel_member.find(
@ -66,13 +64,11 @@ class NotificationService(BaseService):
if channel_member["user_uid"] != user["uid"]:
try:
stripped_message = strip_markdown(channel_message["message"])
channel_name = await channel_member.get_name()
await self.app.services.push.notify_user(
user_uid=channel_member["user_uid"],
payload={
"title": f"New message in {channel_name}",
"message": f"{user['nick']}: {stripped_message}",
"title": f"New message in {channel_member['label']}",
"message": f"{user['nick']}: {channel_message['message']}",
"icon": "/image/snek192.png",
"url": f"/channel/{channel_message['channel_uid']}.html",
},

Binary file not shown.

Before

(image error) Size: 1.3 MiB

Binary file not shown.

Before

(image error) Size: 1.2 MiB

Binary file not shown.

Before

(image error) Size: 14 KiB

Binary file not shown.

Before

(image error) Size: 17 KiB

Binary file not shown.

Before

(image error) Size: 1.0 KiB

Binary file not shown.

Before

(image error) Size: 25 KiB

Binary file not shown.

Before

(image error) Size: 40 KiB

Binary file not shown.

Before

(image error) Size: 1.8 KiB

Binary file not shown.

Before

(image error) Size: 79 KiB

Binary file not shown.

Before

(image error) Size: 3.2 KiB

Binary file not shown.

Before

(image error) Size: 132 KiB

Binary file not shown.

Before

(image error) Size: 117 KiB

Binary file not shown.

Before

(image error) Size: 5.0 KiB

Binary file not shown.

Before

(image error) Size: 5.9 KiB

Binary file not shown.

Before

(image error) Size: 177 KiB

Binary file not shown.

Before

(image error) Size: 9.0 KiB

Binary file not shown.

Before

(image error) Size: 1.3 MiB

View File

@ -1,58 +1,30 @@
{
"id": "snek",
"name": "Snek",
"short_name": "Snek",
"description": "Snek Software Development Community",
"display": "standalone",
"orientation": "portrait",
"scope": "/",
"start_url": "/web.html",
"theme_color": "#000000",
"background_color": "#000000",
"dir": "ltr",
"lang": "en-US",
"icons": [
{
"src": "/image/snek_logo_32x32.png",
"type": "image/png",
"sizes": "32x32"
},
{
"src": "/image/snek_logo_64x64.png",
"type": "image/png",
"sizes": "64x64"
},
{
"src": "/image/snek_logo_128x128.png",
"type": "image/png",
"sizes": "128x128"
},
{
"src": "/image/snek_logo_144x144.png",
"type": "image/png",
"sizes": "144x144"
},
{
"src": "/image/snek_logo_192x192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "/image/snek_logo_256x256.png",
"type": "image/png",
"sizes": "256x256"
},
{
"src": "/image/snek_logo_512x512.png",
"type": "image/png",
"sizes": "512x512"
},
{
"src": "/image/snek_logo_1024x1024.png",
"type": "image/png",
"sizes": "1024x1024"
}
],
"related_applications": [],
"prefer_related_applications": false
}
"id": "snek",
"name": "Snek",
"description": "Danger noodle",
"display": "standalone",
"orientation": "portrait",
"scope": "/",
"theme_color": "#000000",
"background_color": "#000000",
"related_applications": [],
"prefer_related_applications": false,
"screenshots": [],
"dir": "ltr",
"lang": "en-US",
"launch_path": "/web.html",
"short_name": "Snek",
"start_url": "/web.html",
"icons": [
{
"src": "/image/snek192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "/image/snek512.png",
"type": "image/png",
"sizes": "512x512"
}
]
}

View File

@ -1,5 +1,5 @@
# Original source: https://brandonjay.dev/posts/2021/render-markdown-html-in-python-with-jinja2
import re
from types import SimpleNamespace
from app.cache import time_cache_async
@ -12,20 +12,6 @@ from pygments.formatters import html
from pygments.lexers import get_lexer_by_name
def strip_markdown(md_text):
# Remove code blocks (
md_text = re.sub(r'[\s\S]?```', '', md_text)
md_text = re.sub(r'^\s{4,}.$', '', md_text, flags=re.MULTILINE)
md_text = re.sub(r'^\s{0,3}#{1,6}\s+', '', md_text, flags=re.MULTILINE)
md_text = re.sub(r'!\[.?\]\(.?\)', '', md_text)
md_text = re.sub(r'\[([^\]]+)\]\(.?\)', r'\1', md_text)
md_text = re.sub(r'(\*|_){1,3}(.+?)\1{1,3}', r'\2', md_text)
md_text = re.sub(r'^\s{0,3}>+\s?', '', md_text, flags=re.MULTILINE)
md_text = re.sub(r'^(\s)(\-{3,}|_{3,}|\{3,})\s$', '', md_text, flags=re.MULTILINE)
md_text = re.sub(r'[`~>#+\-=]', '', md_text)
md_text = re.sub(r'\s+', ' ', md_text)
return md_text.strip()
class MarkdownRenderer(HTMLRenderer):
_allow_harmful_protocols = False

View File

@ -21,8 +21,14 @@
<link rel="stylesheet" href="/user-list.css">
<link rel="stylesheet" href="/fa640.all.min.css">
<link rel="stylesheet" href="/base.css">
<link rel="icon" type="image/png" href="/image/snek_logo_32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/image/snek_logo_64x64.png" sizes="64x64">
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"
integrity="sha512-pBMV+3tn6+5xAZuhI6tyCmQkXh15riZDqGPxAx/U+FuiI5Dh3ZTjM23cZqQ25jJCfi8+ka9gzC2ukNkGkP/Aw=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<link rel="icon" type="image/png" href="/image/snek1.png" sizes="32x32">
<script defer src="https://umami.molodetz.nl/script.js" data-website-id="d127c3e4-dc70-4041-a1c8-bcc32c2492ea"></script>
</head>
<body>

View File

@ -33,6 +33,7 @@ class PushView(BaseFormView):
if not all(
[
"encoding" in body,
"endpoint" in body,
"keys" in body,
"p256dh" in body["keys"],