100 Commits

Author SHA1 Message Date
Max Leiter
8ca7bca70b ircv3: draft/multiline (#5092)
Closes #5052

Multi-line input is currently sent as one PRIVMSG per line, so a paste
arrives as N unrelated messages. On networks that support
[draft/multiline](https://ircv3.net/specs/extensions/multiline) it can
be sent as a single BATCH and stays one message everywhere.

## Summary

Sending goes through `sayMultiline()` in `plugins/inputs/msg.ts` when
the network advertises limits we can respect (`multilineLimits()`); if
the batch is over max-bytes/max-lines the send falls back to individual
messages, and the local echo follows whichever path was actually taken
so the sender sees what everyone else got. `Client.input()` stops
splitting on newlines when the target network has the cap. Inbound
batches arrive from irc-framework already reassembled and are flagged
`multiline` on the `Msg`, which drives line-by-line rendering (`parse()`
joins lines with `<br>`), one entry per message in the text logs, and a
first-non-empty-line notification preview. `MULTILINE_*` standard
replies get readable text.

No pin bump: `master` already points at the irc-framework commit that
carries multiline (kiwiirc/irc-framework#414).

## Test Plan

- New unit tests for the send path (batch, fallback on max-bytes, no
limits advertised, blank lines), the text log format, `parse()`, and the
standard replies.
- Ran the server against a local IRCd advertising `draft/multiline` and
confirmed on the wire: a 3-line message goes out as one `BATCH …
draft/multiline` with three frames; with the cap advertised bare (no
limits) or with `max-bytes` too small it degrades to three plain
PRIVMSGs and the local echo degrades with it; a CRLF paste sends clean
frames and echoes without stray `\r`; an inbound batch from another user
renders as one message.
- Not verified: rendering was checked through unit tests rather than in
a browser.
2026-07-20 14:45:45 -07:00
Max Leiter
db5a183117 ircv3: +typing support (#5050)
https://ircv3.net/specs/client-tags/typing

https://libera.chat/news/new-and-upcoming-features-3#client-tags

Very open to style feedback: I took some tips from discord:
- bump padding on the bottom to the chat to fit it (20px, not very
noticeable)
- when scrolled up, a gradient is applied
- I dont love adding the padding but idk a better solution and IMO its
not noticeable



https://github.com/user-attachments/assets/a911994e-1564-45bf-8475-37742ad8b4f5


<img width="1288" height="330" alt="image"
src="https://github.com/user-attachments/assets/19441440-be8c-477c-8513-9c43b83c009b"
/>
<img width="1608" height="1086" alt="image"
src="https://github.com/user-attachments/assets/339dff30-6719-450d-9d4f-e01ec354de3f"
/>

Closes https://github.com/thelounge/thelounge/issues/2419
Supersedes/closes #4611

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-07-14 13:12:57 -07:00
Max Leiter
dc7f79fe92 sqlite: add message history index (#5107)
Fixes #5103

Today, `getMessages()` filters by `(network, channel)` but sorts by
`time DESC, id DESC` and no index covers both (and a new one supersedes
`network_channel`). This has always been an issue but
https://github.com/thelounge/thelounge/pull/5055 made this code
synchronous which exposed it.

|  | Before | After |
|--------|--------|--------|
| history load, 5 channels (4.4M rows total, busiest 3M) | 6.9s, event
loop blocked | 80ms |
| single channel with 3M messages | 4.6s | 18ms |
| query plan | index scan + temp B-tree sort | index only |
2026-06-14 22:02:13 -07:00
Max Leiter
0fe011235e remove webpack, babel, mocha; switch to vite/vitest (#5064)
```
Webpack vs Vite Build Comparison

  ┌────────────┬──────────────────────┬────────────────────┬───────────────┐
  │   Metric   │      Webpack 5       │ Vite 8 (Rolldown)  │    Change     │
  ├────────────┼──────────────────────┼────────────────────┼───────────────┤
  │ Build time │ 1,961ms (2.96s wall) │ 612ms (0.82s wall) │ 3.2x faster   │
  ├────────────┼──────────────────────┼────────────────────┼───────────────┤
  │ CPU time   │ 11.0s user           │ 1.3s user          │ 8.5x less CPU │
  └────────────┴──────────────────────┴────────────────────┴───────────────┘

  Bundle sizes (gzipped)

  ┌────────────────┬─────────┬────────┬────────┐
  │     Asset      │ Webpack │  Vite  │ Change │
  ├────────────────┼─────────┼────────┼────────┤
  │ App JS         │ 152.6K  │ 104.9K │ -31%   │
  ├────────────────┼─────────┼────────┼────────┤
  │ Vendor JS      │ 251.1K  │ 81.6K  │ -68%   │
  ├────────────────┼─────────┼────────┼────────┤
  │ Runtime JS     │ —       │ 0.5K   │ new    │
  ├────────────────┼─────────┼────────┼────────┤
  │ Total JS       │ 403.7K  │ 187.0K │ -54%   │
  ├────────────────┼─────────┼────────┼────────┤
  │ CSS            │ 12.5K   │ 11.9K  │ -5%    │
  ├────────────────┼─────────┼────────┼────────┤
  │ Total transfer │ 416.2K  │ 198.9K │ -52%   │
  └────────────────┴─────────┴────────┴────────┘

  Raw (uncompressed)

  ┌───────────────┬─────────┬──────┬────────┐
  │     Asset     │ Webpack │ Vite │ Change │
  ├───────────────┼─────────┼──────┼────────┤
  │ App JS        │ 1.3M    │ 304K │ -77%   │
  ├───────────────┼─────────┼──────┼────────┤
  │ Vendor JS     │ 1.1M    │ 236K │ -79%   │
  ├───────────────┼─────────┼──────┼────────┤
  │ CSS           │ 64K     │ 56K  │ -13%   │
  ├───────────────┼─────────┼──────┼────────┤
  │ Total public/ │ 5.1M    │ 3.4M │ -33%   │
  └───────────────┴─────────┴──────┴────────┘
```

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-06-01 09:02:09 -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
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
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
Reto Brunner
f97c4df2a2 ignore invalid warning in ldap test
it complains that the call `ldap.parseDN(dn).toString();` yields
"[object Object]" but that's bogus... the typing is incorrect.

ldap.DN stringifies properly
2024-11-07 17:48:30 +01:00
Reto Brunner
3259ac596d client: fix all new linter errros 2024-05-04 12:29:57 +02:00
Reto Brunner
1ec67a6605 test/sqlite: remove unused eslint directive 2024-04-21 15:11:52 +02:00
Reto Brunner
03151e0ab1 test/plugins/sqlite: fix import path 2024-04-21 15:11:52 +02:00
Reto Brunner
7f5e0f3ebf test/plugins/link: fix import path 2024-04-21 15:11:52 +02: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
ec75ff00cb sqlite: don't modify global array during tests 2023-11-06 07:52:59 +01:00
Reto Brunner
79fae26f39 test/storage: use helper for url creation
We keep repeating ourselves, let's move that into a helper instead.
In order to get a sane host, we fix the listener to 127.0.0.1
else we get the unspecified :: ipv6 addr (on suitable hosts),
which isn't useful.
2023-06-25 19:30:52 +02:00
Reto Brunner
c6b1913b91 test/link: use helper for url creation
We keep repeating ourselves, let's move that into a helper instead.
In order to get a sane host, we fix the listener to 127.0.0.1
else we get the unspecified :: ipv6 addr (on suitable hosts),
which isn't useful.
2023-06-25 19:08:23 +02:00
Reto Brunner
3be805bd38 sqlite: Add rollback support
This enables db migrations to be undone, or "down migrated".
The down migration shouldn't be done automatically
as it could lead to severe data loss if that were done.
Hence, we still hard fail if we encounter a version lower than what
we have in the DB.

A CLI will be added in a later commit that allows users to explicitly
do that.
2023-03-31 11:34:26 +02:00
Reto Brunner
899762cddd sqlite: Add infrastructure for migration tests
This sets up the testing infrastructure to test migrations we are
doing.
It's done on a in memory database directly, we are only interested
in the statements themselves and it's easier than to try and
inject a prepared db into the store.

We do add some dummy data though to make sure we actually execute
the things as we expect.
2023-02-27 14:20:29 +01:00
Reto Brunner
063aca948c sqlite: don't hardcode version test 2023-02-27 14:17:04 +01:00
Reto Brunner
25642fbe98 sqlite: delete table creation test
This just repeats the hard coded values from the code, which
is not helping.
We need to touch that test whenever we modify the sql which is
undesired and it doesn't test any useful functionality.

Any error that may ensue would hopefully be tracked by the other
test.
2023-02-27 14:11:47 +01:00
Reto Brunner
958a948456 sqlite: Remove client from sqlitestorage
The only reason we accepted a client was that so we have access
to the next message id when we need it.
So let's accept an id provider function instead.
2022-12-30 16:52:04 +01:00
Reto Brunner
2d4143b779 sqlite: synchronize enable() internally
TL is stupid and doesn't wait for message{Provider,Storage} to
settle before it starts using the store.

While this should be fixed globally, we can hack around the problem
by pushing everything onto the call stack and hope that we'll eventually
finish the setup before we blow the stack.
2022-11-30 10:28:26 +01:00
Reto Brunner
deeea274da Merge branch 'sqlite_cleanup'
Converts sqlite to async, providing a way forward
for migrations to actually happen
2022-11-24 09:45:01 +01:00
Reto Brunner
8095d9e88a SearchQuery: offset is always a number
Fix type confusion that specified offset to be a string, it is
always a number.
2022-11-15 18:50:52 +01:00
Reto Brunner
d62dd3e62d messageStorage: convert to async
Message stores are more complicated that a sync "fire and forget"
API allows for.
For starters, non trivial stores (say sqlite) can fail during init
and we want to be able to catch that.
Second, we really need to be able to run migrations and such, which
may block (and fail) the activation of the store.

On the plus side, this pushes error handling to the caller rather
than the stores, which is a good thing as that allows us to eventually
push this to the client in the UI, rather than just logging it in the
server on stdout
2022-11-02 00:01:36 +01:00
Max Leiter
dd05ee3a65 TypeScript and Vue 3 (#4559)
Co-authored-by: Eric Nemchik <eric@nemchik.com>
Co-authored-by: Pavel Djundik <xPaw@users.noreply.github.com>
2022-06-18 17:25:21 -07:00
Reto
d4cc2dd361 Refactor config out of Helper (#4558)
* Remove config from Helper

Helper is the usual util grab bag of useful stuff.
Somehow the config ended up there historically but
structurally that doesn't make any sense.

* Add cert folder to prettier ignore file
2022-05-01 12:12:39 -07:00
Val Lorentz
20ed3e6dc5 sqlite: Escape '%' and '_' in search queries. (#4487)
I picked '@' arbitrarily, it doesn't matter much.
I just don't like '\' because it needs to be escaped itself in the JS code,
which is annoying.
2022-04-11 17:49:13 -07:00
Reto
d228a8c4f4 Bump most deps (#4453) 2022-02-09 15:27:34 -08:00
itsjohncs
044cd2403b Small cleanup of messageStorage/sqlite.
* Extend test coverage to the `search` function.
* Test sort order of messages from `getMessages` and `search`
* Move reversal of `search` results from Vue to messageStorage.
* Remove unnecessary uses of `sqlite.serialize` in tests.
* Return promises from test functions where possible.
2021-10-28 00:48:11 -07:00
Jay2k1
b97b145df1 add highlight exceptions 2020-08-19 00:00:56 +02:00
Pavel Djundik
8c6460b58a Disable link prefetching for urls with no schema specified 2020-08-04 20:21:12 +03:00
Dexter Chua
2f434be75d Add option to disable media preview.
This disables image previews iff prefetchStorage is disabled. This
stops the client from making any requests to third-party sites.
2020-07-21 08:52:02 +08:00
Pavel Djundik
f8f692af05 Generate client certificates and automatically do SASL EXTERNAL 2020-04-15 10:56:04 +03:00
Pavel Djundik
6de6f8185e Clean up folders in after test runs 2020-03-22 20:43:06 +02:00
Pavel Djundik
881b3eda19 Run format after updating to prettier 2.0 2020-03-21 22:55:36 +02:00
Pavel Djundik
1b2894bf99 Fix increasing test timeout on github actions 2020-02-09 14:21:45 +02:00
Pavel Djundik
26bf0850d7 Stub checkForUpdates in tests 2020-01-19 01:14:52 +02:00
Pavel Djundik
d2932ccea8 Correctly track user toggle of previews 2019-12-23 12:26:57 +02:00
Pavel Djundik
769585e72d Collapse prefetch errors by default 2019-12-23 12:15:23 +02:00
Pavel Djundik
72a954b865 Add preview for text/plain urls 2019-12-19 15:12:02 +02:00
Pavel Djundik
8b7fb33627 Increase test timeout due to unpredictable I/O on CI services 2019-11-27 20:25:29 +02:00
Raqbit
95cc9a47fb Add file size to link preview 2019-11-07 16:58:28 +01:00
MiniDigger
6f8364b1dd Print package versions on startup 2019-11-06 18:02:28 +01:00
Pavel Djundik
fe4e0343a4 Load existing users on startup when LDAP is enabled
Fixes #3219
2019-10-31 11:01:44 +02:00
Pavel Djundik
390a0b8e83 Let OS generate a port in link prefetch tests 2019-10-04 14:19:04 +03:00
Pavel Djundik
cee3a50ddc Move back to ldapjs dependency
Fixes #3381
2019-09-15 22:42:27 +03:00
Alistair McKinlay
133e7bf710 Format js/vue with prettier 2019-07-19 11:27:40 +01:00
Pavel Djundik
54a4085b68 Store ip and language in a separate object in user file 2019-07-16 13:00:29 +03:00
Pavel Djundik
95a3ec42c2 Add a message about experimental API 2019-07-05 10:26:22 +03:00