Commit Graph

114 Commits

Author SHA1 Message Date
JC Brand
d95a7987ce Fix linting errors and add @module jsdoc directives 2019-07-11 10:48:52 +02:00
JC Brand
ded9945ed9 MUC: Don't send XEP-0085 CSNs when we don't have voice
Includes some refactoring:

- Don't send an `active` chat state notification when entering a MUC
  I can't think of a good reason why this might be necessary or desired.
- Move `setChatState` form the view to the model
- Remove unused method `handleChatStateNotification`
- Don't store `role` and `affiliation` for the current user on the
  ChatRoom object, but instead on the ChatRoomOccupant object representing
  the user.
2019-07-10 14:24:00 +02:00
JC Brand
168f29cf06 Only call credentials_url when authentication is set to login
Also update to newer strophe.js version which contains a bugfix.
2019-07-09 12:47:09 +02:00
JC Brand
ec68dc1cf0 Always set JID on the connection
So that the resource is passed along when we manually bind.

Related to bd81b89724
2019-06-27 15:19:48 +02:00
JC Brand
119966d902 Set flag to indicate user session is active
We then use this flag to determine whether we should use the values from
sessionStorage.

This appears to fix the problem I originally tried to fix in 607d798665.

When "cloning" a tab (e.g. via middle-click), the `active` flag will be
set and we'll create a new empty user session, otherwise it'll be false
and we can re-use the user session.
2019-06-27 15:13:04 +02:00
JC Brand
8d9d0a1ef4 Revert "Store session per full JID"
This reverts commit 607d798665.

Unfortunately this doesn't solve the issue because we have a
chicken-and-egg problem due to not knowing the resource beforehand.

So what happens after this change is that we never resume XEP-0198
sessions but instead always start a new one.
2019-06-27 15:11:14 +02:00
JC Brand
bd81b89724 Ensure current resource is bound when manually calling connection.bind 2019-06-26 13:48:10 +02:00
JC Brand
607d798665 Store session per full JID
Otherwise we run into a bug where two tabs with Converse.js share the
same XEP-0198 SM-ID, causing both to go into a reconnection-loop as
the XMPP server switches XEP-0198 sessions between them.

This bug is due to a distinction in how sessionStorage behaves when you
open the existing site in a new tab (e.g. middle-click or
`target="_blank"), as opposed to creating a new tab
and then opening the site in that tab.

In the latter case, the newly created sessionStorage object is empty.
In the former, the contents of sessionStorage of the current page is
copied over to the new page!
2019-06-25 21:40:28 +02:00
JC Brand
83201e7c02 Reconnection fixes.
When reconnecting with a new transport, we call setUserJID
so that a new resource is generated, to avoid multiple
server-side sessions with the same resource.

We also call `_proto._doDisconnect` so that connection event handlers
for the old transport are removed.
2019-06-14 12:00:49 +02:00
JC Brand
9635f53dad converse-smacks: 2 bugfixes.
- Don't ever resume SMACKS stream when using BOSH
- Clear SMACKS session data when using BOSH
2019-06-14 12:00:49 +02:00
JC Brand
f3c4dbc344 Avoid unnecessarily sending out a presence stanza
- Set roster_fetched flag when we get an empty IQ[type="result"] stanza
- Set `restored` flag when resuming in converse-smacks
- Don't trigger change event when fetching xmppstatus values
- Removed two events, since we can just listen to `change` on `_converse.xmppstatus`.
2019-06-13 13:33:01 +02:00
JC Brand
9d3dfa831a Fixes #1599 2019-06-12 06:40:53 +02:00
JC Brand
690052e1c2 Call setUserJID when we get JID from credentials_url 2019-06-06 13:41:52 +02:00
JC Brand
a656750459 Only fetch presences when we're resuming an existing session.
updates #555
2019-06-05 11:47:23 +02:00
JC Brand
a7184fab41 Bugfix. Need to wait for setUserJID 2019-06-05 11:38:14 +02:00
JC Brand
38a232fd45 Move BOSH code into a plugin
- Remove the `keepalive` configuration setting. It is now always implicitly `true`.
- Remove the `expose_rid_and_sid` configuration setting.
- A `prebind_url` is now mandatory when setting `authentication` to `prebind`.
- It's no longer possible to pass in `rid` and `sid` values to `converse.initialize.
2019-06-05 11:35:48 +02:00
JC Brand
01fce55733 Add prettierx and tentatively use it for some formatting
I'm using prettierx, which is a fork of prettier so that we can have
spaces before the brackets in a function declaration.

I don't like how restrictive prettier is concerning its configuration
and formatting.

- it messes up some indentation in specs/
- it removes a second newline when I specifically want to have two
- it doesn't allow spaces before brackets in function declarations (hence prettierx)
- it adds spaces for function parameters with default values

None of this is configurable.

So auto-formatting is not turned on by default, but it might be a useful
tool in some cases.

Fixes an issue where indentation was off in converse-core.js, causing
vim-sleuth to wrongly indent by three spaces only.
2019-06-05 10:25:31 +02:00
JC Brand
51f2ab9100 Fixes #1196. Use alternative connection method upon connfail 2019-06-04 15:11:32 +02:00
JC Brand
297f3d9efb The list of core plugins doesn't have to be an attribute of _converse 2019-06-04 14:27:25 +02:00
JC Brand
f2ac9ef4d7 converse-muc: Support for XEP-0410 to check whether we're joined 2019-06-03 11:41:34 +02:00
JC Brand
68d4a71c75 Fix _converse.api.user.login to handle auto_login case
Also, set the resource in `setUserJID`
2019-06-03 11:40:26 +02:00
JC Brand
699fe0df63 Initial support for the CredentialsContainer web API 2019-06-03 09:43:24 +02:00
JC Brand
737e27c726 Use shakespearean character names in tests 2019-06-03 09:43:24 +02:00
JC Brand
f30d415f76 Refactor reconnection 2019-06-03 09:43:24 +02:00
JC Brand
55cffab594 Destroy session objects in clearSession, not in tearDown 2019-06-03 09:43:24 +02:00
JC Brand
dc58e6d47f Make teardown a function 2019-06-03 09:43:24 +02:00
JC Brand
7b11d85503 Add support for XEP-0198 Stream Management
- New plugin `converse-smacks`
- New config option `enable_smacks`
- Rename session cache id from `converse.bosh-session` to `converse.session`
- Refactor logout and login as consistently used api methods
- Refactor session cache to store per JID

Fixes #316
2019-06-03 09:43:12 +02:00
JC Brand
7c7002ebf9 Add _converse.default_connection_options
So that we can specify defaults
2019-06-03 09:41:29 +02:00
JC Brand
24956d8dca Execute manual resource binding if necessary 2019-06-03 09:41:29 +02:00
JC Brand
0688907e0d Allow events to be synchronous
When a synchronous event is fired, Converse will wait for all
promises returned by the event's handlers to finish before continuing.
2019-06-03 09:41:29 +02:00
JC Brand
267fb38e0c Remove the forward_messages config option 2019-05-31 16:07:51 +02:00
JC Brand
aece956281 Refactor strophe usage
- Upgrade to latest commit in Strophe
- Import individual Strophe dependencies
- Replace strophe plugins with code in Converse
2019-05-29 18:27:34 +02:00
JC Brand
f387c947f5 Allow the full app to be embedded.
- new config option `singleton`.
- new plugin `converse-uniview`
- removed `converse-embedded`.
- various CSS changes, to properly render an embedded full app
- don't re-open cached and non-autojoined chats in singleton mode

The goal here is to extend the `embedded` `view_mode` so that the full app can
also be embedded, not just a single MUC or private chat.

To do this, we'll need to differentiate between multi and singleton chat apps.

* A singleton chat app contains only a single chat.
* A multi-chat app can contain zero or more chats

So we introduce a new config option, `singleton`, which when used with
`view_mode` set to `embedded` will determine whether a single chat or the full
app is embedded.

Similarly, in `overlayed`, `fullscreen` and `mobile` view modes, `singleton`
set to true will allow only one chat within the parameters of that view mode.

We're appropriating the word `singleton` and introducing the concepts of
`uniview` and `multiview` (see a785ca8) to cover what was
previously meant with `singleton`.

updates #1297
2019-05-24 20:39:19 +02:00
JC Brand
1ef29bee4e Use composition instead of overrides 2019-05-24 16:02:07 +02:00
JC Brand
f0a680e492 Remove animate config settings.
Also update tests
2019-05-23 22:02:08 +02:00
JC Brand
b876500865 Update to latest backbone.overview 2019-05-23 14:44:10 +02:00
JC Brand
271c79eae8 Refactor message corrections
- Save date for older message versions and display it in the modal
- Properly handle the correction being received *before* the corrected message
2019-05-22 13:26:46 +02:00
JC Brand
4c924a66df Split bookmarks plugin into headless and views
Fixes #1577
2019-05-21 11:35:00 +02:00
JC Brand
886ff1bd19 Don't debounce reconnect on leading edge
Otherwise we can get into a situation where Converse stops trying to
reconnect.
2019-05-20 15:16:36 +02:00
JC Brand
6193a9dc80 Replace lodash methods with native ones and remove lodash.fp 2019-05-14 12:41:47 +02:00
JC Brand
d98b33de0a Trigger will-connect event inside reconnect method.
Also add docstrings.
2019-05-14 10:31:41 +02:00
JC Brand
d91a5ca6de Remove alias for xss. Upgrade pluggable.js to version 2.0.1 2019-05-13 18:54:00 +02:00
JC Brand
7a990ae0b9 Fixes #1558, this.get is not a function 2019-05-13 14:37:48 +02:00
JC Brand
c3dac272f8 Replace moment with DayJS 2019-05-06 14:27:18 +02:00
JC Brand
9528276be2 Use native Date methods instead of moment
- Use native `getTime` method instead of moment's `valueOf`
- Use toISOString() instead of moment().format()
  This makes the code timezone independent since we're now globally using UTC.
2019-05-06 10:28:03 +02:00
JC Brand
d868b9a9f7 Continuously retry to fetch login credentials 2019-05-02 14:53:42 +02:00
JC Brand
ba6de8844e Use Object.keys instead of _.keys 2019-04-29 09:29:40 +02:00
JC Brand
34469425d6 Use Object.assign instead of _.extend 2019-04-29 09:07:15 +02:00
JC Brand
51d0dc8d23 No such method disconnect 2019-04-27 18:09:59 +02:00
JC Brand
e189acc8c9 Returning nick with credentials_url complicates things too much 2019-04-23 14:53:48 +02:00