This commit is contained in:
retoor 2025-03-22 20:42:38 +01:00
parent 6e68408ddf
commit 604e27ce10
3 changed files with 31 additions and 6 deletions
src/snek
terminal

View File

@ -143,6 +143,31 @@ class Application(BaseApplication):
# @time_cache_async(60)
async def render_template(self, template, request, context=None):
channels = []
if not context:
context = {}
if request.session.get("uid"):
async for subscribed_channel in self.services.channel_member.find(user_uid=request.session.get("uid"), deleted_at=None, is_banned=False):
item = {}
other_user = await self.services.channel_member.get_other_dm_user(subscribed_channel["channel_uid"], request.session.get("uid"))
parent_object = await subscribed_channel.get_channel()
last_message =await parent_object.get_last_message()
item["last_message_on"] = parent_object["last_message_on"]
item["is_private"] = parent_object["tag"] == "dm"
if other_user:
item["name"] = other_user["nick"]
item["uid"] = subscribed_channel["channel_uid"]
else:
item["name"] = subscribed_channel["label"]
item["uid"] = subscribed_channel["channel_uid"]
channels.append(item)
channels.sort(key=lambda x: x['last_message_on'] or '', reverse=True)
if not 'channels' in context:
context['channels'] = channels
if not 'user' in context:
context['user'] = await self.services.user.get(uid=request.session.get("uid"))
return await super().render_template(template, request, context)

View File

@ -17,9 +17,8 @@ class TerminalSocketView(BaseView):
terminal_folder = pathlib.Path("terminal")
for path in terminal_folder.iterdir():
destination_path = root.joinpath(path.name)
if not destination_path.exists():
if not path.is_dir():
destination_path.write_bytes(path.read_bytes())
if not path.is_dir():
destination_path.write_bytes(path.read_bytes())
return root
async def get(self):

View File

@ -94,11 +94,11 @@ fi
cp ~/r /usr/local/bin
chmod -x /usr/local/bin/*
chmod -x /usr/local/bin/r
apt update && apt install libreadline-dev libcurl4-openssl-dev libssl-dev libncurses5-dev libncursesw5-dev libsqlite3-dev libreadline6-dev zlib1g-dev libbz2-dev libffi-dev liblzma-dev python3 python3-pip python3-venv -y
apt update && apt install libreadline-dev libcurl4-openssl-dev libssl-dev libncurses5-dev libncursesw5-dev libsqlite3-dev libreadline6-dev zlib1g-dev libbz2-dev libffi-dev liblzma-dev python3 python3-pip python3-venv libjson-c-dev -y
echo "r is installed."
echo "R is installed. Type r to run it."
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
@ -106,3 +106,4 @@ echo "r is installed."
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
# . /etc/bash_completion
#fi
export PS1="root@snek: "