90 Commits

Author SHA1 Message Date
Jay2k1
0b2fc8d890 fix order of messages with identical timestamps (#5087)
When sending a message that is too long, thelounge will split it up into
multiple PRIVMSGs. These will be saved to the sqlite database with
identical timestamps. Thelounge retrieves messages from the DB using
`ORDER BY time DESC`, which under certain circumstances causes these
messages to be loaded and displayed in the wrong order. This PR
addresses that by also ordering by id (only affects messages with
identical timestamps).

Before:
<img width="1050" height="107" alt="image"
src="https://github.com/user-attachments/assets/54fac085-a989-48fa-9538-1faecb09aa44"
/>

After:
<img width="1058" height="114" alt="image"
src="https://github.com/user-attachments/assets/0bb99db9-5a5d-481d-b799-87162d0535e8"
/>
2026-04-18 16:35:10 -07:00
Max Leiter
4bb6420e04 fix: escape user-supplied LDAP filter value as per RFC 4515 (#5084)
Pointed out by claude and @xPaw 

https://datatracker.ietf.org/doc/html/rfc4515#section-3

Tests written by Claude
2026-04-18 16:13:23 -07:00
Reto
51b620c589 sqlite: don't interpolate the deletion query (#5086)
While it was safe and not attacker controlled, it's better to be safe
than sorry. Plus it trips the scanners up
2026-04-18 16:12:24 -07:00
Max Leiter
5b83f0ab4e chore: replace uuid package with crypto.randomUUID (#5081)
Available since Node 15:
https://nodejs.org/docs/latest-v20.x/api/crypto.html
2026-04-18 09:23:19 -07:00
Max Leiter
21f0e70696 fix /mute not persisting, case-insensitive channel check (#5083)
Found by claude:

```
server/plugins/inputs/mute.ts — /mute slash command never persists. Missing client.save(). Mutes set via the command vanish on restart. The socket handler (server/server.ts:768-797) does save.

server/plugins/inputs/mute.ts:18 — /mute #Foo fails when channel was joined as #foo. Uses case-sensitive c.name === arg; IRC channel names are case-insensitive.
```
2026-04-18 09:23:07 -07:00
Max Leiter
d33e1d4184 Remove sqlite3 dependency; use built-in node:sqlite (#5055)
https://www.npmjs.com/package/sqlite3 is deprecated and Node 22 (#5041)
lets us use the builtin `node:sqlite` package (although it is
experimental)

most changes are a result of the native module being synchronous

relies on #5041 (now merged)

Closes https://github.com/thelounge/thelounge/issues/5033
2026-04-12 13:30:56 +00:00
Max Leiter
769c9614b3 chore: bump some dev deps (mainly webpack) (#5042)
Closes some renovate PRs like
https://github.com/thelounge/thelounge/pull/5024 and should improve dev
perf.

It might be better to merge this instead:
https://github.com/thelounge/thelounge/pull/5001

---------

Co-authored-by: Tiago de Paula <tiagodepalves@gmail.com>
2026-04-11 14:28:18 -07:00
Max Leiter
eb75c4b77c chore: refactor Mentions, add isIgnoredUser util (#5051)
- Mentions were doing a bunch of mutations; not just uses derived state
- no need for a separate `ClientMention` 
- added `extractInputHistory` for shared logic
- tests made by claude
2026-04-11 07:59:14 -07:00
Reto Brunner
5d35ffc35d Merge branch 'fix/4993-ds-store-storage' 2026-04-11 10:11:24 +02:00
Max Leiter
a5070fa4a6 actions and package.json: remove Node 18 (EOL), bump sqlite3 (#5041)
Node 18 is EOL (https://nodejs.org/en/about/previous-releases). We can
use 22+ instead.
2026-04-10 15:10:19 -07:00
Max Leiter
c88f647f1a fix: use fs.rmSync in storage cleanup, fixing .DS_Store crash (fixes #4993)
Replace the manual deleteFolder() recursive implementation with
fs.rmSync({recursive: true, force: true}), which handles both files
and directories. This also resolves the ENOTDIR error caused by
.DS_Store and other non-directory entries in the storage folder.
2026-04-10 15:04:55 -07:00
Max Leiter
a309313d0f ircv3: parse msgid from tags manually 2026-04-09 23:15:21 -07:00
Max Leiter
9f9b98bf0e ircv3: start storing/tracking msgid 2026-04-09 21:48:18 -07:00
Max Leiter
44b6f87f16 Unset topic (#5028) 2026-04-09 22:33:30 -05:00
Reto Brunner
75490f5b5b sqlite: change to single quotes
Apparently sqlite started validating this in certain versions.
Crashes on BSDs with:

SQLite version 3.50.4 2025-07-30 19:33:53
sqlite> SELECT msg, type, time, network, channel FROM messages WHERE type = "message";
Parse error: no such column: "message" - should this be a string literal in single-quotes?
  time, network, channel FROM messages WHERE type = "message";
                                      error here ---^
2026-02-10 20:28:04 +01:00
Reto Brunner
91fb1ee343 add cleartopic command
Fixes: https://github.com/thelounge/thelounge/issues/4687
2026-02-09 08:16:27 +01:00
Reto Brunner
3d8e96491b topic: display topic when no arguments are given
That's what the help says that we do, so do it.

Fixes: https://github.com/thelounge/thelounge/issues/5026
2026-02-09 08:08:15 +01:00
Taavi Väänänen
be603c6bdc server: Fix quoting in error message
In the error message about an invalid plugin command, only quote the
command name and not the rest of the error message after the command
name.
2025-11-08 12:36:50 +02:00
arminius-smh
ac485c483b server: fix loading themes from scoped packages
Scoped packages have slashes in them, that led to them being loaded at
the wrong path. Encoding the name fixes this.
2024-09-04 12:25:48 +02:00
Reto Brunner
0d9c184f19 server: fix time handling
The framework may emit messages which do not have a time stamp.
We tried to unconditionally convert the time field, fix that.

The Msg constructor replaces falsey time fields with the current
date so we can also remove the duplication from that codepath.
2024-05-16 22:15:39 +02:00
Reto Brunner
3259ac596d client: fix all new linter errros 2024-05-04 12:29:57 +02:00
Reto Brunner
8c41356ae9 publicClient: type fix 2024-04-21 15:11:52 +02:00
Reto Brunner
e2b56cf16b irc-events/message: fix types 2024-04-21 15:11:52 +02:00
Reto Brunner
92a0affba1 kick: use the user object 2024-04-21 15:11:52 +02:00
Reto Brunner
edb96f683b cap: type the boolean 2024-04-21 15:11:52 +02:00
Reto Brunner
5c8951ffc3 fix extractTargetGroup typing 2024-04-21 15:11:52 +02:00
Reto Brunner
c3fc54e158 ignorelist: shut up the linter 2024-04-21 15:11:52 +02:00
Reto Brunner
917fdb2a0a ignore: remove dead import 2024-04-21 15:11:52 +02:00
Reto Brunner
b8400a3a46 ignore: clean up the types and conditionals
Now that ignorelist doesn't muddy the waters, we can clean up
all the funny conditional types and enforce `when`
2024-04-21 15:11:52 +02:00
Reto Brunner
071a5afda6 ignore: move ignorelist to its own command
ignorelist shares no logic with /ignore or /unignore so it shouldn't
share a file. That just makes typing awkward.
2024-04-21 15:11:52 +02:00
Reto Brunner
5274fdc21a ignore: keep happy path on the left
It is much easier to follow the control flow if error checks
are done on the indented path, immediately returning.
2024-04-21 15:11:52 +02:00
Reto Brunner
b8a9fe08ab clientCertificate: remove unsafe casts 2024-04-21 15:11:52 +02:00
Reto Brunner
a4afa08add ldap: type SearchOptions scope 2024-04-21 15:11:52 +02:00
Reto Brunner
c20cd6bda1 publicClient: add FIXME and ignore the type mismatch
The publicClient interface is utterly horrific.
It allows any client to inject arbitrary events into the socket.io
event stream.
This should get wrapped into a "plugin" event so that it can get properly
typed, better yet, this should get removed completely.
2024-04-21 15:11:51 +02:00
Reto Brunner
e15b121080 remove obsolete error override 2024-04-21 15:11:51 +02:00
Reto Brunner
e57e547b74 further chan fixes 2024-04-21 15:11:51 +02:00
Reto Brunner
3217536245 searchresponse 2024-04-21 15:11:51 +02:00
Reto Brunner
7bc184b252 changelog data type 2024-04-21 15:11:51 +02:00
Reto Brunner
4d237600d5 changelog: don't type assert to a broken type
The mandatory fields are unset, stop lying to the compiler
2024-04-21 15:11:51 +02:00
Reto Brunner
3f0ee6a961 move chan enums 2024-04-21 15:10:45 +02:00
Reto Brunner
68ba13ca12 wip: searchquery 2024-04-21 15:10:45 +02:00
Reto Brunner
3eb19135f5 wip: msg 2024-04-21 15:10:41 +02:00
Zach Bloomquist
45563d9a59 server: remove version from CTCP response 2024-02-01 00:09:45 -05:00
Reto Brunner
edb1226b47 sqlite: add msg type index to speed up cleaner 2023-12-24 16:55:45 +01:00
Reto Brunner
14d9ff247d sqlite: implement deleteMessages
This is laying the foundation to build a cleaning task that's
sort of database agnostic.
All calls are done by acting on a "DeletionRequest" so interpretation
of the config will go through a single point
2023-12-23 21:08:07 +01:00
Reto Brunner
aec8d0b033 sqlite: accept db connection string
This allows us to inject a memory db during testing
2023-12-23 21:08:07 +01:00
Reto Brunner
60ddf17124 sqlite: use variadic function for serialize_run
This makes the usage of the function a bit nicer
2023-12-23 21:08:07 +01:00
Reto Brunner
d1561f8ebc sqlite: return new version in downgrade()
We want to give the caller the current version, not the last
version we rolled back, fix that
2023-11-06 07:52:59 +01:00
Reto Brunner
884a92c74b sqlite: fix typo fetch_rollbacks 2023-11-06 07:52:59 +01:00
Reto Brunner
3af4ad1076 Respect bind setting for all outgoing requests
So far the bind config only impacted the IRC connections.
However, nothing in our doc comment says that this is intentional.

> ### bind
> Set the local IP to bind to for outgoing connections.

This commit fixes the leak and uses it for all outgoing requests
as described by the docstring.
2023-06-25 19:30:52 +02:00