Chat
Kantoor has a simple chat with rooms. It is off unless KANTOOR_CHAT=true is set;
when it is on, Chat appears in the navigation.
Who is in it
The chat of an organisation is the chat of a mail domain: everyone with a mailbox in the domain belongs to it. Someone with mailboxes in two domains sees both, kept apart (the room list has a heading per domain). An administrator belongs to a domain's chat only through a mailbox in it, like everyone else. Nobody from another domain can read, list, search, join or post in a room, or fetch anything from it, even with a guessed address — unless an administrator of a private room has brought them in with a single-use invite link (see Sharing a room with another organization).
Rooms and messages
- Everybody in the domain may make a room (a name of 1 to 40 characters and an optional topic). A public room (its name is unique in the domain whatever the case) is read and written by everyone in the domain.
- A private room (choose "Only the people I add") is seen only by its members: it is not in anyone else's room list, not in search and not in mentions, and its address leads nowhere for them. You are its first member; a member of the room's own organization can add people from that organization (Members, then "Add someone from the organization"), never people of another organization by directory: those come in by invite link. A private room's messages are sent only to its members' open pages. Leave ends your access; your messages stay under your name. The last administrator of a shared room cannot leave until they have made another member an administrator.
- Mentions: write
@and a person's handle, the part of their e-mail address before the@(@ann), or use the @ button next to the composer. Only people who can read the room can be mentioned; the name is marked in the message, and the person sees a red @ badge on the room until they have read it. An e-mail address is not a mention. - Edit and delete your own messages: Edit and Delete appear under your own messages. An edited message says "edited"; a deleted one stays in the room as "Message deleted" and its text is gone. Nobody can change anybody else's message.
- A message is plain text with line breaks (Enter sends, Shift+Enter starts a new
line), at most 4,000 characters. Nothing in it is ever shown as HTML; web addresses
starting with
http://orhttps://become links that open in a new tab. - A message shows its author's current name, taken from their profile at the time the page is drawn: a name changed in the identity provider updates on the next sign-in and is then shown on every message of that person, old and new. The name the message was posted with is kept in the record only; the page shows the person's name, or the e-mail address when they have none.
- You can post 20 messages in 10 seconds and make 10 rooms an hour.
- Unread: a room with messages from others that you have not seen has a badge in the room list; opening the room clears it. The count is kept in the database, so it is right after a reload or on another device.
- History loads 50 messages at a time (Load earlier messages).
- Messages arrive at once in every open page, also when Kantoor runs on several nodes (see Running several replicas); a page that missed one catches up within five seconds.
Layout
On a wide screen: Kantoor's navigation, a room list and the conversation. The list is grouped by organization: each organization has its own heading with its full name (the name wraps rather than being cut short, with a tile of its initials beside it), and the organization of the open room is marked as active. Each room shows a tile with the first letters of its name, the name itself, a badge for unread messages, and the full name as a tooltip. On a phone the room list comes first; a room opens on its own with a Back to rooms button, the same pattern as the mail view. Names are visible on both widths, light and dark.
Search
The Search tile at the top of the room list opens the search page. It finds whole
words (no stemming; quotes, - and or work) in the messages of
the rooms you can read: the public rooms of your domains and the private rooms you
are in, never anybody else's. Deleted messages are not found; an edited message is found
by its new text. Best matches first, at most 50, with the words marked; 30 searches a
minute. A result opens its room at that message, with a banner "Showing an older part of
the room" and Jump to the latest to go back.
Archiving and deleting rooms
- Archive (the room's creator, or an administrator; the button in the room's header): the room leaves the room strip, nothing more can be posted or edited in it, and a banner says so. It stays readable, files included, for the people who could read it. It is listed under Archived rooms (the archive icon under the strip), where its creator or an administrator can Restore it. Archiving and restoring go to the audit log. In an archived room people may still delete their own messages (and so their files): archiving stops new content, it does not take away the way to remove what one wrote. A post that was already under way when the room was archived (or deleted) is refused, and the files it had stored are removed again.
- Delete (administrators only; "Delete room..." in the header): removes the room for good,
with its messages, their edit history, the file rows and the stored bytes. The room's
name must be typed to confirm. It is audited (name, kind, how many messages and files). The
rows and the audit row go in one transaction, the stored bytes right after it. If the store
fails then, possibly halfway, the room is gone all the same: the failure is logged and a second
audit row
chat.room.files_orphaned(room id, domain id) tells an operator to runKantoor.Release.delete_chat_files("<domain id>", "<room id>"); a leftover byte can be cleaned that way. An administrator may archive or delete a room of any domain, also a private one, without being able to read it. For a domain where the operator has no mailbox,bin/kantoor eval 'Kantoor.Release.delete_chat_room("<room id>", "<room name>")'does the same as the system. - Deleting a whole domain that no operator owns is an operator command:
bin/kantoor eval 'Kantoor.Release.delete_domain("<domain name>")'(Kantoor.Deprovision). It needs the domain's name as the confirmation, deletes every chat room with its stored bytes, then the mailboxes with their mail, then the domain, and recordsdomain.deletein the audit log with the counts. A domain an operator owns is refused: its owner deprovisions it through the provisioning API. A person whose account belongs to the domain blocks the command until they are disabled or moved in the admin pages. A leftover account that no operator owns goes withbin/kantoor eval 'Kantoor.Release.delete_user("<address>")': its app passwords, grants and identities go with it and its chat messages stay as a former member's; an account an operator owns, and an administrator, are refused.
Sharing a room with another organization
A private room can hold members from more than one organization (mail domain) on the same Kantoor. Its own organization is the host; everyone else is a guest. The room list marks such a room with a people icon, its header says how many organizations are in it, and the members panel shows each member's organization next to their name.
Invite links
- An administrator of the room makes the link: the room menu, then Invite from another organization.... A link lasts 1, 7 (the default) or 30 days.
- Only a hash of the token is stored. The link is shown once, when it is made, with a Copy button; the open links are listed under it and can be revoked. Using a link, revoking one, and every change of a member's role go to the audit log.
- Opening the link: someone who is not signed in is asked to sign in (the usual Kantoor/OIDC sign-in, which returns to the link). Then they choose which of their organizations joins — a person with one organization skips that step — and see the room's name, who invited them and the host organization, with a Join button.
- A link works once. The use is settled in the database under a lock, so when two people open the same link at the same moment, exactly one joins and the other is told the link has already been used. A used, revoked or expired link, or one whose room was archived, shows a friendly page and joins nobody. A member who opens the link again joins without consuming it.
- A person needs at least one organization on this Kantoor to join. The chat of an organization is the chat of a mail domain, so a Kantoor account without a mailbox in any domain has nothing to join as.
What a guest sees
A guest sees that room only. It is in their room list under the host organization's name, and it opens, searches, mentions and takes files like any room they are a member of. It is not a door into the host organization:
- the organization's other rooms are not listed and their addresses answer "not found", also with a guessed id;
- the organization's people are not listed: the members panel shows the room's members, not a directory, and there is no "Add someone" list for a guest;
- search looks in the rooms they may read (that shared room and their own organizations' rooms), never in the rest of the host organization;
- mentions can name only the people who are in the room;
- files in the room are readable by its members only (the same checks as everywhere:
never executables or web pages, and the virus scan when
KANTOOR_CHAT_CLAMAVis set).
Who administers a room
- The person who created the room is its first administrator. An administrator may make another member an administrator (Members, then Make administrator), make an administrator a member again, and remove a member.
- The last administrator cannot demote themself or leave until they have named another administrator. Two administrators changing roles at the same moment cannot both step down either: the member rows are locked while the change is decided.
- End sharing (the room menu) removes every member from outside the host organization in one go; the room and its own organization's members stay. Close a room by archiving it; its creator, an administrator of the room or a Kantoor administrator can do that, and it can be restored as before.
- Kantoor's own administrators act as the host organization's administrators for this: Admin → Chat rooms lists every room with a member from another organization (its organizations and how many guests it has) and can end sharing for it, without having a mailbox in that organization. They can also archive or delete any room as before.
- The rooms of one organization are listed under that organization's name. A room is marked "shared with N organizations" once it has members from N organizations.
Retention, deletion and what is kept
The room belongs to its host organization, and that organization's retention and
deletion rules apply to everyone in it: the daily retention job removes deleted messages
for good after KANTOOR_CHAT_DELETED_DAYS, and deleting the host domain deletes its
rooms, messages and files for guests too. Files follow the same storage, size, quota,
content and virus-scan rules as in any room, counted against the host organization's
quota. Removing a guest (or ending sharing) removes their access; the messages they wrote
stay under their name. The audit log keeps chat.invite.create, chat.invite.use,
chat.invite.revoke, chat.member.role, chat.member.remove and chat.room.unshare
beside the existing room events.
Where things are
Sign-out is in the account menu at the top right of every page (the person icon, then "Sign out"), not in the chat. On a phone the rooms and the conversation are two screens: "Back to rooms" leads from a room to the list, and a search icon in the room's header opens the search. The start page has a Chat card that leads to the chat and shows the number of unread messages.
Files
The paper clip next to the composer attaches up to 5 files to a message (a message
may be only files). Each file is at most 25 MB (KANTOOR_CHAT_MAX_FILE_MB), and a mail
domain may keep 5 GB in all (KANTOOR_CHAT_DOMAIN_QUOTA_GB); deleting messages frees
the space. 30 files per 10 minutes per person.
What Kantoor takes is checked on the content, not the name or the type the browser
says: the first bytes must be what the extension claims (a .png must be a PNG), and
nothing is taken that can run or render as a page: programs and scripts (.exe, .sh,
.js, ELF, Mach-O, #! scripts) and web pages (.html, .svg, .xml, <html> and the
like), by name or by content. A refused file is named in the notice and nothing is posted.
Only people who can read the room get a file (the same rules as for messages: another
domain, or a private room you are not in, answers 404, also for a guessed address — a
guest of a shared room is a member of that room and does get its files).
Every file is sent as a download (application/octet-stream, Content-Disposition: attachment, nosniff, a sandbox policy), so nothing a person uploads ever runs from
Kantoor's address. The one exception is a PNG, JPEG, GIF or WebP picture, shown inline
on its own path with its first bytes checked again when it is sent; SVG is never inline.
Deleting a message deletes its files at once (the stored bytes); the database row (name, size, who, when) stays with the message for audit until the retention job removes the message. Deleting a whole domain removes its rows; bytes already stored under that domain stay in the store until it is cleaned (see "Known limits" below).
Settings (see the installing guide for the list): KANTOOR_CHAT_STORAGE=local keeps the
bytes in a directory, s3 in an S3-compatible store.
Local storage needs a persistent volume. With the default
localadapter the files live inKANTOOR_CHAT_FILES_PATH(defaultchat_filesin the container's working directory). Without a mounted volume they are lost at every redeploy, while the database still lists them. Mount a volume there, or uses3. With more than one Kantoor node the directory must be shared by all of them;s3is the choice then.
Uploads and downloads do not hold a whole file in memory: a download is send_file (local)
or a chunked stream from the store (S3), an upload to S3 is streamed from disk. The copy,
the virus scan and the storing of a post with files run in their own task, not in the
person's page: the Send button shows "Sending..." and is off until the answer comes. The
cheap checks (size, kind against name) happen before anything is taken, so when one file is
refused the others stay chosen; a failure of the scan or the store afterwards means the files
must be chosen again.
Known limits
- Bytes left by a failed deletion stay until an operator sweeps them. Deleting a room
deletes its bytes; deleting a domain through
Kantoor.Release.delete_domain/1(Kantoor.Deprovision) does too. A store failure can still leave bytes underchat/<domain id>/(orchat/<domain id>/<room id>/) that the deletion could not remove; the audit rows say so. The sweep exists (Kantoor.Chat.Files.delete_domain_files/1,delete_room_files/2: delete by key prefix, both adapters) and an operator runs it:bin/kantoor eval 'Kantoor.Release.delete_chat_files("<domain id>")'(add, "<room id>"for one room). The ids must be UUIDs (anything else, a.included, is refused and deletes nothing). Run it only for a domain or room that is gone, it deletes every file under the prefix. - Files in archived rooms stay downloadable by the members of the room. That is intended: an archived room is hidden from the list but its history, and so its files, stay readable under the same rules as before. Delete the messages to remove the files.
- A file that fails the virus scan or the store after the cheap checks has to be chosen again.
Storing files in Garage (steps for the operator)
Kantoor does not create buckets. With Garage, for example:
garage bucket create kantoor-chatgarage key create kantoor-chat(prints the access key id and the secret; keep the secret out of git)garage bucket allow --read --write kantoor-chat --key kantoor-chat- optional:
garage bucket set-quotas kantoor-chat --max-size 100GiB - On the Kantoor application set
KANTOOR_CHAT_STORAGE=s3,KANTOOR_CHAT_S3_ENDPOINT(the S3 API of Garage as the Kantoor container reaches it, path-style, for examplehttp://<garage host>:3900),KANTOOR_CHAT_S3_BUCKET=kantoor-chat,KANTOOR_CHAT_S3_ACCESS_KEY_ID,KANTOOR_CHAT_S3_SECRET_ACCESS_KEYand, when Garage'ss3_regionis notgarage,KANTOOR_CHAT_S3_REGION. A missing setting stops the release at start with the names that are missing. - Redeploy. Post a file in a room, then look for
chat/<domain id>/<room id>/<file id>in the bucket; delete the message and the object goes.
The key needs no other bucket. Objects are keyed by id only; the file's name is in the database.
Virus scan
Off unless KANTOOR_CHAT_CLAMAV=host:port is set. Once set, every upload is sent to that
ClamAV daemon (clamd, INSTREAM) before it is stored; a found virus refuses the file, and
so does a file that could not be scanned (daemon unreachable, an error reply). That is
the default; KANTOOR_CHAT_CLAMAV_REQUIRED=false takes such files unscanned instead.
clamd's StreamMaxLength must be above Kantoor's file limit (KANTOOR_CHAT_MAX_FILE_MB,
25 MB by default; clamd's own default is also 25 MB): a file clamd refuses for its size
(INSTREAM size limit exceeded) counts as "could not be scanned", so it is refused too.
Set StreamMaxLength 30M (or more) in clamd.conf.
Without KANTOOR_CHAT_CLAMAV, uploaded files are not scanned for viruses at all. The
checks on name and content (no programs, scripts or pages) still apply, but that is not a
virus scan. Kantoor needs a clamd that its own container can reach over the network
(for example a clamav container beside it); there is no scanner built in.
What is kept for audit
The chat's data stays in Kantoor. An edit keeps the text it replaced (who and when). A
deleted message disappears from the room's view, but the database row keeps its text,
who deleted it and when, for 30 days (KANTOOR_CHAT_DELETED_DAYS); then a daily job
removes the message and its edit history for good. Creating a room and adding or
losing a private room's members are recorded in the admin Audit log.
When people go
A message keeps its author's name; if the user is removed it shows "(former member)". A person who loses their last mailbox in a domain loses that domain's chat. Deleting a domain deletes its rooms and messages.
Not in this version
Threads, reactions, calls, bots, multi-use share links (one link for many people), typing indicators, push notifications and e-mail digests are not planned for the first version. Guests from another organization come in only by a single-use link made by the room's administrator.