### Setup database for testing Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/developers-guide/Testing-MongooseIM/index.html Configure and set up the necessary database (e.g., PostgreSQL) for MongooseIM testing. This command should be run before starting MongooseIM nodes. ```shell DB="pgsql" ./tools/setup-db.sh ``` -------------------------------- ### MUC Light Admin Queries Example Source: https://github.com/esl/mongoosedocs/blob/gh-pages/latest/graphql-api/admin-graphql-doc.html Example showcasing queries available for MUC Light administration, such as retrieving room messages, room configuration, listing room users, listing user's rooms, and getting a user's blocking list. ```graphql { "getRoomMessages": StanzasPayload, "getRoomConfig": Room, "listRoomUsers": [RoomUser], "listUserRooms": ["alice@localhost"], "getBlockingList": [BlockingItem] } ``` -------------------------------- ### System install on Mac with custom prefix and user Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/developers-guide/release_config/index.html Manually test the installation process on a Mac system. This command configures the installation with a specific user, prefix, and system mode, then installs the release. Overriding RUNNER_GROUP is necessary on Mac. ```bash ./tools/configure user=erszcz prefix=/tmp/mim-sandbox-system system=yes cat configure.out rel/configure.vars.config RUNNER_GROUP=staff make install ``` -------------------------------- ### Example Exometer Configuration with Graphite Reporters Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/configuration/instrumentation/index.html Enable the Exometer handler and configure two different Graphite reporters for sending metrics. This setup allows for detailed metrics reporting to Graphite instances. ```ini [[instrumentation.exometer.report.graphite]] host = "127.0.0.1" interval = 15000 prefix = "mongooseim" connect_timeout = 5000 [[instrumentation.exometer.report.graphite]] host = "hosted_graphite.com" prefix = "mim" ``` -------------------------------- ### Example Key-Value Pair Source: https://github.com/esl/mongoosedocs/blob/gh-pages/latest/graphql-api/admin-graphql-doc.html A basic example of a key-value pair structure. ```json { "key": "abc123", "value": "abc123" } ``` -------------------------------- ### Script Execution Example (XML) Source: https://github.com/esl/mongoosedocs/blob/gh-pages/latest/migrations/jid-from-mam-muc-script/index.html Demonstrates how to run the script with XML input. Ensure the input file is correctly formatted. ```bash tools/migration/sender-jid-from-mam-message.escript xml < sender-jid-from-mam-message.example.xml > out ``` -------------------------------- ### Resend Offline Messages Hook Example Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/developers-guide/Hooks-and-handlers/index.html Example of the `resend_offline_messages` hook in `mod_presence`, demonstrating how to retrieve accumulated messages using `mongoose_acc:get`. ```erlang Acc1 = mongoose_hooks:resend_offline_messages(Acc, Jid), Rs = mongoose_acc:get(offline, messages, [], Acc1), ``` -------------------------------- ### Example External Authentication Configuration Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/authentication-methods/external/index.html A complete example showing how to configure both the external authentication program and the number of instances. ```ini [auth.external] program = "/home/user/authenticator" instances = 5 ``` -------------------------------- ### Client Requests Tokens (IQ Get) Source: https://github.com/esl/mongoosedocs/blob/gh-pages/latest/open-extensions/xeps/xep-token-reconnection.html Example of an IQ 'get' stanza a client sends to its own bare JID to request tokens from the server. ```xml ``` -------------------------------- ### Sound Input Example Source: https://github.com/esl/mongoosedocs/blob/gh-pages/latest/graphql-api/user-graphql-doc.html Example of how to provide sound input, including phonetic, binary, or external values. ```json { "phonetic": "xyz789", "binValue": "xyz789", "extValue": "xyz789" } ``` -------------------------------- ### Start and Check MongooseIM Node Status Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/operation-and-maintenance/Rolling-upgrade/index.html After installing the new version, use these commands to start the MongooseIM node and verify its status and cluster membership. ```bash mongooseimctl start mongooseimctl status mongooseimctl mnesia info | grep "running db nodes" ``` -------------------------------- ### Client Requests Tokens (XMPP IQ Get) Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/open-extensions/xeps/xep-token-reconnection.html Example of an XMPP IQ 'get' request sent by a client to its own bare JID to obtain authentication tokens. ```xml ``` -------------------------------- ### ModuleInfo Example Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/graphql-api/admin-graphql-doc.html This example shows the structure for ModuleInfo, which includes the module name and a list of its configuration options. ```json { "name": "xyz789", "options": [ModuleOption] } ``` -------------------------------- ### Files that change after starting and stopping Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/developers-guide/release_config/index.html List of files within the MongooseIM installation that are modified after the server starts and stops. These typically include log files and data storage files. ```bash var/lib/mongooseim/DECISION_TAB.LOG var/lib/mongooseim/LATEST.LOG var/lib/mongooseim/last_activity.DCD var/lib/mongooseim/muc_registered.DCD var/lib/mongooseim/muc_room.DCD var/lib/mongooseim/offline_msg.DAT var/lib/mongooseim/passwd.DCD var/lib/mongooseim/privacy.DCD var/lib/mongooseim/private_storage.DAT var/lib/mongooseim/roster.DCD var/lib/mongooseim/roster_version.DCD var/lib/mongooseim/schema.DAT var/lib/mongooseim/vcard.DAT var/lib/mongooseim/vcard_search.DCD var/lib/mongooseim/pid var/lib/mongooseim/status var/log/mongooseim/crash.log var/log/mongooseim/mongooseim.log var/log/mongooseim/erlang.log.1 var/log/mongooseim/run_erl.log ``` -------------------------------- ### Example: Registering a GDPR-Safe User Source: https://github.com/esl/mongoosedocs/blob/gh-pages/latest/operation-and-maintenance/gdpr-considerations/index.html This example shows the command to register a user and the expected JSON output, confirming the user's JID and registration message. ```bash $ mongooseimctl account registerUser --domain localhost --password secret { "data" : { "account" : { "registerUser" : { "message" : "User 1661-175924-881845-449bca06515e060a@localhost successfully registered", "jid" : "1661-175924-881845-449bca06515e060a@localhost" } } } } ``` -------------------------------- ### Example Dummy Authentication Configuration Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/authentication-methods/dummy/index.html An example configuration combining base_time and variance for the dummy authentication module. ```ini [auth.dummy] base_time = 5 variance = 10 ``` -------------------------------- ### FileUrls Type Example Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/graphql-api/user-graphql-doc.html Contains URLs for putting and getting a file, along with HTTP headers. ```json { "putUrl": "xyz789", "getUrl": "abc123", "headers": [Header] } ``` -------------------------------- ### Error Response Example Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/open-extensions/inbox/index.html Illustrates an error response when an invalid value is provided for a query parameter, such as the 'start' field. ```APIDOC ## Error Handling ### Description This section provides an example of an error response that occurs when a query parameter, such as the 'start' field, is provided with an invalid value. ### Method SET (IQ stanza) ### Endpoint N/A (IQ stanza) ### Request Example (Invalid Input) ```xml invalid ``` ### Response Example (Error) #### Error Response (400) - **error** (element, type='modify') - **bad-rquest** (element, xmlns='urn:ietf:params:xml:ns:xmpp-stanzas') - **text** (element, xmlns='urn:ietf:params:xml:ns:xmpp-stanzas') - Description of the error, indicating the invalid field and value. #### Response Example ```xml Invalid inbox form field value, field=start, value=invalid ``` ``` -------------------------------- ### Example: Retrieving Personal Data Source: https://github.com/esl/mongoosedocs/blob/gh-pages/latest/operation-and-maintenance/gdpr-considerations/index.html This example demonstrates how to use the retrievePersonalData command, specifying the username, domain, and the output file path for the zip archive. ```bash $ mongooseimctl gdpr retrievePersonalData --username 1661-175924-881845-449bca06515e060a --domain localhost --resultFilepath /home/mongooseim/gdpr/1661-175924-881845-449bca06515e060a.zip ``` -------------------------------- ### Example MongooseIM mod_vcard Configuration Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/modules/mod_vcard/index.html A comprehensive example configuration for the mod_vcard module, demonstrating LDAP settings, vCard mapping to LDAP fields, and search field configurations. This setup enables vCard storage and retrieval via LDAP. ```Erlang [modules.mod_vcard] matches = 1 search = true host = "directory.example.com" [[modules.mod_vcard.ldap.vcard_map]] vcard_field = "FAMILY" ldap_pattern = "%s" ldap_field = "sn" [[modules.mod_vcard.ldap.vcard_map]] vcard_field = "FN" ldap_pattern = "%s" ldap_field = "displayName" [[modules.mod_vcard.ldap.search_fields]] search_field = "User" ldap_field = "%u" [[modules.mod_vcard.ldap.search_fields]] search_field = "Full Name" ldap_field = "displayName" [[modules.mod_vcard.ldap.search_reported]] search_field = "Full Name" vcard_field = "FN" [[modules.mod_vcard.ldap.search_reported]] search_field = "Given Name" vcard_field = "FIRST" ``` -------------------------------- ### Example PubSub Module Configuration Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/modules/mod_pubsub/index.html An example configuration for the mod_pubsub module, demonstrating settings for access control, PEP, backend storage, caching, and plugin selection. ```toml [modules.mod_pubsub] access_createnode = "pubsub_createnode" ignore_pep_from_offline = false backend = "rdbms" last_item_cache = "mnesia" max_items_node = 1000 plugins = ["flat", "pep"] [[modules.mod_pubsub.pep_mapping]] namespace = "urn:xmpp:microblog:0" node = "mb" ``` -------------------------------- ### Requesting Affiliation List Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/open-extensions/xeps/xep-muc-light.html User list is retrieved with affiliation IQ get. This example shows requesting owners and members. ```xml ``` ```xml ``` -------------------------------- ### Script Execution Example (Eterm) Source: https://github.com/esl/mongoosedocs/blob/gh-pages/latest/migrations/jid-from-mam-muc-script/index.html Demonstrates how to run the script with eterm input. Ensure the input file is correctly formatted. ```bash tools/migration/sender-jid-from-mam-message.escript eterm < sender-jid-from-mam-message.example.eterm > out ``` -------------------------------- ### Erlang API for Getting a Key Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/modules/mod_keystore/index.html This is a hook-based API call in Erlang to retrieve a key. Refer to mod_auth_token for usage examples. ```erlang mongoose_hooks:get_key(Domain, [], KeyName). ``` -------------------------------- ### Example Configuration for mod_fast_auth_token Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/modules/mod_fast_auth_token/index.html A complete example demonstrating how to configure the access and rotation validity periods for fast authentication tokens. ```toml [modules.mod_fast_auth_token] validity_period.access = {value = 1, unit = "days"} validity_period.rotate_before_expire = {value = 0, unit = "days"} ``` -------------------------------- ### Start MongooseIM with legacy config format Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/migrations/3.7.0_4.0.0/index.html Use this command to start MongooseIM using the legacy `mongooseim.cfg` configuration file format by setting the `MONGOOSEIM_CONFIG_FORMAT` environment variable. ```bash MONGOOSEIM_CONFIG_FORMAT=cfg mongooseimctl start ``` -------------------------------- ### Example: Allow Registration from Localhost Source: https://github.com/esl/mongoosedocs/blob/gh-pages/latest/modules/mod_register/index.html This configuration snippet allows registrations specifically from the localhost IP address and sets a custom welcome message and access rule. ```toml [modules.mod_register] welcome_message = {subject = "Hello from MIM!", body = "Message body."} ip_access = [ {address = "127.0.0.1", policy = "allow"} ] access = "register" ``` -------------------------------- ### OTP Logger configuration example Source: https://github.com/esl/mongoosedocs/blob/gh-pages/latest/migrations/3.7.0_4.0.0/index.html This is the equivalent OTP Logger configuration for the previous lager setup. It demonstrates how to configure handlers and levels for the new logging framework. ```erlang { %% The default configuration for the logger is: %% logger:set_handler_level(info). %% logger:add_handler(logger_std_h,lager_file_backend,[ %% {file,"ejabberd.log"}, %% {level,info}, %% {size,2097152}, %% {date,"$D0"}, %% {count,5} %% ]). %% logger:add_handler(logger_std_h,lager_console_backend,[ %% {level,info} %% ]). %% The configuration below is an example of how to configure it: %% logger:set_handler_level(info). %% logger:add_handler(logger_std_h,lager_file_backend,[ %% {file,"ejabberd.log"}, %% {level,info}, %% {size,2097152}, %% {date,"$D0"}, %% {count,5} %% ]). %% logger:add_handler(logger_std_h,lager_console_backend,[ %% {level,info} %% ]). } ``` -------------------------------- ### Configure ACL Resource Glob Pattern Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/configuration/acl/index.html Use `resource_glob` to match JIDs with resource names matching a glob pattern. This example matches resources starting with 'res'. ```erlang resource_glob = "^res" ``` ```erlang limited_resources = [ {resource_glob = "res???"} ] ``` -------------------------------- ### Full mod_disco Configuration Example Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/modules/mod_disco/index.html A comprehensive example demonstrating the configuration of various mod_disco options within a MongooseIM configuration file. ```lua [modules.mod_disco] iqdisc.type = "one_queue" extra_domains = ["some_domain", "another_domain"] server_info = [ {name = "abuse-address", urls = ["admin@example.com"]}, {name = "friendly-spirits", urls = ["spirit1@localhost", "spirit2@localhost"], modules = ["mod_muc", "mod_disco"]} ] users_can_see_hidden_services = true ``` -------------------------------- ### Service Configuration Example Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/graphql-api/admin-graphql-doc.html Example configuration for a service, including host, type, port, transport, and authentication details. ```json { "host": "localhost", "type": "xyz789", "port": 0, "transport": "xyz789", "username": "xyz789", "password": "xyz789", "expires": 2 } ``` -------------------------------- ### ACL Match Server with Glob Pattern Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/configuration/acl/index.html Use `server_glob` with a glob pattern to match JIDs where the domain name conforms to the pattern. This example matches domains starting with 'host'. ```erlang localhost_users = [ {server_glob = "host*"} ] ``` -------------------------------- ### ACL Match User with Regex Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/configuration/acl/index.html Use `user_regexp` with a regular expression to match JIDs where the user name conforms to the pattern. This example matches users starting with 'a' and ending with 'e'. ```erlang ae = [ {user_regexp = "^a.*e"} ] ``` -------------------------------- ### Enable CETS with File Discovery Backend Example Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/configuration/internal-databases/index.html An example configuration enabling CETS with the file discovery backend and specifying the node list file. ```ini [internal_databases.cets] backend = "file" node_list_file = "cets_disco.txt" ``` -------------------------------- ### Session Information Example Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/graphql-api/admin-graphql-doc.html Example of session data, including user, connection, IP, port, priority, node, and uptime. ```json { "user": "alice@localhost", "connection": "xyz789", "ip": "abc123", "port": 987, "priority": 123, "node": "xyz789", "uptime": 123 } ``` -------------------------------- ### Unblocking in MUC Light Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/open-extensions/xeps/xep-muc-light.html To unblock a room or user, send a get IQ stanza with a privacy list where the corresponding items have the action 'allow'. This example shows unblocking both a room and a user. ```xml ``` ```xml ``` -------------------------------- ### MnesiaAdminQuery SystemInfo Example Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/graphql-api/admin-graphql-doc.html This example shows how to query system information from Mnesia using the 'systemInfo' field. It accepts an optional list of keys to retrieve specific properties. ```json {"systemInfo": [MnesiaStringResponse]} ``` -------------------------------- ### MnesiaAdminMutation Example Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/graphql-api/admin-graphql-doc.html This snippet demonstrates the various mutation operations available for Mnesia administration, including setting master, changing nodenames, backup, restore, dump, load, and installing fallback. ```json { "setMaster": "xyz789", "changeNodename": "abc123", "backup": "xyz789", "restore": "xyz789", "dump": "abc123", "dumpTable": "abc123", "load": "xyz789", "installFallback": "abc123" } ``` -------------------------------- ### Example Inbox Error Response Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/open-extensions/inbox/index.html Illustrates an error response when an invalid value is provided for the 'start' field in an inbox query. The error includes a code and a text description of the invalid value. ```xml invalid Invalid inbox form field value, field=start, value=invalid ``` -------------------------------- ### Example Smart Markers Configuration Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/modules/mod_smart_markers/index.html A sample configuration block for the `mod_smart_markers` module, specifying the backend and IQ disc strategy. ```ini [modules.mod_smart_markers] backend = "rdbms" iqdisc = "parallel" ``` -------------------------------- ### ACL Match User with Glob Pattern Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/configuration/acl/index.html Use `user_glob` with a glob pattern to match JIDs where the user name conforms to the pattern. This example matches users starting with 'a' and containing 'e'. ```erlang ae_users = [ {user_glob = "a*e*"} ] ``` -------------------------------- ### Start MongooseIM Server Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/getting-started/Quick-setup/index.html Use this command to start the MongooseIM server. It will use Mnesia as the default database. ```bash mongooseimctl start ``` -------------------------------- ### Basic General Configuration Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/configuration/general/index.html Configure essential general settings like log level, XMPP hosts, default server domain, and language. This is a starting point for basic MongooseIM setup. ```ini [general] loglevel = "warning" hosts = ["my-xmpp-domain.com"] default_server_domain = "my-xmpp-domain.com" language = "en" ``` -------------------------------- ### Configure BOSH and WebSocket Handlers Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/listeners/listen-http/index.html Example showing how to configure both BOSH and WebSocket handlers for HTTP listeners. Ensure corresponding service configurations are also set up. ```toml [[listen.http.handlers.mongoose_bosh_handler]] host = "_" path = "/http-bind" [[listen.http.handlers.mongoose_websocket_handler]] host = "_" path = "/ws-xmpp" ``` -------------------------------- ### ACL Match Resource with Regex Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/configuration/acl/index.html Use `resource_regexp` with a regular expression to match JIDs where the resource name conforms to the pattern. This example matches resources starting with 'res' followed by one or more digits. ```erlang digital_resources = [ {resource_regexp = '^res\d+$'} ] ``` -------------------------------- ### Install Dependencies on Ubuntu Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/tutorials/How-to-build/index.html Installs Git, make, zlib, OpenSSL development libraries, GCC, G++, and Erlang using apt. ```bash sudo apt install git make zlib1g-dev libssl-dev gcc g++ erlang ``` -------------------------------- ### Session Example Source: https://github.com/esl/mongoosedocs/blob/gh-pages/latest/graphql-api/user-graphql-doc.html Details about a user's session, including JID, connection type, IP address, port, priority, node, and uptime. ```json { "user": "alice@localhost", "connection": "xyz789", "ip": "abc123", "port": 987, "priority": 987, "node": "abc123", "uptime": 987 } ``` -------------------------------- ### Configure Component Listener Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/listeners/listen-components/index.html Example TOML configuration for a component listener. This setup accepts all incoming connections on port 8888, uses the 'fast' shaper, limits access to the loopback interface, and requires a 'secret' password. ```toml [[listen.component]] port = 8888 access = "all" shaper = "fast" ip_address = "127.0.0.1" password = "secret" ``` -------------------------------- ### Show Test Runner Completion Examples Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/developers-guide/Testing-MongooseIM/index.html Displays examples of how to use the test runner's shell completion feature. ```bash ./tools/test-runner.sh --examples-complete ``` -------------------------------- ### MUC Light Room Mutations Example Source: https://github.com/esl/mongoosedocs/blob/gh-pages/latest/graphql-api/admin-graphql-doc.html Example demonstrating various mutations for MUC Light room management, including creating, changing configuration, inviting users, deleting rooms, kicking users, sending messages, and setting blocking lists. ```graphql { "createRoom": Room, "changeRoomConfiguration": Room, "inviteUser": "xyz789", "deleteRoom": "xyz789", "kickUser": "abc123", "sendMessageToRoom": "xyz789", "setBlockingList": "xyz789" } ``` -------------------------------- ### Start MongooseIM Server Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/tutorials/How-to-build/index.html Starts the MongooseIM server from the compiled project tree. ```bash bin/mongooseim start ``` -------------------------------- ### Installed MongooseIM directory structure Source: https://github.com/esl/mongoosedocs/blob/gh-pages/6.7.0/developers-guide/release_config/index.html Display the tree structure of the installed MongooseIM release. This shows the layout of configuration files, binaries, and data directories after installation. ```bash tree mim-sandbox-system/ -L 3 ``` -------------------------------- ### Get User Certificates via HTTP GET Request Source: https://github.com/esl/mongoosedocs/blob/gh-pages/latest/authentication-methods/http/index.html This endpoint retrieves a user's valid certificates in PEM format. It expects a GET request. ```http GET /get_certs?user=&server=&pass= HTTP/1.1 ```