Heavy repair.

This commit is contained in:
retoor 2025-02-03 21:15:18 +01:00
parent f395d16173
commit 084f8dba20
5 changed files with 27 additions and 51 deletions

View File

@ -30,7 +30,6 @@ RUN apk add --no-cache \
&& apk del .build-deps && apk del .build-deps
COPY --from=wkhtmltopdf /bin/wkhtmltopdf /bin/wkhtmltopdf COPY --from=wkhtmltopdf /bin/wkhtmltopdf /bin/wkhtmltopdf
COPY --from=wkhtmltopdf /bin/wkhtmltoimage /bin/wkhtmltoimage COPY --from=wkhtmltopdf /bin/wkhtmltoimage /bin/wkhtmltoimage
COPY setup.cfg setup.cfg
COPY pyproject.toml pyproject.toml COPY pyproject.toml pyproject.toml
COPY src src COPY src src
RUN pip install --upgrade pip RUN pip install --upgrade pip

View File

@ -4,7 +4,6 @@ RUN apk add --no-cache gcc musl-dev linux-headers git openssh
#WKHTMLTOPDFNEEDS #WKHTMLTOPDFNEEDS
COPY setup.cfg setup.cfg
COPY pyproject.toml pyproject.toml COPY pyproject.toml pyproject.toml
COPY src src COPY src src
COpy ssh_host_key ssh_host_key COpy ssh_host_key ssh_host_key

View File

@ -27,6 +27,7 @@ dependencies = [
"requests", "requests",
"asyncssh", "asyncssh",
"emoji", "emoji",
"pywebpush" "pywebpush",
"aiofiles"
] ]

View File

@ -1,29 +0,0 @@
[metadata]
name = snek
version = 1.0.0
description = Snek chat server
author = retoor
author_email = retoor@molodetz.nl
license = MIT
long_description = file: README.md
long_description_content_type = text/markdown
[options]
packages = find:
package_dir =
= src
python_requires = >=3.7
install_requires =
app @ git+https://retoor.molodetz.nl/retoor/app
beautifulsoup4
gunicorn
imgkit
wkhtmltopdf
shed
[options.packages.find]
where = src
[options.entry_points]
console_scripts =
snek.serve = snek.server:cli

View File

@ -166,9 +166,10 @@ class Socket extends EventHandler {
if (this.ensureTimer) { if (this.ensureTimer) {
return this.connect(); return this.connect();
} }
const me = this;
this.ensureTimer = setInterval(() => { this.ensureTimer = setInterval(() => {
if (this.isConnecting) this.isConnecting = false; if (me.isConnecting) me.isConnecting = false;
this.connect(); me.connect();
}, 5000); }, 5000);
return this.connect(); return this.connect();
} }
@ -178,32 +179,34 @@ class Socket extends EventHandler {
} }
connect() { connect() {
const me = this
if (this.isConnected || this.isConnecting) { if (this.isConnected || this.isConnecting) {
return new Promise((resolve) => { return new Promise((resolve) => {
this.connectPromises.push(resolve); me.connectPromises.push(resolve);
if (!this.isConnected) resolve(this); if (!me.isConnecting) resolve(me);
}); });
} }
this.isConnecting = true; this.isConnecting = true;
return new Promise((resolve) => { return new Promise((resolve) => {
this.connectPromises.push(resolve); me.connectPromises.push(resolve);
console.debug("Connecting.."); console.debug("Connecting..");
const ws = new WebSocket(this.url); const ws = new WebSocket(me.url);
ws.onopen = () => { ws.onopen = () => {
this.ws = ws; me.ws = ws;
this.isConnected = true; me.isConnected = true;
this.isConnecting = false; me.isConnecting = false;
ws.onmessage = (event) => { ws.onmessage = (event) => {
this.onData(JSON.parse(event.data)); me.onData(JSON.parse(event.data));
}; };
ws.onclose = () => { ws.onclose = () => {
this.onClose(); me.onClose();
}; };
ws.onerror = () => { ws.onerror = () => {
this.onClose(); me.onClose();
}; };
this.connectPromises.forEach(resolver => resolver(this)); me.connectPromises.forEach(resolver => resolver(me));
}; };
}); });
} }
@ -233,9 +236,10 @@ class Socket extends EventHandler {
method, method,
args, args,
}; };
const me = this
return new Promise((resolve) => { return new Promise((resolve) => {
this.addEventListener(call.callId, data => resolve(data)); me.addEventListener(call.callId, data => resolve(data));
this.sendJson(call); me.sendJson(call);
}); });
} }
@ -281,12 +285,13 @@ class App extends EventHandler {
this.ws = new Socket(); this.ws = new Socket();
this.rpc = this.ws.client; this.rpc = this.ws.client;
this.audio = new NotificationAudio(500); this.audio = new NotificationAudio(500);
const me = this
this.ws.addEventListener("channel-message", (data) => { this.ws.addEventListener("channel-message", (data) => {
this.emit(data.channel_uid, data); me.emit(data.channel_uid, data);
}); });
this.rpc.getUser(null).then(user => { this.rpc.getUser(null).then(user => {
this.user = user; me.user = user;
}); });
} }
@ -296,10 +301,11 @@ class App extends EventHandler {
async benchMark(times = 100, message = "Benchmark Message") { async benchMark(times = 100, message = "Benchmark Message") {
const promises = []; const promises = [];
const me = this;
for (let i = 0; i < times; i++) { for (let i = 0; i < times; i++) {
promises.push(this.rpc.getChannels().then(channels => { promises.push(this.rpc.getChannels().then(channels => {
channels.forEach(channel => { channels.forEach(channel => {
this.rpc.sendMessage(channel.uid, `${message} ${i}`); me.rpc.sendMessage(channel.uid, `${message} ${i}`);
}); });
})); }));
} }