Commit Graph

39 Commits

Author SHA1 Message Date
JC Brand
5029d93523 XML stanza parsing fixes
- Add a `Stanza` class which can be used by Strophe because it has a
  `tree()` function. This is what gets returned by the `stx` tagged
  template.

- Throw an error when no valid namespace is on the stanza.
    Strophe.Builder used to automatically add the `jabber:client` namespace,
    but that doesn't happen with `toStanza`, so we need to fail if it's not
    specified by the user.

- Use the Strophe XML Parser
    This opens the door to NodeJS support
2023-02-14 11:50:38 +01:00
JC Brand
f1cc8c85f4 Rename the stanza TTL to stx to avoid name clashes 2022-08-11 15:30:51 +02:00
JC Brand
d2bdce51e8 Add a tagged template literal function stanza
For creating XML stanzas from template literals.
2022-08-10 14:50:12 +02:00
JC Brand
e80afbfe39 Move MUC and stanza utils into shared and plugin-specific files 2020-12-14 16:30:13 +01:00
JC Brand
c855d2f4ce Updates #2350 Avoid bundling Strophe twice
by not importing Strophe outside of @converse/headless
2020-12-10 16:32:01 +01:00
JC Brand
824bf2ed30 Move all plugin files to ./plugin folders
Rename converse-core.js to core.js
2020-12-03 16:41:15 +01:00
JC Brand
f9650f33be Add support for XEP-0393 message styling
Fixes #1083

Directives are rendered as templates and their bodies are MessageText instances.
We thereby achieve the necessary nesting of directives (and other rich
elements inside directives) by letting each directive
body render itself similarly to how the whole message body is rendered.
2020-11-24 16:06:48 +01:00
JC Brand
19dc66900d Split the trusted setting into two new ones:
- `allow_user_trust_override`
- `clear_cache_on_logout`

The `persistent_store` setting can now also be set to `sessionStorage`

The `trusted` settings was in effect playing the role of two separate settings
and implicitly affecting a third ('persistent_store').

By breaking it up, we make things more explicit and allow for new
configurations. For example, clearing the cache on logout, while using
some kind of persistent store.
2020-10-20 11:29:03 +02:00
JC Brand
48f119b673 MAM: use bare JID as by attribute for archive-id
in 1:1 chats.

See: https://xmpp.org/extensions/xep-0313.html#archives_id
2020-10-13 04:48:21 +02:00
Christoph Scholz
f68eb65cd7 check against own jid when detecting forged mam messages 2020-10-06 20:30:40 +02:00
JC Brand
a0ae8135ce Fixes #1481
For OMEMO in MUC, use the real JID of the user, not the MUC JID
2020-09-17 17:12:06 +02:00
JC Brand
0a82a177c4 OMEMO: ensure reflected encrypted MUC messages are identified 2020-09-17 10:37:09 +02:00
JC Brand
8d3cd687e7 Pass chatbox or _converse as context 2020-09-11 16:44:28 +02:00
JC Brand
bbcfc9f998 Bugfix. 2nd parameter for api.hook is the context 2020-09-11 16:23:51 +02:00
JC Brand
7c43d0435c Refactor OMEMO.
- Add hooks to the stanza parsers so that plugins can do additional parsing.
- Change ChatBox instance methods to functions and use them for stanza parsing.
- Move encrypt and decrypt messages to `converse.env.omemo`

Apparently, when receving a 1:1 carbon message, a device was wrongly created
for the contact's device list, instead of our own.
2020-09-09 14:04:24 +02:00
JC Brand
09371712b0 Updates #1896: Properly identify archived one-on-one messages
Also, rename attribute from `is_receipt_request` to `is_valid_receipt_request` to avoid confusion.
2020-08-13 11:09:22 +02:00
JC Brand
4de9816f24 Make sure emojis are initialized before parsing a message
for emoji related data
2020-07-13 15:45:37 +02:00
JC Brand
b511f1d950 Updates #1896: Use right flag to checked if message is archived 2020-06-08 12:25:49 +02:00
JC Brand
7651d58470 Render chat messages as web components
- Render chat content as a <converse-chat-content> component
- Create new component for rendering the message body
- Get rid of `showMessage` method
2020-06-01 09:53:19 +02:00
JC Brand
ca7adeedbd Save hat URI, not id 2020-05-20 13:44:29 +02:00
JC Brand
555c0966cc muc: save error response to a sent message onto the original model 2020-05-07 13:32:56 +02:00
JC Brand
b5eea12d49 Refactor so that message attributes are parsed early
It's better to parse an incoming message stanza early, than to have
all kinds of methods throughout the codebase that does querySelector
etc.

Firstly, it allows us to catch and report errors and malicious stanzas early on.
It also simplifies programming because you don't need to try and
remember how to properly parse a stanza, all the work is done upfront
for you.
2020-04-27 16:34:37 +02:00
JC Brand
f68f577b71 muc-views: Update ListChatRoomsModal to make better use of lit-html 2020-04-15 11:54:07 +02:00
JC Brand
5cb65d84f1 Bugfix. Don't assume OMEMO store is always there 2020-04-14 14:04:26 +02:00
JC Brand
df9612f937 Add support for XEP-0317 MUC Hats 2020-04-13 22:57:29 +02:00
JC Brand
e2a7045e22 Move MUC presence parsing code to src/headless/utils/stanza.js 2020-04-13 18:22:15 +02:00
JC Brand
a1d5563963 Move OMEMO-related message parsing to utils/stanza.js 2020-04-13 17:44:47 +02:00
JC Brand
ce1f7e090e Rename getMessageAttributesFromStanza to parseMessage 2020-04-13 17:44:47 +02:00
JC Brand
967154d314 Use optional chaining instead of lodash.get 2020-03-24 12:30:45 +01:00
JC Brand
ce08819a43 Retracted moderated sent message should not be editable. 2020-02-18 16:47:52 +01:00
JC Brand
746fe441e2 Updates the message parsing.
Only set `id` once we've actually parsed the sender attributes,
otherwise `attrs.from` is `undefined`.

Use `Array.prototype.reduce` to generate stanza_ids attributes map.

Add `from_muc` attribute which contains the MUC JID
2020-02-07 12:12:38 +01:00
JC Brand
161cbec0d8 For forbidden errors, show error message from server 2020-01-17 14:44:05 +01:00
JC Brand
d8e561ef7e Fix linting errors 2019-12-20 16:02:53 +01:00
JC Brand
9b4276721c Remove unnecessary await statement 2019-12-19 13:12:12 +01:00
JC Brand
e23c7ce543 More retraction updates
- Retracted moderated message are not editable
- Use "removed" for user-facing text
2019-11-26 22:04:38 +01:00
JC Brand
13ffe5a667 Various smaller retraction related fixes and improvements 2019-11-26 12:16:48 +01:00
JC Brand
1b9ba58aca Rename variable to be more accurate 2019-11-22 13:50:36 +01:00
JC Brand
b4dafcc45b Add support for XEP-0424 and XEP-0425
- Add support for switching ephemerality after message creation
- Move more methods from ChatBox and ChatRoom to utils/stanza.js
- Rename 'ephemeral' to 'is_ephemeral' since it's a boolean
2019-11-22 13:50:36 +01:00
JC Brand
8523cae8d0 Move message parsing code out of ChatBox into new stanza-utils plugin 2019-11-22 13:50:36 +01:00