Commit Graph

194 Commits

Author SHA1 Message Date
Holger Weiss 75f150f7ae mod_mam: Simplify 'message_is_archived' callback 2017-11-15 00:36:07 +01:00
Holger Weiss 98419c6662 mod_mam: Improve handling of forked messages
Make sure a message that was forked in ejabberd_sm will really only be
tagged with a stanza ID if (another copy of) it was stored in MAM.
2017-11-15 00:30:38 +01:00
Holger Weiss 2b3890f1b0 Announce support for stanza IDs
Announce the namespace for stanza IDs as per XEP-0359 v0.5.0.
2017-11-15 00:18:25 +01:00
Holger Weiss 06d4f1ff33 mod_mam: Add a few function specifications 2017-11-14 22:58:16 +01:00
Holger Weiss 5ae23a7301 mod_mam: Apply minor cosmetic changes 2017-11-14 22:36:46 +01:00
Holger Weiss 8376370ae1 mod_mam: Don't store from 'sm_receive_packet' hook
Let mod_mam use the 'sm_receive_packet' hook to generate stanza IDs for
incoming messages, but not to actually store them.  The latter would
require additional changes to make sure modules such as mod_privacy and
mod_block_strangers continue to affect MAM.
2017-11-14 22:02:48 +01:00
Evgeniy Khramtsov f953621ed2 Use xmpp:io_format_error/1 wherever possible 2017-11-14 09:02:43 +03:00
Holger Weiss 54c8ae4d2b mod_mam: Make sure archived message isn't bounced
If mod_offline is disabled but a message is archived by mod_mam, no
error bounce should be generated.  This functionality got lost when
mod_mam stopped using the 'offline_message_hook'.
2017-11-10 18:09:33 +01:00
Christophe Romain 5c6a37b20f Cleanup some headers 2017-11-10 17:51:22 +01:00
Holger Weiss d1df522fd9 mod_push: Avoid notification duplicates (again)
Now that mod_mam no longer uses the 'offline_message_hook', avoid
duplicating notifications for messages written to both MAM and offline
storage in another way.
2017-11-10 01:11:24 +01:00
Holger Weiss 28661d20bd mod_mam: Always strip stanza IDs
XEP-0359 v0.5.0 says: "Stanza ID generating entities, which encounter a
<stanza-id/> element where the 'by' attribute matches the 'by' attribute
they would otherwise set, MUST delete that element even if they are not
adding their own stanza ID."
2017-11-09 01:10:24 +01:00
Holger Weiss 9c174e30b2 mod_mam: Fix indentation 2017-11-09 01:00:15 +01:00
Holger Weiss 40d725e9c1 mod_mam: Ignore non-message stanzas earlier
Let mod_mam's hook callbacks ignore non-message stanzas using pattern
matching.
2017-11-09 00:48:19 +01:00
Holger Weiss 5cf4e200ba mod_mam: Make sure a stanza ID is always added
Let mod_mam store incoming messages from a new hook in ejabberd_sm.
This makes sure all messages are tagged with a stanza ID, including
those that are forked to multiple resources in ejabberd_sm.

Closes #1344.
2017-11-09 00:21:40 +01:00
Evgeniy Khramtsov 902c6d476b Prepare version 0.6.1 of XEP-0313 (MAM) support 2017-11-08 15:15:39 +03:00
Badlop cbbfe32d8b Unregister commands when stopping node only if it's last one (#2083) 2017-11-06 16:53:49 +01:00
Holger Weiss 59ec3d36f4 mod_mam: Simplify check for anon MUC JID filtering
Refuse filtering anon MUC MAM queries by JID even if it's the client's
own JID.  Clients probably won't perform such queries in practice, so
the additional complexity is unnecessary.
2017-09-24 15:04:09 +02:00
Holger Weiss 48f2adde98 mod_mam: Refuse filtering anon MUC queries by JID
Return an empty result set if a non-moderator attempts to filter by JID
while querying the archive of an anonymous MUC room.
2017-09-24 02:05:50 +02:00
Christophe Romain 766b7c65a6 Merge pull request #1881 from weiss/push
Support XEP-0357: Push Notifications
2017-08-04 12:58:06 +02:00
Badlop 1a0db3de3a Describe commands arguments and results in ejabberd_sm, ext_mod, mod_mam 2017-07-21 11:26:53 +02:00
Holger Weiss d6f1d3df5b Support XEP-0357: Push Notifications
Closes #1379.
2017-07-20 20:22:50 +02:00
Evgeniy Khramtsov f782955c06 Implement cache for roster 2017-05-17 14:47:35 +03:00
Lamtei W a0908ba393 Added export function for mam module 2017-05-10 11:22:07 +02:00
Evgeniy Khramtsov cf53d834e9 Introduce 'iqdisc' global option 2017-05-04 12:24:47 +03:00
Evgeniy Khramtsov fddd6110e0 Don't validate an option in gen_mod:get*opt() functions
The changes are very similar to those from previous commit:
* Now there is no need to pass validating function in
  gen_mod:get_opt() and gen_mod:get_module_opt() functions,
  because the modules' configuration keeps already validated values.
* New functions gen_mod:get_opt/2 and gen_mod:get_module_opt/3 are
  introduced.
* Functions gen_mod:get_opt/4 and get_module_opt/5 are deprecated.
  If the functions are still called, the "function" argument is
  simply ignored.
* Validating callback Mod:listen_opt_type/1 is introduced to validate
  listening options at startup.
2017-04-30 19:01:47 +03:00
Evgeniy Khramtsov 5444475b1d Correct option validation 2017-04-20 18:55:16 +03:00
Evgeniy Khramtsov 264a40f217 Use new cache API in mod_mam 2017-04-20 18:52:16 +03:00
Christophe Romain b1acd1183f Rename aux.erl as misc.erl
Thanks Microsoft Windows to not support some filenames
2017-04-11 12:13:58 +02:00
Evgeniy Khramtsov ad948d33c0 Add description to feature-not-implemented error 2017-04-05 15:19:00 +03:00
Evgeniy Khramtsov 7bcbea2108 Deprecate jlib.erl in favor of aux.erl
Since the main goal of jlib.erl is lost, all auxiliary functions
are now moved to aux.erl, and the whole jlib.erl is now deprecated.
2017-03-30 14:17:13 +03:00
Evgeniy Khramtsov 02064ae12a Add support for file-based queues
It's now possible to use files as internal packet queues.
The following options are introduced:

* queue_type: the option can be set to `ram` (default) or `file`.
  The option can be set per virtual host.
* queue_dir: path to the directory where queues will be allocated.
  The default is 'queue' directory inside Mnesia directory.
  This is a global option and cannot be set per virtual host.
2017-03-10 15:12:43 +03:00
Evgeniy Khramtsov c1439ddd5b Get rid of jid:to_string/1 and jid:from_string/1 2017-02-26 10:07:12 +03:00
Evgeniy Khramtsov 485aae8134 Don't pass 'from' and 'to' along with stanza in hooks' arguments 2017-02-24 21:25:25 +03:00
Evgeniy Khramtsov 4892b01eb4 Get rid of unused variable warning 2017-02-24 17:48:17 +03:00
Holger Weiss b475df2250 Include stanza ID with archived offline messages
Fixes #1480.
2017-02-23 16:55:35 +01:00
Evgeniy Khramtsov 3c4057ff55 Reload modules when reloading configuration file 2017-02-22 19:46:47 +03:00
Evgeniy Khramtsov 940ca9311d Fix some dialyzer warnings 2017-02-18 09:36:27 +03:00
Evgeniy Khramtsov 8b2d308498 Change routing API
Now 'From' and 'To' arguments must be omitted in functions
and structures related to routing.
The commit deprecates the following functions:
     ejabberd_router:route/3 in favor of ejabberd_router:route/1
     ejabberd_router:route_error/4 in favor of ejabberd_router:route_error/2
     ejabberd_local:route_iq/4 in favor of ejabberd_local:route_iq/2
     ejabberd_local:route_iq/5 in favor of ejabberd_local:route_iq/3
The format of {route, From, To, Packet} is changed in favor of {route, Packet}
2017-02-16 11:10:24 +03:00
Evgeniy Khramtsov e564f9ae31 Make a message is not bounced if it's archived 2017-01-21 13:47:47 +03:00
Evgeniy Khramtsov 68cf45a8b9 Archive message before delivering it to offline storage (#1348) 2017-01-21 11:47:04 +03:00
Evgeniy Khramtsov 56ef607904 Add stanza-id to every archived message (#1477) 2017-01-20 23:21:06 +03:00
Evgeniy Khramtsov d5d906184f Merge branch 'new_stream'
Conflicts:
	src/cyrsasl.erl
	src/ejabberd_c2s.erl
	src/ejabberd_cluster.erl
	src/ejabberd_frontend_socket.erl
	src/ejabberd_node_groups.erl
	src/ejabberd_router.erl
	src/mod_bosh.erl
	src/mod_ip_blacklist.erl
	src/mod_muc_mnesia.erl
	src/mod_offline.erl
	src/mod_proxy65_sm.erl
2017-01-20 19:35:46 +03:00
Evgeniy Khramtsov 87b964a7f6 Make sure 'jabber:client' namespace is added to forwarded messages (#1474) 2017-01-19 18:03:07 +03:00
Evgeniy Khramtsov 0baaad30b1 Implement database backend interface for MUC, BOSH and auth_anonyous 2017-01-13 12:03:39 +03:00
Evgeniy Khramtsov 1e55e018e5 Adopt remaining code to support new hooks 2017-01-09 17:02:17 +03:00
Christophe Romain 32e5781a6a Cleanup file headers 2017-01-03 15:58:52 +01:00
Badlop 5fdd1c39fe Update copyright date automatically (#1442) 2017-01-02 21:42:06 +01:00
Evgeniy Khramtsov 0f11b1be36 Don't forget to erase cache on user removal 2016-11-24 18:40:20 +03:00
Holger Weiss 114ca786ee Let ejabberd_sm mark copied messages
When multiple resources have the same (highest) priority, ejabberd_sm
dispatches messages addressed to the bare JID (or to an unavailable
resource) to each of these resources.  Such messages are now marked with
an 'sm_copy' flag for all but one of the resources.  This makes it
easier for other modules to identify those duplicates.

Resolves #1356.
2016-11-22 19:25:20 +01:00
Evgeniy Khramtsov b8dcc911a3 Make common tests working again 2016-11-18 13:38:08 +03:00
Evgeniy Khramtsov 7e9f1a6dc1 Don't auto-decode forwarded payload 2016-11-13 13:41:04 +03:00
Evgeniy Khramtsov b8f22ff538 Deprecate most of the functions from jlib.erl 2016-11-13 10:44:53 +03:00
Evgeniy Khramtsov 78a44e0176 Merge branch 'master' into xml-ng
Conflicts:
	src/adhoc.erl
	src/cyrsasl_oauth.erl
	src/ejabberd_c2s.erl
	src/ejabberd_config.erl
	src/ejabberd_service.erl
	src/gen_mod.erl
	src/mod_admin_extra.erl
	src/mod_announce.erl
	src/mod_carboncopy.erl
	src/mod_client_state.erl
	src/mod_configure.erl
	src/mod_echo.erl
	src/mod_mam.erl
	src/mod_muc.erl
	src/mod_muc_room.erl
	src/mod_offline.erl
	src/mod_pubsub.erl
	src/mod_stats.erl
	src/node_flat_sql.erl
	src/randoms.erl
2016-11-12 13:27:15 +03:00
Holger Weiss 2a63d0e95a mod_mam: Use user JID for stanza ID 'by' attribute
Use the user (or room) JID instead of the server JID for the 'by'
attribute of <stanza-id/> and <archived/> tags.  That's what the
examples in XEP-0313 v0.2 and XEP-0359 v0.3.0 suggest.
2016-11-01 08:47:08 +01:00
Evgeniy Khramtsov 67720c7713 Add more MUC tests 2016-10-17 13:37:23 +03:00
Holger Weiss b693601dd1 Don't let MAM messages go into offline storage 2016-10-12 23:10:25 +02:00
Evgeniy Khramtsov 6a3691ef7c Add xdata generator and make some code using it 2016-10-07 10:31:03 +03:00
Evgeniy Khramtsov 58969fb854 Improve namespace handling 2016-09-24 14:17:21 +03:00
Evgeniy Khramtsov 151668ac10 Fix dialyzer warnings for mod_mam 2016-09-13 16:56:34 +03:00
Evgeniy Khramtsov e987b88848 Make common tests working again 2016-09-13 12:30:05 +03:00
Holger Weiss 20a510d877 mod_mam: Add 'store_mam_message' hook
The new 'store_mam_message' hook is invoked whenever a MAM message is
stored.
2016-08-15 23:28:36 +02:00
Holger Weiss bf9d6b5534 Honor <store/> hint for any non-"error" message
XEP-0334 says: "A message containing the <store/> hint that is not of
type 'error' SHOULD be stored by the entity."
2016-08-12 21:13:10 +02:00
Holger Weiss 28dde294e5 mod_mam: Don't store messages of type "headline"
XEP-0313 says: "a server SHOULD include in a user archive all of the
messages a user sends or receives of type 'normal' or 'chat' that
contain a <body> element."
2016-08-12 20:38:17 +02:00
Evgeniy Khramtsov 31faa4eb9a Add more type specs 2016-08-12 13:17:42 +03:00
Evgeniy Khramtsov 522a186a38 Improve some type specs 2016-08-09 10:56:32 +03:00
Evgeniy Khramtsov 4ff8d7918a Change code to reflect recent changes in fxml_gen 2016-08-05 08:41:08 +03:00
Holger Weiss 9a5f0751be mod_mam: Simplify "assume_mam_usage" option
The "assume_mam_usage" option now takes a boolean value.  Setting it to
"true" has the same effect as "if_enabled" had before.  The "on_request"
behavior is no longer offered, as it made the option (and its
documentation) overly complex.
2016-08-05 01:57:01 +02:00
Evgeniy Khramtsov 8275e95a16 Swap variables in their correct places 2016-07-27 18:06:34 +03:00
Evgeniy Khramtsov 179fcd9521 Rewrite mod_mam and mod_muc to use XML generator 2016-07-25 13:50:30 +03:00
Holger Weiss 8f8c499cfa mod_mam: Fix handling of result set page limit
Restore function clause for handling a client-specified result set page
limit that doesn't exceed mod_mam's upper threshold.
2016-07-19 21:23:30 +02:00
Holger Weiss 9fcb81dea9 mod_mam: Always limit result set page size
Limit the number of messages returned for a given MAM request even if
the client didn't specify an RSM set (not just if the client specified
an RSM set without a limit).

This is still not done for MAM v0.2 requests though, as that version of
the XEP doesn't require clients to support RSM.
2016-07-19 21:08:13 +02:00
Evgeniy Khramtsov f6e960d326 Fix compilation error 2016-07-10 08:45:24 +03:00
Evgeniy Khramtsov 786bd4f26c Use hooks instead of direct calls to mod_mam 2016-07-09 12:43:01 +03:00
Evgeniy Khramtsov 4220a2b98c Make modules loading in a dependent order (#1191) 2016-07-06 14:58:48 +03:00
Christophe Romain cd0244eb71 Merge pull request #1120 from anagromataf/feature/archive-id-in-message-carbons
Send unique stanza id and archived tag also in the message carbons
2016-06-22 15:47:27 +02:00
Christophe Romain 7744339347 Update supported xep version 2016-06-22 11:24:01 +02:00
Holger Weiss 26bce5dee3 mod_mam: Fix "assume_mam_usage: if_enabled" 2016-06-14 16:40:46 +02:00
Tobias Kräntzer 2529acc36c Send unique stanza id and archived tag also in the message carbons
- Change order of the hooks in mod_mam for sending and receiving packets. Messages are archived before a carbon copy is send to the other recourcces.
- Add archived tag and unique stanza id to the outgoing packet to have message carbons with the archive information.
- Add additional hook (in mod_mam) to strip the archive tag for outgoing packets after message carbons have been send.
2016-05-15 20:13:25 +02:00
Holger Wei 6cb60aaff5 Cosmetic change: Make variable names consistent
Use the same variable names in both mod_mam:select/8 clauses to avoid
confusion.
2016-05-03 19:12:57 +02:00
Evgeniy Khramtsov 3493a87469 Fix typo in mod_mam:select() (#1098) 2016-04-30 21:37:18 +03:00
Evgeniy Khramtsov 9c369b7a8c Improve detection of databases supported by modules (#1092) 2016-04-27 17:10:50 +03:00
Evgeniy Khramtsov 1aae8a9fda Rename odbc to sql everywhere 2016-04-20 13:25:42 +03:00
Evgeniy Khramtsov 52571e8624 Clean mod_mam.erl from DB specific code 2016-04-15 15:11:31 +03:00
Evgeniy Khramtsov fced8dc3d9 Replace some ?ERR_* macros with ?ERRT_* 2016-03-31 11:00:29 +03:00
Evgeniy Khramtsov 7a9e93839a Fix some LIMIT related problems with MSSQL 2016-03-29 11:34:00 +03:00
Holger Weiss 17be70339c mod_mam: Send new preferences when they are set
If a client updates the archiving preferences, include the new
preferences with the IQ result (as mandated by XEP-0313).
2016-02-10 23:06:31 +01:00
Evgeny Khramtsov 2bfb619d19 Merge pull request #914 from weiss/mam-expose-jid
Expose occupant JID in MUC MAM messages whenever possible
2016-02-08 14:23:19 +03:00
Holger Weiss 8098f7d9a8 mod_mam: Don't let outcasts access MUC archive
XEP-0313 says: "A MUC archive MUST check that the user requesting the
archive has the right to enter it at the time of the query [...].  In
the case of open MUC rooms, the MUC archives can generally be accessed
by any users [...] who do not have an affiliation of 'outcast'".
2016-02-08 00:16:02 +01:00
Mickael Remond dfc29ea03c Switch to Fast XML module 2016-02-03 19:03:17 +01:00
Paweł Chmielowski bdeb4a7e32 Add a way to get all ejabberd_commands, not only those that was registered
This is part of (TECH-1828).
2016-01-26 10:00:28 +01:00
Holger Weiss b62607037a mod_mam: Expose MUC occupant JID in more cases
Include the occupant JID with MUC MAM messages if the room is not
anonymous, and also when the MAM user sent the MUC message himself (not
just in the case where he is a room moderator).
2016-01-20 00:02:40 +01:00
Holger Weiss 5e4ed4266d mod_mam: Strip existing JID tags from MUC messages
Strip any pre-existing <x/> tags which have an <item/> child with a
'jid' attribute from MUC MAM messages.  This way, if such a tag exists,
clients can be sure it was added by mod_mam.
2016-01-19 00:39:10 +01:00
Holger Weiss bd383fb8c1 mod_mam: Remove unused code
This mod_mam version doesn't store groupchat messages in user archives,
and it also doesn't support the "store_body_only" option.
2016-01-18 13:27:29 +01:00
Holger Weiss ddaa409ee2 XEP-0198: Let MAM take care of pending messages
If a stream management session times out for a user who appears to be
using MAM, drop any unacknowledged messages rather than resending or
bouncing them.  This avoids duplicates or bogus error messages.

However, this is only done if the new mod_mam option "assume_mam_usage"
is set to 'if_enabled' or 'on_request'.  In the former case, a user is
assumed to be using MAM if archiving is enabled for his account.  In the
latter case, MAM usage is assumed only if archiving was explicitly
requested by the client, or if archiving was enabled by means of
mod_mam's "request_activates_archiving" option.
2016-01-15 01:08:22 +01:00
Holger Weiss db04cdf2ca mod_mam: Sort messages returned by Mnesia
Sort the messages retrieved from an Mnesia archive before selecting the
subset limited by the <max/> value.  This makes sure the desired subset
of messages is sent to the client.
2016-01-14 02:27:02 +01:00
Holger Weiss 58c8fc5770 mod_mam: Limit result set page size
If the client doesn't specify a maximum number of messages to retrieve
per page, set a limit of 50 messages.  If the client specifies a limit
larger than 250, cap the number to 250 messages.

These limits aren't enforced for MAM v0.2 requests though, as that
version of the XEP doesn't require clients to support RSM.  The newer
revisions say that "a server MAY place a reasonable limit on how many
stanzas may be pushed to a client in one request.  Whether or not the
client query included a <set/> element, the server MAY simply return its
limited results, modifying the <set/> element it returns appropriately."
2016-01-14 02:12:28 +01:00
Holger Weiss 35ec0d58a4 mod_mam: Reject <index/>-based paging
If an <index/> is specified in the MAM request, reject the request
rather than ignoring the desired index and returning wrong results.
XEP-0059 says that the server "MAY return a <feature-not-implemented/>
error."
2016-01-14 01:39:19 +01:00
Holger Weiss 11afa45646 mod_mam: Remove unused variable 2016-01-14 01:15:11 +01:00
Holger Weiss 89f63a4fdf mod_mam: Check whether MUC message is desired 2016-01-14 01:13:16 +01:00
Holger Weiss 85f4f90b45 mod_mam: Support XEP-0313 v0.2 MUC archive queries 2016-01-14 00:58:48 +01:00