Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions include/mod_invites.hrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-define(INVITE_TOKEN_EXPIRE_SECONDS_DEFAULT, 5*86400).
-define(INVITE_TOKEN_LENGTH_DEFAULT, 24).

-define(NS_INVITE_INVITE, <<"urn:xmpp:invite#invite">>).
-define(NS_INVITE_CREATE_ACCOUNT, <<"urn:xmpp:invite#create-account">>).

-record(invite_token, {token :: binary(),
inviter :: {binary(), binary()},
invitee = <<>> :: binary(),
created_at = calendar:now_to_datetime(erlang:timestamp()) :: calendar:datetime(),
expires = calendar:gregorian_seconds_to_datetime(calendar:datetime_to_gregorian_seconds(calendar:now_to_datetime(erlang:timestamp()))
+ ?INVITE_TOKEN_EXPIRE_SECONDS_DEFAULT) :: calendar:datetime(),
type = roster_only :: roster_only | account_only | account_subscription,
account_name = <<>> :: binary()
}).
3 changes: 2 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ defmodule Ejabberd.MixProject do
[{:cache_tab, "~> 1.0"},
{:dialyxir, "~> 1.2", only: [:test], runtime: false},
{:eimp, "~> 1.0"},
{:erlydtl, git: "https://github.com/erlydtl/erlydtl", tag: "0.15.0", override: true},
{:ex_doc, "~> 0.31", only: [:edoc], runtime: false},
{:fast_tls, "~> 1.1.24"},
{:fast_xml, "~> 1.1.56"},
Expand All @@ -112,7 +113,7 @@ defmodule Ejabberd.MixProject do
{:p1_utils, "~> 1.0"},
{:pkix, "~> 1.0"},
{:stringprep, ">= 1.0.26"},
{:xmpp, git: "https://github.com/processone/xmpp", ref: "7285aa7802bfa90bcefafdad3a342fbb93ce7eea", override: true},
{:xmpp, git: "https://github.com/processone/xmpp", tag: "1.11.4", override: true},
{:yconf, ">= 1.0.22"}]
++ cond_deps()
end
Expand Down
3 changes: 2 additions & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"epam": {:hex, :epam, "1.0.14", "aa0b85d27f4ef3a756ae995179df952a0721237e83c6b79d644347b75016681a", [:rebar3], [], "hexpm", "2f3449e72885a72a6c2a843f561add0fc2f70d7a21f61456930a547473d4d989"},
"eredis": {:hex, :eredis, "1.7.1", "39e31aa02adcd651c657f39aafd4d31a9b2f63c6c700dc9cece98d4bc3c897ab", [:mix, :rebar3], [], "hexpm", "7c2b54c566fed55feef3341ca79b0100a6348fd3f162184b7ed5118d258c3cc1"},
"erlex": {:hex, :erlex, "0.2.8", "cd8116f20f3c0afe376d1e8d1f0ae2452337729f68be016ea544a72f767d9c12", [:mix], [], "hexpm", "9d66ff9fedf69e49dc3fd12831e12a8a37b76f8651dd21cd45fcf5561a8a7590"},
"erlydtl": {:git, "https://github.com/erlydtl/erlydtl", "aae414692b6052e96d890e03bbeeeca0f4dc01c2", [tag: "0.15.0"]},
"esip": {:hex, :esip, "1.0.59", "eb202f8c62928193588091dfedbc545fe3274c34ecd209961f86dcb6c9ebce88", [:rebar3], [{:fast_tls, "1.1.25", [hex: :fast_tls, repo: "hexpm", optional: false]}, {:p1_utils, "1.0.28", [hex: :p1_utils, repo: "hexpm", optional: false]}, {:stun, "1.2.21", [hex: :stun, repo: "hexpm", optional: false]}], "hexpm", "0bdf2e3c349dc0b144f173150329e675c6a51ac473d7a0b2e362245faad3fbe6"},
"ex_doc": {:hex, :ex_doc, "0.39.1", "e19d356a1ba1e8f8cfc79ce1c3f83884b6abfcb79329d435d4bbb3e97ccc286e", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "8abf0ed3e3ca87c0847dfc4168ceab5bedfe881692f1b7c45f4a11b232806865"},
"exsync": {:hex, :exsync, "0.4.1", "0a14fe4bfcb80a509d8a0856be3dd070fffe619b9ba90fec13c58b316c176594", [:mix], [{:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm", "cefb22aa805ec97ffc5b75a4e1dc54bcaf781e8b32564bf74abbe5803d1b5178"},
Expand Down Expand Up @@ -34,6 +35,6 @@
"stringprep": {:hex, :stringprep, "1.0.33", "22f42866b4f6f3c238ea2b9cb6241791184ddedbab55e94a025511f46325f3ca", [:rebar3], [{:p1_utils, "1.0.28", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm", "96f8b30bc50887f605b33b46bca1d248c19a879319b8c482790e3b4da5da98c0"},
"stun": {:hex, :stun, "1.2.21", "735855314ad22cb7816b88597d2f5ca22e24aa5e4d6010a0ef3affb33ceed6a5", [:rebar3], [{:fast_tls, "1.1.25", [hex: :fast_tls, repo: "hexpm", optional: false]}, {:p1_utils, "1.0.28", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm", "3d7fe8efb9d05b240a6aa9a6bf8b8b7bff2d802895d170443c588987dc1e12d9"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.1", "a48703a25c170eedadca83b11e88985af08d35f37c6f664d6dcfb106a97782fc", [:rebar3], [], "hexpm", "b3a917854ce3ae233619744ad1e0102e05673136776fb2fa76234f3e03b23642"},
"xmpp": {:git, "https://github.com/processone/xmpp", "7285aa7802bfa90bcefafdad3a342fbb93ce7eea", [ref: "7285aa7802bfa90bcefafdad3a342fbb93ce7eea"]},
"xmpp": {:git, "https://github.com/processone/xmpp", "f96c9adde9841bdeb184740857bddd60d3f51ab7", [tag: "1.11.4"]},
"yconf": {:hex, :yconf, "1.0.22", "52a435f9b60ab1e13950dfe3f7131ecdd8b3d1ca72c44bf66fc74b4571027124", [:rebar3], [{:fast_yaml, "1.0.39", [hex: :fast_yaml, repo: "hexpm", optional: false]}], "hexpm", "aca83457ceabe70756484b5c87ba7b1955f511d499168687eaeaa7c300e857f1"},
}
26 changes: 26 additions & 0 deletions priv/mod_invites/apps.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<div class="container">
<div class="row">
{% for item in apps %}
<div class="card m-3 client-card {% for platform in item.platforms %}app-platform-{{ platform|lower }} {% endfor %} flex-wrap col-sm-12 col-md-8 col-lg-5">
<div class="row no-gutters h-100">
<div class="col-md-4">
<img src="{{ static }}/{{ item.image }}" class="p-2 img-fluid" alt="{{ item.imagetext }}">
</div>
<div class="col-md-8">
<div class="card-body d-flex flex-column h-100">
<h5 class="card-title text-nowrap mb-1">{{ item.name }}</h5>
<div>
{% for platform in item.platforms %}<span class="badge badge-info client-platform-badge client-platform-badge-{{ platform|lower }} mr-1 mb-3">{{ platform }}</span>{% endfor %}
</div>
<p class="card-text">{{ item.text }}</p>
<a href="{{ item.proceed_url }}" class="btn btn-primary mt-md-auto">{% if item.select_text %}{{ item.select_text }}{% else %}{% trans "Select" %}{% endif %}</a>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
<div id="show-all-clients-button-container" class="d-none alert alert-info">
{% trans "Showing apps for <span class='platform-name'>your current platform</span> only. You may also <a href='#' id='show-all-clients-button'>view all apps.</a>" %}
</div>
161 changes: 161 additions & 0 deletions priv/mod_invites/apps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
[
{
"download": {
"buttons": [
{
"image": "{{ static }}/logos/google_ps.png",
"url": "https://play.google.com/store/apps/details?id=eu.siacs.conversations",
"magic_link_format": "https://play.google.com/store/apps/details?id=eu.siacs.conversations&referrer={{ uri }}"
},
{
"image": "{{ static }}/logos/fdroid.png",
"url": "https://f-droid.org/en/packages/eu.siacs.conversations/",
"magic_link_format": "https://f-droid.org/packages/eu.siacs.conversations/"
}
]
},
"image": "logos/conversations.svg",
"link": "https://play.google.com/store/apps/details?id=eu.siacs.conversations",
"magic_link_format": "https://play.google.com/store/apps/details?id=eu.siacs.conversations&referrer={{ uri }}",
"name": "Conversations",
"platforms": [
"Android"
],
"supports_preauth_uri": true,
"text": "{% trans "Conversations is a Jabber/XMPP client for Android 6.0+ smartphones that has been optimized to provide a unique mobile experience." %}"
},
{
"download": {
"buttons": [
{
"image": "{{ static }}/logos/apple_as.svg",
"target": "_blank",
"url": "https://apps.apple.com/app/id317711500"
}
]
},
"image": "logos/monal-tmp.svg",
"link": "https://monal-im.org/",
"name": "Monal",
"platforms": [
"iOS", "iPadOS"
],
"supports_preauth_uri": true,
"text": "{% trans "A modern open-source chat client for iPhone and iPad. It is easy to use and has a clean user interface." %}"
},
{
"download": {
"buttons": [
{
"image": "{{ static }}/logos/apple_as.svg",
"target": "_blank",
"url": "https://apps.apple.com/app/id1637078500"
}
]
},
"image": "logos/monal-tmp.svg",
"link": "https://monal-im.org/",
"name": "Monal (macOS)",
"platforms": [
"macOS"
],
"supports_preauth_uri": true,
"text": "{% trans "A modern open-source chat client for Mac. It is easy to use and has a clean user interface." %}"
},
{
"download": {
"buttons": [
{
"image": "{{ static }}/logos/apple_as.svg",
"target": "_blank",
"url": "https://apps.apple.com/us/app/siskin-im/id1153516838"
}
]
},
"image": "logos/siskin-im.svg",
"link": "https://apps.apple.com/us/app/siskin-im/id1153516838",
"name": "Siskin IM",
"platforms": [
"iOS", "iPadOS"
],
"supports_preauth_uri": true,
"text": "{% trans "A lightweight and powerful XMPP client for iPhone and iPad. It provides an easy way to talk and share moments with your friends." %}"
},
{
"download": {
"buttons": [
{
"target": "_blank",
"text": "{% trans "Download from Mac App Store" %}",
"url": "https://apps.apple.com/us/app/beagle-im/id1445349494"
}
]
},
"image": "logos/beagle-im.svg",
"link": "https://apps.apple.com/us/app/beagle-im/id1445349494",
"name": "Beagle IM",
"platforms": [
"macOS"
],
"setup": {
"text": "{% trans "Launch Beagle IM, and select 'Yes' to add a new account. Click the '+' button under the empty account list and then enter your credentials." %}"
},
"text": "{% trans "Beagle IM by Tigase, Inc. is a lightweight and powerful XMPP client for macOS." %}"
},
{
"download": {
"buttons": [
{
"target": "_blank",
"text": "{% trans "Download Dino for Linux" %}",
"url": "https://dino.im/#download"
}
],
"text": "{% trans "Click the button to open the Dino website where you can download and install it on your PC." %}"
},
"image": "logos/dino.svg",
"link": "https://dino.im/",
"name": "Dino",
"platforms": [
"Linux"
],
"text": "{% trans "A modern open-source chat client for the desktop. It focuses on providing a clean and reliable Jabber/XMPP experience while having your privacy in mind." %}"
},
{
"download": {
"buttons": [
{
"target": "_blank",
"text": "{% trans "Download Gajim" %}",
"url": "https://gajim.org/download/"
}
]
},
"image": "logos/gajim.svg",
"link": "https://gajim.org/",
"name": "Gajim",
"platforms": [
"Windows",
"Linux"
],
"text": "{% trans "A fully-featured desktop chat client for Windows and Linux." %}"
},
{
"download": {
"buttons": [
{
"target": "_blank",
"text": "{% trans "Download Renga for Haiku" %}",
"url": "https://depot.haiku-os.org/#!/pkg/renga?bcguid=bc233-PQIA"
}
]
},
"image": "logos/renga.svg",
"link": "https://pulkomandy.tk/projects/renga",
"name": "Renga",
"platforms": [
"Haiku"
],
"text": "{% trans "XMPP client for Haiku" %}"
}
]
47 changes: 47 additions & 0 deletions priv/mod_invites/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% extends "base_min.html" %}

{% block rel_alternate %}
<link rel="alternate" href="{{ uri }}">
{% endblock %}

{% block qr_button %}
<div id="qr-button-container" class="float-right w-25 border border-info p-3 d-none">
{% trans "<strong>Tip:</strong> You can open this invite on your mobile device by scanning a barcode with your camera." %}
<button id="qr-modal-show" class="mt-2 d-block btn btn-info" title="{% trans "Send this invite to your device" %}"
data-toggle="modal" data-target="#qr-modal">
<img src="{{ static }}/qr-logo.png" alt="{% trans "QR code icon" %}" class="align-middle h-50 mt-1" style="display:inline" >
{% trans "Scan with mobile device" %}
</button>
</div>
{% endblock %}

{% block qr_code %}
<div class="modal" tabindex="-1" role="dialog" id="qr-modal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{% trans "Scan invite code" %}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<p>{% trans "You can transfer this invite to your mobile device by scanning a code with your camera." %}</p>
<div id="qr-info-url" class="tab-pane show active">
<p>{% trans "Use a <em>QR code</em> scanner on your mobile device to scan the code below:" %}</p>
<div id="qr-invite-page" style="width: 304px;" class="bg-white p-4 mx-auto"></div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">{% trans "Close" %}</button>
</div>
</div>
</div>
</div>
{% endblock %}

{% block extra_scripts %}
<script src="{{ static }}/qrcode.min.js"></script>
<script src="{{ static }}/platform.min.js"></script>
<script src="{{ static }}/invite.js"></script>
{% endblock %}
35 changes: 35 additions & 0 deletions priv/mod_invites/base_min.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}{% blocktrans %}Invite to {{ site_name }}{% endblocktrans %}{% endblock %}</title>
{% block rel_alternate %}{% endblock %}
<link rel="stylesheet" href="/share/bootstrap4/css/bootstrap.min.css">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#fbd308">
<meta name="theme-color" content="#fbd308">
</head>
<body>
<div id="background" class="fixed-top overflow-hidden"></div>
<div id="form" class="{% block form_class %}container col-md-10 col-md-offset-1 col-sm-8 col-sm-offset-2 col-lg-10 col-lg-offset-1 mt-2 mt-md-5{% endblock %}">
<div class="card rounded-lg shadow">
<h1 class="card-header rounded-lg rounded-lg">
{%block h1 %}{% blocktrans %}Invite to {{ site_name }}{% endblocktrans %}{% endblock %}<br/>
</h1>
<div class="card-body">
{% block qr_button %}{% endblock %}
{% block content %}{% endblock %}
</div>
</div>
</div>
{% block qr_code %}{% endblock %}
{% block extra_scripts %}{% endblock %}
<script src="/share/jquery/jquery.min.js"></script>
<script src="/share/bootstrap4/js/bootstrap.min.js"></script>
</body>
</html>
70 changes: 70 additions & 0 deletions priv/mod_invites/client.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{% extends "base.html" %}

{% block h1 %}
{% blocktrans with app_name=app.name %}Join {{ site_name }} with {{ app_name }}{% endblocktrans %}
{% endblock %}

{% block content %}
<p>{% if invite.inviter|user %}
{% blocktrans with inviter=invite.inviter|user %}You have been invited to chat with <strong>{{ inviter }}</strong> on {{ site_name }}, part of the XMPP secure and decentralized messaging network.{% endblocktrans %}
{% else %}
{% blocktrans %}You have been invited to chat on {{ site_name }}, part of the XMPP secure and decentralized messaging network.{% endblocktrans %}
{% endif %}
</p>

<p>{% blocktrans with app_name=app.name %}You can start chatting right away with {{ app_name }}. Let's get started!{% endblocktrans %}</p>

<div class="card m-3 client-card {% for item in app.platforms %}app-platform-{{ item|lower }} {% endfor %} flex-wrap col-sm-12 col-md-8 col-lg-5">
<div class="row no-gutters h-100">
<div class="col-md-4">
<img src="{{ static }}/{{ app.image }}" class="p-2 img-fluid" alt="{{ app.imagetext }}">
</div>
<div class="col-md-8 h-100">
<div class="card-body d-flex flex-column h-100">
<h5 class="card-title text-nowrap mb-1">{{ app.name }}</h5>
<div>
{% for item in app.platforms %}<span class="badge badge-info client-platform-badge client-platform-badge-{{ item|lower }} mr-1 mb-3">{{ item }}</span> {% endfor %}
</div>
<p class="card-text">{{ app.text }}</p>
</div>
</div>
</div>
</div>

<h3 style="clear:both">{% blocktrans with app_name=app.name %}Step 1: Install {{ app_name }}{% endblocktrans %}</h3>

<p>{% if app.download.text %}{{ app.download.text }}{% else %}{% blocktrans with app_name=app.name %}Download and install {{ app_name }} below:{% endblocktrans %}{% endif %}</p>

<div class="ml-5">
{% for button in app.download.buttons %}
{% if button.image %}
<a href="{% if button.magic_link %}{{ button.magic_link }}{% else %}{{ button.url }}{% endif %}" {% if button.target %}target="{{ button.target }}"{% endif %} rel="noopener">
<img src="{{ button.image }}" {% if button.alttext %}alt="{{ button.alttext }}"{% endif %} style="max-width: 160px;">
</a>
{% endif %}
{% if button.text %}
<a href="{{ button.url }}" {% if button.target %}target="{{ button.target }}"{% endif %} class="btn btn-primary" rel="noopener">
{{ button.text }}
</a>
{% endif %}
{% endfor %}
</div>

<p class="mt-3">{% blocktrans with app_name=app.name %}After successfully installing {{ app_name }}, come back to this page and <strong>continue with Step 2</strong>.{% endblocktrans %}</p>

<h3>{% trans "Step 2: Activate your account" %}</h3>

<p>{% trans "Installed ok? Great! <strong>Click or tap the button below</strong> to accept your invite and continue with your account setup:" %}</p>

<div>
<a href="{{ uri }}" id="uri-cta" class="btn btn-primary ml-5 mt-1 mb-3">{% blocktrans with app_name=app.name %}Accept invite using {{ app_name }}{% endblocktrans %}</a><br/>
</div>

<p>{% blocktrans with app_name=app.name %}After clicking the button you will be taken to {{ app_name }} to finish setting up your new {{ site_name }} account.{% endblocktrans %}</p>
{% endblock %}

{% block extra_scripts %}
<script src="{{ static }}/qrcode.min.js"></script>
<script src="{{ static }}/platform.min.js"></script>
<script src="{{ static }}/invite.js"></script>
{% endblock %}
Loading
Loading