1 |
|
%%%------------------------------------------------------------------- |
2 |
|
%%% @author Rafal Slota |
3 |
|
%%% @copyright (C) 2017 Erlang Solutions Ltd. |
4 |
|
%%% This software is released under the Apache License, Version 2.0 |
5 |
|
%%% cited in 'LICENSE.txt'. |
6 |
|
%%% @end |
7 |
|
%%%------------------------------------------------------------------- |
8 |
|
%%% @doc |
9 |
|
%%% Plugin module defining default custom behaviour for AWS SNS notifications. |
10 |
|
%%% @end |
11 |
|
%%%------------------------------------------------------------------- |
12 |
|
-module(mod_event_pusher_sns_defaults). |
13 |
|
-author("Rafal Slota"). |
14 |
|
|
15 |
|
-behavior(mod_event_pusher_sns). |
16 |
|
|
17 |
|
-include("jlib.hrl"). |
18 |
|
|
19 |
|
%%%=================================================================== |
20 |
|
%%% Exports |
21 |
|
%%%=================================================================== |
22 |
|
|
23 |
|
%% Callbacks |
24 |
|
-export([user_guid/1, message_attributes/3, message_attributes/5]). |
25 |
|
|
26 |
|
%% ------------------------------------------------------------------- |
27 |
|
%% @doc Returns user's GUID for SNS notification based on his JID. |
28 |
|
%% ------------------------------------------------------------------- |
29 |
|
-spec user_guid(UserJID :: jid:jid()) -> mod_event_pusher_sns:user_guid(). |
30 |
|
user_guid(#jid{} = UserJID) -> |
31 |
26 |
jid:to_binary(jid:to_lower(jid:to_bare(UserJID))). |
32 |
|
|
33 |
|
%% ------------------------------------------------------------------- |
34 |
|
%% @doc Returns SNS Message Attributes for presence change notification. |
35 |
|
%% ------------------------------------------------------------------- |
36 |
|
-spec message_attributes(TopicARN :: mod_event_pusher_sns:topic_arn(), UserJID :: jid:jid(), |
37 |
|
IsOnline :: boolean()) -> mod_event_pusher_sns:attributes(). |
38 |
|
message_attributes(_TopicARN, _UserJID, _IsOnline) -> |
39 |
18 |
#{}. |
40 |
|
|
41 |
|
%% ------------------------------------------------------------------- |
42 |
|
%% @doc Returns SNS Message Attributes for message notification. |
43 |
|
%% ------------------------------------------------------------------- |
44 |
|
-spec message_attributes(TopicARN :: mod_event_pusher_sns:topic_arn(), From :: jid:jid(), |
45 |
|
To :: jid:jid(), MessageType :: pm | muc, Packet :: exml:element()) -> |
46 |
|
mod_event_pusher_sns:attributes(). |
47 |
|
message_attributes(_TopicARN, _From, _To, _MessageType, _Packet) -> |
48 |
4 |
#{}. |