Commit Graph

138 Commits

Author SHA1 Message Date
Paweł Chmielowski c99ff6059f Fix cache invalidation in shared roster
Doing srg_get_info for not existing group, then srg_create, will make
srg_add_user fail because it will get info that group doesn't exist from
cache.
2022-09-28 18:28:24 +02:00
Linus Jahn 4a52b73a17 mod_shared_roster: Fix wrong hook type #roster{} (now #roster_item{})
The hook type was changed from #roster{} to #roster_item{} by me in the
recent MIX changes. Unfortunately I've overseen this one (and unit tests
+ dialyzer passed).
2022-08-12 17:07:28 +02:00
Linus Jahn d6b72f1c5d mod_roster: Change hook type from #roster{} to #roster_item{}
The problem with #roster{} is that every new record entry is also stored
in the mnesia roster table.  Adding the mix_participant_id there makes
no sense because the normal roster items are no MIX channels.  Using
\#roster_item{} for the hook and #roster{} for storing the normal items
seems to be a better idea.
2022-08-11 12:45:20 +02:00
Badlop 4f8e6fe844 Fix errors and warnings for "rebar3 edoc" 2022-05-17 10:42:02 +02:00
Badlop b3211b1f71 Update copyright year to 2022 2022-02-11 09:39:25 +01:00
Badlop c92478f7c2 Use the same wording in all the identical options db_type and ram_db_type 2022-02-03 18:21:51 +01:00
Holger Weiss 52ac941034 mod_shared_roster: Adjust special group cache size
Let the size of the cache used for 'special' groups (such as @all@ or
@online@) depend on the number of virtual hosts, as the cache will
contain seperate entries per domain.

Thanks to Ingo Jrgensmann for reporting the issue.
2022-01-25 16:57:27 +01:00
Holger Weiss 8e88fa3884 mod_shared_roster: Normalize JID on unset_presence
Don't forget to normalize the JID handed over from ejabberd_sm on
presence-unavailable.  Without normalization, mod_shared_roster might
fail to look up the storage backend for the given host name, for
example.

Fixes #3752.
2022-01-15 18:18:24 +01:00
Badlop 506e2f3b97 Use specific syntax so modules and top-level will be links
If we use _`whatever`_ here in ejabberd man pages,
it is converted to *`whatever`* in markdown,
and docs.ejabberd.im/Makefile converts to the proper links
2021-08-23 14:04:49 +02:00
Jindrich Sarson dcc5d8704f delete cache after performing change to be sure that in cache will be up to date data 2021-04-17 19:07:21 +02:00
Paweł Chmielowski e462f0a584 Fix dialyzer warnings 2021-04-16 11:55:48 +02:00
Paweł Chmielowski 45bbbd0284 Fix syntax not recognized by older erlang 2021-04-16 10:46:28 +02:00
Paweł Chmielowski 5b0f0d8352 Improve database and caching in mod_shared_roster
This makes us keep cache of groups that use wildcards no matter
of cache settings, and tries to not same fetch data multiple times
in roster get operations.
2021-04-16 10:34:32 +02:00
Paweł Chmielowski 54916caf65 Use proper source for cache options in mod_shared_roster 2021-04-16 10:20:13 +02:00
Paweł Chmielowski c8afb5ceb6 Reconfigure cache in mod_shared_roster when options change 2021-04-16 10:19:09 +02:00
Badlop 6e0161470e Update newest copyright year to 2021 (#3464) 2021-01-27 17:02:06 +01:00
Badlop 3581d90d9d Provide name when pushing new roster item in shared roster group (#3427) 2020-11-19 17:07:23 +01:00
Stu Tomlinson bd11a00f8f
Use include_lib() to include headers from dependencies (#3369) 2020-09-03 13:45:57 +02:00
Badlop 864188ad65 Mark dangerous buttons with CSS (#3363) 2020-08-24 16:44:07 +02:00
Badlop f2e81ed2a0 When updating group in cache, first delete so insert succeeds (#3296) 2020-06-05 19:34:00 +02:00
Badlop 7efc208b9e Handle ets_cache return value in shared roster get_group_opts (#3296) 2020-06-05 19:33:52 +02:00
Badlop 78f0439e78 Make a few more strings translatable in MUC and Shared Roster WebAdmin 2020-04-20 20:24:56 +02:00
Badlop 0705695e02 Update documentation of mod_shared_roster (#3214) 2020-04-16 13:12:32 +02:00
Badlop e197b25e82 Rename opts->name to label, to avoid confusion with the group name (#3214)
Also updated WebAdmin to show more meaningful explanations
Also fixed a bug that break support for group@host in Displayed
2020-04-14 13:58:53 +02:00
Paweł Chmielowski d8899ca9ac Add cache to mod_shared_roster
This should help with excessive queries that sql backend generates
Should fix issue #3158.
2020-03-17 14:35:43 +01:00
Paweł Chmielowski 82074190fb Replace mod_shared_roster:X call with just X inside that module 2020-03-16 14:57:55 +01:00
Paweł Chmielowski 6fe7c5cac5 Try to limit calls to groups_with_opts in mod_shared_roster 2020-03-16 13:29:05 +01:00
Badlop 2d32c66fd7 Update copyright to 2020 (#3149) 2020-01-28 15:49:23 +01:00
Evgeny Khramtsov 97da380acd Generate ejabberd.yml.5 man page from source code directly
Several documentation callbacks (doc/0 and mod_doc/0) are implemented
and `ejabberdctl man` command is added to generate a man page. Note
that the command requires a2x to be installed (which is a part of
asciidoc package).
2020-01-08 12:24:51 +03:00
Evgeny Khramtsov 5770946f03 Correctly handle unicode in log messages 2019-09-23 15:17:20 +03:00
Badlop e50ecf9e96 Fix some links to Guide in WebAdmin and add new ones (#3003) 2019-08-27 15:41:37 +02:00
Badlop 94d50a447d Fix call to deprecated ejabberd_config:get_myhosts() (#3000) 2019-08-22 18:35:41 +02:00
Badlop 12c4dfd955 Provide meaningful error when adding non-local users to shared roster (#3000) 2019-08-22 17:13:18 +02:00
Evgeny Khramtsov a3e0cbbdd8 Make logging messages more consistent 2019-06-24 20:32:34 +03:00
Evgeny Khramtsov 00f2a736eb Improve extraction of translated strings
Now every such string MUST be encapsulated into ?T() macro.
The macro itself is defined in include/translate.hrl.
Example:

-module(foo).
-export([bar/1]).
-include("translate.hrl").

bar(Lang) ->
    translate:translate(Lang, ?T("baz")).
2019-06-22 17:08:45 +03:00
Evgeny Khramtsov a205ebad2b Get rid of "well-known" type 2019-06-15 12:53:16 +03:00
Evgeny Khramtsov a02cff0e78 Use new configuration validator 2019-06-14 12:33:26 +03:00
Paweł Chmielowski b30775a357 Don't perform roster push for non-local contacts in mod_shared_roster
If group have member with jid from external server we tried to make
mod_roster sent roster push to it, and it sometimes didn't like to get
bogus data like that, so let's check if it's local user before doing this.
2019-02-18 12:37:42 +01:00
Badlop 55417dfb37 Update copyright to 2019 (#2756) 2019-01-08 22:53:27 +01:00
colm b0b188aa68 remove some chatty SQL queries by pulling back all groups with opts and filtering in memory. move a call to get_group_name outside of a loop to eliminate redundant repeated queries 2018-09-10 00:08:00 +01:00
Evgeniy Khramtsov ed1ee6061e Move move randoms module to p1_utils repo 2018-07-05 11:51:49 +03:00
Evgeniy Khramtsov fd8e07af47 Get rid of ejabberd.hrl header
The header consisted of too many unrelated stuff and macros misuse.
Some stuff is moved into scram.hrl and type_compat.hrl.
All macros have been replaced with the corresponding function calls.

TODO: probably type_compat.hrl is not even needed anymore since
we support only Erlang >= OTP 17.5
2018-06-14 14:00:47 +03:00
Evgeniy Khramtsov bb20e5f3fa Apply some dirty hacks for mod_shared_roster
Probably this fixes #1846
2018-03-19 12:32:43 +03:00
Evgeniy Khramtsov 4b012a99d2 Introduce option 'captcha' for mod_block_strangers
When the option is set to `true`, the module will generate
CAPTCHA challenges for incoming subscription requests. The option
also implies that option `drop` is set to `true`. Note that
the module won't generate CAPTCHA challenges for messages: they
will still be rejected if `drop` is set to `true`.

Fixes #2246
2018-01-26 15:02:06 +03:00
Evgeniy Khramtsov ba2b650464 Introduce new gen_mod callback: mod_options/1
The callback is supposed to provide known options and their default
values, as long as the documentation. Passing default values into
get_mod functions is now deprecated: all defaults should be provided
by the Mod:mod_options/1 callback.
2018-01-23 10:54:52 +03:00
Evgeniy Khramtsov cdc7c1d1ed Update copyright dates 2018-01-05 23:18:58 +03:00
Evgeniy Khramtsov f782955c06 Implement cache for roster 2017-05-17 14:47:35 +03:00
Evgeniy Khramtsov 633b68db11 Use cache for authentication backends
The commit introduces the following API incompatibilities:

In ejabberd_auth.erl:
* dirty_get_registered_users/0 is renamed to get_users/0
* get_vh_registered_users/1 is renamed to get_users/1
* get_vh_registered_users/2 is renamed to get_users/2
* get_vh_registered_users_number/1 is renamed to count_users/1
* get_vh_registered_users_number/2 is renamed to count_users/2

In ejabberd_auth callbacks
* plain_password_required/0 is replaced by plain_password_required/1
  where the argument is a virtual host
* store_type/0 is replaced by store_type/1 where the argument is
  a virtual host
* set_password/3 is now an optional callback
* remove_user/3 callback is no longer needed
* remove_user/2 now should return `ok | {error, atom()}`
* is_user_exists/2 now must only be implemented for backends
  with `external` store type
* check_password/6 is no longer needed
* check_password/4 now must only be implemented for backends
  with `external` store type
* try_register/3 is now an optional callback and should return
  `ok | {error, atom()}`
* dirty_get_registered_users/0 is no longer needed
* get_vh_registered_users/1 is no longer needed
* get_vh_registered_users/2 is renamed to get_users/2
* get_vh_registered_users_number/1 is no longer needed
* get_vh_registered_users_number/2 is renamed to count_users/2
* get_password_s/2 is no longer needed
* get_password/2 now must only be implemented for backends with
  `plain` or `scram` store type

Additionally, the commit introduces two new callbacks:
* use_cache/1 where the argument is a virtual host
* cache_nodes/1 where the argument is a virtual host

New options are also introduced: `auth_use_cache`, `auth_cache_missed`,
`auth_cache_life_time` and `auth_cache_size`.
2017-05-11 14:37:21 +03:00
Badlop ee849338dd Include shared groups also when contact is is personal roster (#1585) 2017-03-09 19:21:45 +01:00
Evgeniy Khramtsov c1439ddd5b Get rid of jid:to_string/1 and jid:from_string/1 2017-02-26 10:07:12 +03:00