Most recent users.

This commit is contained in:
retoor 2025-05-27 14:03:01 +02:00
parent 973afa0cc2
commit 96629113f1
3 changed files with 19 additions and 3 deletions
src/snek

View File

@ -67,6 +67,10 @@ class ChannelService(BaseService):
await self.services.channel_member.create_dm(channel["uid"], user1, user2)
return channel
async def get_recent_users(self, channel_uid):
async for user in self.query("SELECT user.uid, user.username,user.color,user.last_ping,user.nick FROM channel_member INNER JOIN user ON user.uid = channel_member.user_uid WHERE channel_uid=:channel_uid ORDER BY last_ping DESC LIMIT 30", {"channel_uid": channel_uid}):
yield user
async def get_users(self, channel_uid):
async for channel_member in self.services.channel_member.find(
channel_uid=channel_uid,

View File

@ -56,7 +56,7 @@ class ChatInputComponent extends HTMLElement {
}
extractMentions(text) {
const regex = /@([a-zA-Z0-9_]+)/g;
const regex = /@([a-zA-Z0-9_-]+)/g;
const mentions = [];
let match;
@ -81,7 +81,6 @@ class ChatInputComponent extends HTMLElement {
distance += 10
}
console.warn([ mention, author, distance ]);
if (distance < minDistance) {
minDistance = distance;
closestAuthor = author;
@ -153,7 +152,7 @@ levenshteinDistance(a, b) {
parseInt(this.getAttribute("live-type-interval")) || 3;
this.channelUid = this.getAttribute("channel");
app.rpc.getUsers(this.channelUid).then(users=>{
app.rpc.getRecentUsers(this.channelUid).then(users=>{
this.users = users
})
this.messageUid = null;

View File

@ -327,6 +327,19 @@ class RPCView(BaseView):
await self.ws.send_json(obj)
return "noresponse"
async def get_recent_users(self, channel_uid):
self._require_login()
return [
{
"uid": record["uid"],
"username": record["username"],
"nick": record["nick"],
"last_ping": record["last_ping"],
}
async for record in self.services.channel.get_recent_users(channel_uid)
]
async def get_users(self, channel_uid):
self._require_login()