Skip to content

Send and receive SMS messages using your Android phone programmatically via a simple HTTP API

Fix services

Acho Arnoldd447d42b82d4
diff --git a/api/go.mod b/api/go.mod
index 62be12bd..5ce5aadd 100644
--- a/api/go.mod
+++ b/api/go.mod
@@ -17,6 +17,8 @@ require (
github.com/google/uuid v1.3.0
github.com/hirosassa/zerodriver v0.1.2
github.com/joho/godotenv v1.4.0
+ github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible
+ github.com/matcornic/hermes/v2 v2.1.0
github.com/nyaruka/phonenumbers v1.1.0
github.com/palantir/stacktrace v0.0.0-20161112013806-78658fd2d177
github.com/pkg/errors v0.9.1
@@ -44,8 +46,13 @@ require (
cloud.google.com/go/trace v1.2.0 // indirect
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.32.3 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
+ github.com/Masterminds/semver v1.4.2 // indirect
+ github.com/Masterminds/sprig v2.16.0+incompatible // indirect
+ github.com/PuerkitoBio/goquery v1.5.0 // indirect
github.com/VividCortex/ewma v1.1.1 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
+ github.com/andybalholm/cascadia v1.0.0 // indirect
+ github.com/aokoli/goutils v1.0.1 // indirect
github.com/fatih/color v1.10.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
@@ -60,6 +67,9 @@ require (
github.com/googleapis/enterprise-certificate-proxy v0.1.0 // indirect
github.com/googleapis/gax-go/v2 v2.4.0 // indirect
github.com/googleapis/go-type-adapters v1.0.0 // indirect
+ github.com/gorilla/css v1.0.0 // indirect
+ github.com/huandu/xstrings v1.2.0 // indirect
+ github.com/imdario/mergo v0.3.6 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.12.1 // indirect
github.com/jackc/pgio v1.0.0 // indirect
@@ -68,6 +78,7 @@ require (
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
github.com/jackc/pgtype v1.11.0 // indirect
github.com/jackc/pgx/v4 v4.16.1 // indirect
+ github.com/jaytaylor/html2text v0.0.0-20180606194806-57d518f124b0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.4 // indirect
github.com/josharian/intern v1.0.0 // indirect
@@ -79,11 +90,17 @@ require (
github.com/mattn/go-runewidth v0.0.12 // indirect
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 // indirect
+ github.com/olekukonko/tablewriter v0.0.1 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
+ github.com/russross/blackfriday/v2 v2.0.1 // indirect
+ github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
+ github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
github.com/swaggo/files v0.0.0-20210815190702-a29dd2bc99b2 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.37.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
+ github.com/vanng822/css v0.0.0-20190504095207-a21e860bcd04 // indirect
+ github.com/vanng822/go-premailer v0.0.0-20191214114701-be27abe028fe // indirect
go.opencensus.io v0.23.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
diff --git a/api/go.sum b/api/go.sum
index a079707a..3566eae2 100644
--- a/api/go.sum
+++ b/api/go.sum
@@ -78,9 +78,15 @@ github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapp
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.32.3/go.mod h1:9a+Opaevo9fybhUvQkEG7fR6Zk7pYrW/s9NC4fODFIQ=
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
+github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc=
+github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
+github.com/Masterminds/sprig v2.16.0+incompatible h1:QZbMUPxRQ50EKAq3LFMnxddMu88/EUUG3qmxwtDmPsY=
+github.com/Masterminds/sprig v2.16.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
+github.com/PuerkitoBio/goquery v1.5.0 h1:uGvmFXOA73IKluu/F84Xd1tt/z07GYm8X49XKHP7EJk=
+github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg=
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM=
@@ -90,7 +96,11 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafo
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
+github.com/andybalholm/cascadia v1.0.0 h1:hOCXnnZ5A+3eVDX8pvgl4kofXv2ELss0bKcqRySc45o=
+github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
+github.com/aokoli/goutils v1.0.1 h1:7fpzNGoJ3VA8qcrm++XEE1QUe0mIwNeLa02Nwq7RDkg=
+github.com/aokoli/goutils v1.0.1/go.mod h1:SijmP0QR8LtwsmDs8Yii5Z/S4trXFGFC2oO5g9DP+DQ=
github.com/carlmjohnson/requests v0.22.3 h1:ip16AKXNYuArdw9L5/1mL+mNorlZO5XhkLg617yOumc=
github.com/carlmjohnson/requests v0.22.3/go.mod h1:iTsaX9TdFg2+L4WtZO/HFyDMPEfBnogV3i4A4gjDnvs=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
@@ -146,6 +156,7 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
+github.com/go-gomail/gomail v0.0.0-20160411212932-81ebce5c23df/go.mod h1:GJr+FCSXshIwgHBtLglIg9M2l2kQSi6QjVAngtzI08Y=
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
@@ -257,6 +268,7 @@ github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLe
github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
+github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
@@ -276,13 +288,19 @@ github.com/googleapis/go-type-adapters v1.0.0 h1:9XdMn+d/G57qq1s8dNc5IesGCXHf6V2
github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4=
github.com/googleinterns/cloud-operations-api-mock v0.0.0-20200709193332-a1e58c29bdd3 h1:eHv/jVY/JNop1xg2J9cBb4EzyMpWZoNCP1BslSAIkOI=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
+github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
+github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hirosassa/zerodriver v0.1.2 h1:tOBstLRxuUs8bol1Ho+r3xTs5Y8DKv3dqA7DnA+pjo0=
github.com/hirosassa/zerodriver v0.1.2/go.mod h1:+P2wLNeI1pgxJHbpyi2b6thTlfLjdN3Qptv34GNvXQA=
+github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0=
+github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
+github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28=
+github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
@@ -340,6 +358,8 @@ github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0f
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.2.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.2.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
+github.com/jaytaylor/html2text v0.0.0-20180606194806-57d518f124b0 h1:xqgexXAGQgY3HAjNPSaCqn5Aahbo5TKsmhp8VRfr1iQ=
+github.com/jaytaylor/html2text v0.0.0-20180606194806-57d518f124b0/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.4 h1:tHnRBy1i5F2Dh8BAFxqFzxKqqvezXrL2OW1TnX+Mlas=
@@ -347,6 +367,8 @@ github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/
github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ=
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
+github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible h1:jdpOPRN1zP63Td1hDQbZW73xKmzDvZHzVdNYxhnTMDA=
+github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible/go.mod h1:1c7szIrayyPPB/987hsnvNzLushdWf4o/79s3P08L8A=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
@@ -377,6 +399,8 @@ github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
+github.com/matcornic/hermes/v2 v2.1.0 h1:9TDYFBPFv6mcXanaDmRDEp/RTWj0dTTi+LpFnnnfNWc=
+github.com/matcornic/hermes/v2 v2.1.0/go.mod h1:2+ziJeoyRfaLiATIL8VZ7f9hpzH4oDHqTmn0bhrsgVI=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
@@ -385,6 +409,7 @@ github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
+github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.12 h1:Y41i/hVW3Pgwr8gV+J23B9YEY0zxjptBuCWEaxmAOow=
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
@@ -400,6 +425,8 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWb
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nyaruka/phonenumbers v1.1.0 h1:OvNAOAl4A9a2kNpzziITbUVH4bBBeKHkHl0llPmkxaA=
github.com/nyaruka/phonenumbers v1.1.0/go.mod h1:cGaEsOrLjIL0iKGqJR5Rfywy86dSkbApEpXuM9KySNA=
+github.com/olekukonko/tablewriter v0.0.1 h1:b3iUnf1v+ppJiOfNX4yxxqfWKMQPZR5yoh8urCTFX88=
+github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U=
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs=
@@ -425,18 +452,22 @@ github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OK
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
github.com/rs/zerolog v1.26.1 h1:/ihwxqH+4z8UxyI70wM1z9yCvkWcfz/a3mj48k/Zngc=
github.com/rs/zerolog v1.26.1/go.mod h1:/wSSJWX7lVrsOwlbyTRSOJvqRlc+WjWlfes+CiJ+tmc=
+github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
+github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
+github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf h1:pvbZ0lM0XWPBqUKqFU8cmavspvIl9nulOYwdy6IFRRo=
+github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf/go.mod h1:RJID2RhlZKId02nZ62WenDCkgHFerpIOmW0iT7GKmXM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
@@ -464,6 +495,10 @@ github.com/valyala/fasthttp v1.37.0 h1:7WHCyI7EAkQMVmrfBhWTCOaeROb1aCBiTopx63LkM
github.com/valyala/fasthttp v1.37.0/go.mod h1:t/G+3rLek+CyY9bnIE+YlMRddxVAAGjhxndDB4i4C0I=
github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8=
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
+github.com/vanng822/css v0.0.0-20190504095207-a21e860bcd04 h1:L0rPdfzq43+NV8rfIx2kA4iSSLRj2jN5ijYHoeXRwvQ=
+github.com/vanng822/css v0.0.0-20190504095207-a21e860bcd04/go.mod h1:tcnB1voG49QhCrwq1W0w5hhGasvOg+VQp9i9H1rCM1w=
+github.com/vanng822/go-premailer v0.0.0-20191214114701-be27abe028fe h1:9YnI5plmy+ad6BM+JCLJb2ZV7/TNiE5l7SNKfumYKgc=
+github.com/vanng822/go-premailer v0.0.0-20191214114701-be27abe028fe/go.mod h1:JTFJA/t820uFDoyPpErFQ3rb3amdZoPtxcKervG0OE4=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@@ -506,6 +541,7 @@ go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.13.0 h1:nR6NoDBgAf67s68NhaXbsojM+2gxp3S1hWkHDl27pVU=
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
+golang.org/x/crypto v0.0.0-20181029175232-7e6ffbd03851/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
@@ -559,8 +595,10 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
+golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -645,6 +683,7 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190225065934-cc5685c2db12/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -988,6 +1027,7 @@ gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8X
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
+gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/api/pkg/emails/hermes_mailer.go b/api/pkg/emails/hermes_mailer.go
new file mode 100644
index 00000000..c3adfd2f
--- /dev/null
+++ b/api/pkg/emails/hermes_mailer.go
@@ -0,0 +1,31 @@
+package emails
+
+import (
+ "fmt"
+ "strconv"
+ "time"
+
+ "github.com/matcornic/hermes/v2"
+)
+
+// HermesGeneratorConfig contains details for the generator
+type HermesGeneratorConfig struct {
+ AppURL string
+ AppName string
+ AppLogoURL string
+}
+
+// Generator creates hermes.Hermes from HermesGeneratorConfig
+func (config *HermesGeneratorConfig) Generator() hermes.Hermes {
+ return hermes.Hermes{
+ Theme: newHermesTheme(),
+ Product: hermes.Product{
+ // Appears in header & footer of e-mails
+ Name: fmt.Sprintf("The %s Team", config.AppName),
+ Link: config.AppURL,
+ // Optional product logo
+ Copyright: fmt.Sprintf("© %s %s. All rights reserved.", strconv.Itoa(time.Now().Year()), config.AppName),
+ Logo: config.AppLogoURL,
+ },
+ }
+}
diff --git a/api/pkg/emails/hermes_theme.go b/api/pkg/emails/hermes_theme.go
new file mode 100644
index 00000000..7214c0ef
--- /dev/null
+++ b/api/pkg/emails/hermes_theme.go
@@ -0,0 +1,570 @@
+package emails
+
+import "github.com/matcornic/hermes/v2"
+
+// hermesTheme is the theme by default
+type hermesTheme struct{}
+
+func newHermesTheme() hermes.Theme {
+ return &hermesTheme{}
+}
+
+// Name returns the name of the default theme
+func (dt *hermesTheme) Name() string {
+ return "default"
+}
+
+// HTMLTemplate returns a Golang template that will generate an HTML email.
+func (dt *hermesTheme) HTMLTemplate() string {
+ return `
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <style type="text/css" rel="stylesheet" media="all">
+ /* Base ------------------------------ */
+ *:not(br):not(tr):not(html) {
+ font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+ }
+ body {
+ width: 100% !important;
+ height: 100%;
+ margin: 0;
+ line-height: 1.4;
+ background-color: #F2F4F6;
+ color: #74787E;
+ -webkit-text-size-adjust: none;
+ }
+ a {
+ color: #3869D4;
+ }
+ /* Layout ------------------------------ */
+ .email-wrapper {
+ width: 100%;
+ margin: 0;
+ padding: 0;
+ background-color: #283593;
+ }
+ .email-content {
+ width: 100%;
+ margin: 0;
+ padding: 0;
+ }
+ /* Masthead ----------------------- */
+ .email-masthead {
+ padding: 25px 0;
+ text-align: center;
+ }
+ .email-masthead_logo {
+ max-width: 400px;
+ border: 0;
+ }
+ .email-masthead_name {
+ font-size: 16px;
+ font-weight: bold;
+ color: #2F3133;
+ text-decoration: none;
+ text-shadow: 0 1px 0 white;
+ }
+ .email-logo {
+ max-height: 50px;
+ }
+ /* Body ------------------------------ */
+ .email-body {
+ width: 100%;
+ margin: 0;
+ padding: 0;
+ border-top: 1px solid #EDEFF2;
+ border-bottom: 1px solid #EDEFF2;
+ background-color: #FFF;
+ }
+ .email-body_inner {
+ width: 570px;
+ margin: 0 auto;
+ padding: 0;
+ }
+ .email-footer {
+ width: 570px;
+ margin: 0 auto;
+ padding: 0;
+ text-align: center;
+ }
+ .email-footer p {
+ color: #AEAEAE;
+ }
+ .body-action {
+ width: 100%;
+ margin: 30px auto;
+ padding: 0;
+ text-align: center;
+ }
+ .body-dictionary {
+ width: 100%;
+ overflow: hidden;
+ margin: 20px auto 10px;
+ padding: 0;
+ }
+ .body-dictionary dd {
+ margin: 0 0 10px 0;
+ }
+ .body-dictionary dt {
+ clear: both;
+ color: #000;
+ font-weight: bold;
+ }
+ .body-dictionary dd {
+ margin-left: 0;
+ margin-bottom: 10px;
+ }
+ .body-sub {
+ margin-top: 25px;
+ padding-top: 25px;
+ border-top: 1px solid #EDEFF2;
+ table-layout: fixed;
+ }
+ .body-sub a {
+ word-break: break-all;
+ }
+ .content-cell {
+ padding: 35px;
+ }
+ .align-right {
+ text-align: right;
+ }
+ /* Type ------------------------------ */
+ h1 {
+ margin-top: 0;
+ color: #2F3133;
+ font-size: 19px;
+ font-weight: bold;
+ }
+ h2 {
+ margin-top: 0;
+ color: #2F3133;
+ font-size: 16px;
+ font-weight: bold;
+ }
+ h3 {
+ margin-top: 0;
+ color: #2F3133;
+ font-size: 14px;
+ font-weight: bold;
+ }
+ blockquote {
+ margin: 25px 0;
+ padding-left: 10px;
+ border-left: 10px solid #F0F2F4;
+ }
+ blockquote p {
+ font-size: 1.1rem;
+ color: #999;
+ }
+ blockquote cite {
+ display: block;
+ text-align: right;
+ color: #666;
+ font-size: 1.2rem;
+ }
+ cite {
+ display: block;
+ font-size: 0.925rem;
+ }
+ cite:before {
+ content: "\2014 \0020";
+ }
+ p {
+ margin-top: 0;
+ color: #74787E;
+ font-size: 16px;
+ line-height: 1.5em;
+ }
+ p.sub {
+ font-size: 12px;
+ }
+ p.center {
+ text-align: center;
+ }
+ table {
+ width: 100%;
+ }
+ th {
+ padding: 0px 5px;
+ padding-bottom: 8px;
+ border-bottom: 1px solid #EDEFF2;
+ }
+ th p {
+ margin: 0;
+ color: #9BA2AB;
+ font-size: 12px;
+ }
+ td {
+ padding: 10px 5px;
+ color: #74787E;
+ font-size: 15px;
+ line-height: 18px;
+ }
+ .content {
+ align: center;
+ padding: 0;
+ }
+ /* Data table ------------------------------ */
+ .data-wrapper {
+ width: 100%;
+ margin: 0;
+ padding: 35px 0;
+ }
+ .data-table {
+ width: 100%;
+ margin: 0;
+ }
+ .data-table th {
+ text-align: left;
+ padding: 0px 5px;
+ padding-bottom: 8px;
+ border-bottom: 1px solid #EDEFF2;
+ }
+ .data-table th p {
+ margin: 0;
+ color: #9BA2AB;
+ font-size: 12px;
+ }
+ .data-table td {
+ padding: 10px 5px;
+ color: #74787E;
+ font-size: 15px;
+ line-height: 18px;
+ }
+ /* Invite Code ------------------------------ */
+ .invite-code {
+ display: inline-block;
+ padding-top: 20px;
+ padding-right: 36px;
+ padding-bottom: 16px;
+ padding-left: 36px;
+ border-radius: 3px;
+ font-family: Consolas, monaco, monospace;
+ font-size: 28px;
+ text-align: center;
+ letter-spacing: 8px;
+ color: #555;
+ background-color: #eee;
+ }
+ /* Buttons ------------------------------ */
+ .button {
+ display: inline-block;
+ background-color: #3869D4;
+ border-radius: 3px;
+ color: #ffffff !important;
+ font-size: 15px;
+ line-height: 45px;
+ text-align: center;
+ text-decoration: none;
+ -webkit-text-size-adjust: none;
+ mso-hide: all;
+ }
+ /*Media Queries ------------------------------ */
+ @media only screen and (max-width: 600px) {
+ .email-body_inner,
+ .email-footer {
+ width: 100% !important;
+ }
+ }
+ @media only screen and (max-width: 500px) {
+ .button {
+ width: 100% !important;
+ }
+ }
+ </style>
+</head>
+<body dir="{{.Hermes.TextDirection}}">
+ <table class="email-wrapper" width="100%" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="content">
+ <table class="email-content" width="100%" cellpadding="0" cellspacing="0">
+ <!-- Logo -->
+ <tr>
+ <td class="email-masthead">
+ <a class="email-masthead_name" href="{{.Hermes.Product.Link}}" target="_blank">
+ {{ if .Hermes.Product.Logo }}
+ <img src="{{.Hermes.Product.Logo | url }}" class="email-logo" />
+ {{ else }}
+ {{ .Hermes.Product.Name }}
+ {{ end }}
+ </a>
+ </td>
+ </tr>
+
+ <!-- Email Body -->
+ <tr>
+ <td class="email-body" width="100%">
+ <table class="email-body_inner" align="center" width="570" cellpadding="0" cellspacing="0">
+ <!-- Body content -->
+ <tr>
+ <td class="content-cell">
+ <h1>{{if .Email.Body.Title }}{{ .Email.Body.Title }}{{ else }}{{ .Email.Body.Greeting }} {{ .Email.Body.Name }},{{ end }}</h1>
+ {{ with .Email.Body.Intros }}
+ {{ if gt (len .) 0 }}
+ {{ range $line := . }}
+ <p>{{ $line }}</p>
+ {{ end }}
+ {{ end }}
+ {{ end }}
+ {{ if (ne .Email.Body.FreeMarkdown "") }}
+ {{ .Email.Body.FreeMarkdown.ToHTML }}
+ {{ else }}
+
+ {{ with .Email.Body.Dictionary }}
+ {{ if gt (len .) 0 }}
+ <dl class="body-dictionary">
+ {{ range $entry := . }}
+ <dt>{{ $entry.Key }}:</dt>
+ <dd>{{ $entry.Value }}</dd>
+ {{ end }}
+ </dl>
+ {{ end }}
+ {{ end }}
+
+ <!-- Table -->
+ {{ with .Email.Body.Table }}
+ {{ $data := .Data }}
+ {{ $columns := .Columns }}
+ {{ if gt (len $data) 0 }}
+ <table class="data-wrapper" width="100%" cellpadding="0" cellspacing="0">
+ <tr>
+ <td colspan="2">
+ <table class="data-table" width="100%" cellpadding="0" cellspacing="0">
+ <tr>
+ {{ $col := index $data 0 }}
+ {{ range $entry := $col }}
+ <th
+ {{ with $columns }}
+ {{ $width := index .CustomWidth $entry.Key }}
+ {{ with $width }}
+ width="{{ . }}"
+ {{ end }}
+ {{ $align := index .CustomAlignment $entry.Key }}
+ {{ with $align }}
+ style="text-align:{{ . }}"
+ {{ end }}
+ {{ end }}
+ >
+ <p>{{ $entry.Key }}</p>
+ </th>
+ {{ end }}
+ </tr>
+ {{ range $row := $data }}
+ <tr>
+ {{ range $cell := $row }}
+ <td
+ {{ with $columns }}
+ {{ $align := index .CustomAlignment $cell.Key }}
+ {{ with $align }}
+ style="text-align:{{ . }}"
+ {{ end }}
+ {{ end }}
+ >
+ {{ $cell.Value }}
+ </td>
+ {{ end }}
+ </tr>
+ {{ end }}
+ </table>
+ </td>
+ </tr>
+ </table>
+ {{ end }}
+ {{ end }}
+
+ <!-- Action -->
+ {{ with .Email.Body.Actions }}
+ {{ if gt (len .) 0 }}
+ {{ range $action := . }}
+ <p>{{ $action.Instructions }}</p>
+ {{ $length := len $action.Button.Text }}
+ {{ $width := add (mul $length 9) 20 }}
+ {{if (lt $width 200)}}{{$width = 200}}{{else if (gt $width 570)}}{{$width = 570}}{{else}}{{end}}
+ {{safe "<!--[if mso]>" }}
+ {{ if $action.Button.Text }}
+ <div style="margin: 30px auto;v-text-anchor:middle;text-align:center">
+ <v:roundrect xmlns:v="urn:schemas-microsoft-com:vml"
+ xmlns:w="urn:schemas-microsoft-com:office:word"
+ href="{{ $action.Button.Link }}"
+ style="height:45px;v-text-anchor:middle;width:{{$width}}px;background-color:{{ if $action.Button.Color }}{{ $action.Button.Color }}{{ else }}#3869D4{{ end }};"
+ arcsize="10%"
+ {{ if $action.Button.Color }}strokecolor="{{ $action.Button.Color }}" fillcolor="{{ $action.Button.Color }}"{{ else }}strokecolor="#3869D4" fillcolor="#3869D4"{{ end }}
+ >
+ <w:anchorlock/>
+ <center style="color: {{ if $action.Button.TextColor }}{{ $action.Button.TextColor }}{{else}}#FFFFFF{{ end }};font-size: 15px;text-align: center;font-family:sans-serif;font-weight:bold;">
+ {{ $action.Button.Text }}
+ </center>
+ </v:roundrect>
+ </div>
+ {{ end }}
+ {{ if $action.InviteCode }}
+ <div style="margin-top:30px;margin-bottom:30px">
+ <table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0">
+ <tr>
+ <td align="center">
+ <table align="center" cellpadding="0" cellspacing="0" style="padding:0;text-align:center">
+ <tr>
+ <td style="display:inline-block;border-radius:3px;font-family:Consolas, monaco, monospace;font-size:28px;text-align:center;letter-spacing:8px;color:#555;background-color:#eee;padding:20px">
+ {{ $action.InviteCode }}
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </div>
+ {{ end }}
+ {{safe "<![endif]-->" }}
+ {{safe "<!--[if !mso]><!-- -->"}}
+ <table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0">
+ <tr>
+ <td align="center">
+ <div>
+ {{ if $action.Button.Text }}
+ <a href="{{ $action.Button.Link }}" class="button" style="{{ with $action.Button.Color }}background-color: {{ . }};{{ end }} {{ with $action.Button.TextColor }}color: {{ . }};{{ end }} width: {{$width}}px;" target="_blank">
+ {{ $action.Button.Text }}
+ </a>
+ {{end}}
+ {{ if $action.InviteCode }}
+ <span class="invite-code">{{ $action.InviteCode }}</span>
+ {{end}}
+ </div>
+ </td>
+ </tr>
+ </table>
+ {{safe "<![endif]-->" }}
+ {{ end }}
+ {{ end }}
+ {{ end }}
+
+ {{ end }}
+ {{ with .Email.Body.Outros }}
+ {{ if gt (len .) 0 }}
+ {{ range $line := . }}
+ <p>{{ $line }}</p>
+ {{ end }}
+ {{ end }}
+ {{ end }}
+
+ <p>
+ {{.Email.Body.Signature}},
+ <br />
+ {{.Hermes.Product.Name}}
+ </p>
+
+ {{ if (eq .Email.Body.FreeMarkdown "") }}
+ {{ with .Email.Body.Actions }}
+ <table class="body-sub">
+ <tbody>
+ {{ range $action := . }}
+ {{if $action.Button.Text}}
+ <tr>
+ <td>
+ <p class="sub">{{$.Hermes.Product.TroubleText | replace "{ACTION}" $action.Button.Text}}</p>
+ <p class="sub"><a href="{{ $action.Button.Link }}">{{ $action.Button.Link }}</a></p>
+ </td>
+ </tr>
+ {{ end }}
+ {{ end }}
+ </tbody>
+ </table>
+ {{ end }}
+ {{ end }}
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="email-footer" align="center" width="570" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="content-cell">
+ <p class="sub center">
+ {{.Hermes.Product.Copyright}}
+ </p>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+</body>
+</html>
+`
+}
+
+// PlainTextTemplate returns a Golang template that will generate an plain text email.
+func (dt *hermesTheme) PlainTextTemplate() string {
+ return `<h2>{{if .Email.Body.Title }}{{ .Email.Body.Title }}{{ else }}{{ .Email.Body.Greeting }} {{ .Email.Body.Name }},{{ end }}</h2>
+{{ with .Email.Body.Intros }}
+ {{ range $line := . }}
+ <p>{{ $line }}</p>
+ {{ end }}
+{{ end }}
+{{ if (ne .Email.Body.FreeMarkdown "") }}
+ {{ .Email.Body.FreeMarkdown.ToHTML }}
+{{ else }}
+ {{ with .Email.Body.Dictionary }}
+ <ul>
+ {{ range $entry := . }}
+ <li>{{ $entry.Key }}: {{ $entry.Value }}</li>
+ {{ end }}
+ </ul>
+ {{ end }}
+ {{ with .Email.Body.Table }}
+ {{ $data := .Data }}
+ {{ $columns := .Columns }}
+ {{ if gt (len $data) 0 }}
+ <table class="data-table" width="100%" cellpadding="0" cellspacing="0">
+ <tr>
+ {{ $col := index $data 0 }}
+ {{ range $entry := $col }}
+ <th>{{ $entry.Key }} </th>
+ {{ end }}
+ </tr>
+ {{ range $row := $data }}
+ <tr>
+ {{ range $cell := $row }}
+ <td>
+ {{ $cell.Value }}
+ </td>
+ {{ end }}
+ </tr>
+ {{ end }}
+ </table>
+ {{ end }}
+ {{ end }}
+ {{ with .Email.Body.Actions }}
+ {{ range $action := . }}
+ <p>
+ {{ $action.Instructions }}
+ {{ if $action.InviteCode }}
+ {{ $action.InviteCode }}
+ {{ end }}
+ {{ if $action.Button.Link }}
+ {{ $action.Button.Link }}
+ {{ end }}
+ </p>
+ {{ end }}
+ {{ end }}
+{{ end }}
+{{ with .Email.Body.Outros }}
+ {{ range $line := . }}
+ <p>{{ $line }}<p>
+ {{ end }}
+{{ end }}
+<p>{{.Email.Body.Signature}},<br>{{.Hermes.Product.Name}} - {{.Hermes.Product.Link}}</p>
+
+<p>{{.Hermes.Product.Copyright}}</p>
+`
+}
diff --git a/api/pkg/emails/hermes_user_email_factory.go b/api/pkg/emails/hermes_user_email_factory.go
new file mode 100644
index 00000000..c967ab82
--- /dev/null
+++ b/api/pkg/emails/hermes_user_email_factory.go
@@ -0,0 +1,57 @@
+package emails
+
+import (
+ "fmt"
+ "time"
+
+ "github.com/NdoleStudio/httpsms/pkg/entities"
+ "github.com/matcornic/hermes/v2"
+ "github.com/palantir/stacktrace"
+)
+
+type hermesUserEmailFactory struct {
+ config *HermesGeneratorConfig
+ generator hermes.Hermes
+}
+
+// NewHermesUserEmailFactory creates a new instance of the UserEmailFactory
+func NewHermesUserEmailFactory(config *HermesGeneratorConfig) UserEmailFactory {
+ return &hermesUserEmailFactory{
+ config: config,
+ generator: config.Generator(),
+ }
+}
+
+// PhoneDead is the email sent to a user when their phone is dead
+func (factory *hermesUserEmailFactory) PhoneDead(user *entities.User, lastHeartbeatTimestamp time.Time, owner string) (*Email, error) {
+ email := hermes.Email{
+ Body: hermes.Body{
+ Intros: []string{
+ fmt.Sprintf("We haven't received any heartbeat event from your mobile phone <b>%s</b> since %s.", owner, lastHeartbeatTimestamp.Format(time.RFC822)),
+ fmt.Sprintf("Check if the mobile phone is powered on and if it has stable internet connection."),
+ },
+ Title: "Hello 🤚",
+ Signature: "Cheers",
+ Outros: []string{
+ fmt.Sprintf("Don't hesitate to contact us by replying to this email."),
+ },
+ },
+ }
+
+ html, err := factory.generator.GenerateHTML(email)
+ if err != nil {
+ return nil, stacktrace.Propagate(err, "cannot generate html email")
+ }
+
+ text, err := factory.generator.GeneratePlainText(email)
+ if err != nil {
+ return nil, stacktrace.Propagate(err, "cannot generate text email")
+ }
+
+ return &Email{
+ ToEmail: user.Email,
+ Subject: fmt.Sprintf("⚠ No heartbeat from android phone [%s]", owner),
+ HTML: html,
+ Text: text,
+ }, nil
+}
diff --git a/api/pkg/emails/mailer.go b/api/pkg/emails/mailer.go
new file mode 100644
index 00000000..ae70dd57
--- /dev/null
+++ b/api/pkg/emails/mailer.go
@@ -0,0 +1,29 @@
+package emails
+
+import (
+ "context"
+ "fmt"
+ "strings"
+)
+
+// Email represents an email message
+type Email struct {
+ ToName string
+ ToEmail string
+ Subject string
+ HTML string
+ Text string
+}
+
+func (mail *Email) toAddress() string {
+ if strings.TrimSpace(mail.ToName) != "" {
+ return fmt.Sprintf("%s <%s>", mail.ToName, mail.ToEmail)
+ }
+ return mail.ToEmail
+}
+
+// Mailer is used for sending emails
+type Mailer interface {
+ // Send adds a message to the push queue
+ Send(ctx context.Context, mail *Email) error
+}
diff --git a/api/pkg/emails/smtp_mailer_service.go b/api/pkg/emails/smtp_mailer_service.go
new file mode 100644
index 00000000..bebea4a0
--- /dev/null
+++ b/api/pkg/emails/smtp_mailer_service.go
@@ -0,0 +1,58 @@
+package emails
+
+import (
+ "context"
+ "fmt"
+ "net/smtp"
+
+ "github.com/NdoleStudio/httpsms/pkg/telemetry"
+ mail "github.com/jordan-wright/email"
+ "github.com/palantir/stacktrace"
+)
+
+// SMTPConfig is the config for setting up the smtpMailer
+type SMTPConfig struct {
+ FromName string
+ FromEmail string
+ Username string
+ Password string
+ Hostname string
+ Port string
+}
+
+type smtpMailer struct {
+ address string
+ from string
+ tracer telemetry.Tracer
+ auth smtp.Auth
+}
+
+// NewSMTPEmailService creates a new instance of the smtpMailer
+func NewSMTPEmailService(tracer telemetry.Tracer, config SMTPConfig) Mailer {
+ return &smtpMailer{
+ tracer: tracer,
+ auth: smtp.PlainAuth("", config.Username, config.Password, config.Hostname),
+ address: fmt.Sprintf("%s:%s", config.Hostname, config.Port),
+ from: fmt.Sprintf("%s <%s>", config.FromName, config.FromEmail),
+ }
+}
+
+// Send a new email
+func (mailer *smtpMailer) Send(ctx context.Context, email *Email) (err error) {
+ ctx, span := mailer.tracer.Start(ctx)
+ defer span.End()
+
+ e := mail.NewEmail()
+ e.From = mailer.from
+ e.To = []string{email.toAddress()}
+ e.Subject = email.Subject
+ e.Text = []byte(email.Text)
+ e.HTML = []byte(email.HTML)
+
+ err = e.Send(mailer.address, mailer.auth)
+ if err != nil {
+ return stacktrace.Propagate(err, "cannot send email")
+ }
+
+ return nil
+}
diff --git a/api/pkg/emails/user_email.go b/api/pkg/emails/user_email.go
new file mode 100644
index 00000000..d05595f5
--- /dev/null
+++ b/api/pkg/emails/user_email.go
@@ -0,0 +1 @@
+package emails
diff --git a/api/pkg/emails/user_email_factory.go b/api/pkg/emails/user_email_factory.go
new file mode 100644
index 00000000..5a058822
--- /dev/null
+++ b/api/pkg/emails/user_email_factory.go
@@ -0,0 +1,13 @@
+package emails
+
+import (
+ "time"
+
+ "github.com/NdoleStudio/httpsms/pkg/entities"
+)
+
+// UserEmailFactory generates emails to a user
+type UserEmailFactory interface {
+ // PhoneDead sends an emails when the user's phone is not sending heartbeats
+ PhoneDead(user *entities.User, lastHeartbeatTimestamp time.Time, owner string) (*Email, error)
+}
diff --git a/api/pkg/entities/user.go b/api/pkg/entities/user.go
index 4225ad0a..5721e01d 100644
--- a/api/pkg/entities/user.go
+++ b/api/pkg/entities/user.go
@@ -11,11 +11,10 @@ type UserID string
// User stores information about a user
type User struct {
- ID UserID `json:"id" gorm:"primaryKey;type:string;" example:"WB7DRDWrJZRGbYrv2CKGkqbzvqdC"`
- Email string `json:"email" example:"[email protected]"` // gorm:"uniqueIndex"
- APIKey string `json:"api_key" example:"xyz"` // gorm:"uniqueIndex"
- ActivePhoneID *uuid.UUID `json:"active_phone_id" gorm:"type:uuid;" example:"32343a19-da5e-4b1b-a767-3298a73703cb"`
- NotificationEmail *string `json:"notification_email" example:"[email protected]"`
- CreatedAt time.Time `json:"created_at" example:"2022-06-05T14:26:02.302718+03:00"`
- UpdatedAt time.Time `json:"updated_at" example:"2022-06-05T14:26:10.303278+03:00"`
+ ID UserID `json:"id" gorm:"primaryKey;type:string;" example:"WB7DRDWrJZRGbYrv2CKGkqbzvqdC"`
+ Email string `json:"email" example:"[email protected]"` // gorm:"uniqueIndex"
+ APIKey string `json:"api_key" example:"xyz"` // gorm:"uniqueIndex"
+ ActivePhoneID *uuid.UUID `json:"active_phone_id" gorm:"type:uuid;" example:"32343a19-da5e-4b1b-a767-3298a73703cb"`
+ CreatedAt time.Time `json:"created_at" example:"2022-06-05T14:26:02.302718+03:00"`
+ UpdatedAt time.Time `json:"updated_at" example:"2022-06-05T14:26:10.303278+03:00"`
}
diff --git a/api/pkg/events/phone_heartbeat_dead_event.go b/api/pkg/events/phone_heartbeat_dead_event.go
index 0462870d..bd6989aa 100644
--- a/api/pkg/events/phone_heartbeat_dead_event.go
+++ b/api/pkg/events/phone_heartbeat_dead_event.go
@@ -12,9 +12,10 @@ const EventTypePhoneHeartbeatDead = "phone.heartbeat.dead"
// PhoneHeartbeatDeadPayload is the payload of the EventTypePhoneHeartbeatDead event
type PhoneHeartbeatDeadPayload struct {
- PhoneID uuid.UUID `json:"phone_id"`
- UserID entities.UserID `json:"user_id"`
- Timestamp time.Time `json:"timestamp"`
- MonitorID uuid.UUID `json:"monitor_id"`
- Owner string `json:"owner"`
+ PhoneID uuid.UUID `json:"phone_id"`
+ UserID entities.UserID `json:"user_id"`
+ LastHeartbeatTimestamp time.Time `json:"last_heartbeat_timestamp"`
+ Timestamp time.Time `json:"timestamp"`
+ MonitorID uuid.UUID `json:"monitor_id"`
+ Owner string `json:"owner"`
}
diff --git a/api/pkg/listeners/user_listener.go b/api/pkg/listeners/user_listener.go
new file mode 100644
index 00000000..3e89b9fb
--- /dev/null
+++ b/api/pkg/listeners/user_listener.go
@@ -0,0 +1,64 @@
+package listeners
+
+import (
+ "context"
+ "fmt"
+
+ "github.com/davecgh/go-spew/spew"
+
+ "github.com/NdoleStudio/httpsms/pkg/events"
+ "github.com/NdoleStudio/httpsms/pkg/services"
+ "github.com/NdoleStudio/httpsms/pkg/telemetry"
+ cloudevents "github.com/cloudevents/sdk-go/v2"
+ "github.com/palantir/stacktrace"
+)
+
+// UserListener handles cloud events which sends notifications
+type UserListener struct {
+ logger telemetry.Logger
+ tracer telemetry.Tracer
+ service *services.UserService
+}
+
+// NewUserListener creates a new instance of UserListener
+func NewUserListener(
+ logger telemetry.Logger,
+ tracer telemetry.Tracer,
+ service *services.UserService,
+) (l *UserListener, routes map[string]events.EventListener) {
+ l = &UserListener{
+ logger: logger.WithService(fmt.Sprintf("%T", l)),
+ tracer: tracer,
+ service: service,
+ }
+
+ return l, map[string]events.EventListener{
+ events.EventTypePhoneHeartbeatDead: l.onPhoneHeartbeatDead,
+ }
+}
+
+// onPhoneHeartbeatDead handles the events.EventTypePhoneHeartbeatDead event
+func (listener *UserListener) onPhoneHeartbeatDead(ctx context.Context, event cloudevents.Event) error {
+ ctx, span := listener.tracer.Start(ctx)
+ defer span.End()
+
+ var payload events.PhoneHeartbeatDeadPayload
+ if err := event.DataAs(&payload); err != nil {
+ msg := fmt.Sprintf("cannot decode [%s] into [%T]", event.Data(), payload)
+ return listener.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
+ }
+
+ sendParams := &services.UserSendPhoneDeadEmailParams{
+ UserID: payload.UserID,
+ PhoneID: payload.PhoneID,
+ Owner: payload.Owner,
+ LastHeartbeatTimestamp: payload.LastHeartbeatTimestamp,
+ }
+
+ if err := listener.service.SendPhoneDeadEmail(ctx, sendParams); err != nil {
+ msg := fmt.Sprintf("cannot send notification with params [%s] for event with ID [%s]", spew.Sdump(sendParams), event.ID())
+ return listener.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
+ }
+
+ return nil
+}
diff --git a/api/pkg/services/heartbeat_service.go b/api/pkg/services/heartbeat_service.go
index 9b53f2ec..b89f6229 100644
--- a/api/pkg/services/heartbeat_service.go
+++ b/api/pkg/services/heartbeat_service.go
@@ -185,7 +185,8 @@ func (service *HeartbeatService) Monitor(ctx context.Context, params *HeartbeatM
exists, err := service.monitorRepository.Exists(ctx, params.UserID, params.Owner)
if err != nil {
msg := fmt.Sprintf("cannot check if monitor exists with userID [%s] and owner [%s]", params.UserID, params.Owner)
- return service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
+ ctxLogger.Error(stacktrace.Propagate(err, msg))
+ return service.scheduleHeartbeatCheck(ctx, time.Now().UTC(), params)
}
if !exists {
@@ -197,19 +198,18 @@ func (service *HeartbeatService) Monitor(ctx context.Context, params *HeartbeatM
if err != nil {
msg := fmt.Sprintf("cannot fetch last heartbeat for userID [%s] and owner [%s]", params.UserID, params.Owner)
ctxLogger.Error(stacktrace.Propagate(err, msg))
- return service.handleFailedMonitor(ctx, params, false)
+ return service.scheduleHeartbeatCheck(ctx, time.Now().UTC(), params)
}
if time.Now().UTC().Sub(heartbeat.Timestamp) > heartbeatCheckInterval &&
time.Now().UTC().Sub(heartbeat.Timestamp) < (heartbeatCheckInterval*2) {
- ctxLogger.Error(stacktrace.NewError(fmt.Sprintf("last heartbeat was at [%s] which is more than [%s]", heartbeat.Timestamp, heartbeatCheckInterval)))
- return service.handleFailedMonitor(ctx, params, true)
+ return service.handleFailedMonitor(ctx, heartbeat.Timestamp, params)
}
return service.scheduleHeartbeatCheck(ctx, heartbeat.Timestamp, params)
}
-func (service *HeartbeatService) handleFailedMonitor(ctx context.Context, params *HeartbeatMonitorParams, raiseEvent bool) error {
+func (service *HeartbeatService) handleFailedMonitor(ctx context.Context, lastTimestamp time.Time, params *HeartbeatMonitorParams) error {
ctx, span := service.tracer.Start(ctx)
defer span.End()
@@ -219,16 +219,13 @@ func (service *HeartbeatService) handleFailedMonitor(ctx context.Context, params
return service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
}
- if !raiseEvent {
- return nil
- }
-
event, err := service.createPhoneHeartbeatDeadEvent(params.Source, &events.PhoneHeartbeatDeadPayload{
- PhoneID: params.PhoneID,
- UserID: params.UserID,
- MonitorID: params.MonitorID,
- Timestamp: time.Now().UTC(),
- Owner: params.Owner,
+ PhoneID: params.PhoneID,
+ UserID: params.UserID,
+ MonitorID: params.MonitorID,
+ LastHeartbeatTimestamp: lastTimestamp,
+ Timestamp: time.Now().UTC(),
+ Owner: params.Owner,
})
if err != nil {
msg := fmt.Sprintf("cannot create event when phone monitor failed")
diff --git a/api/pkg/services/user_service.go b/api/pkg/services/user_service.go
index 26e203f1..178e9505 100644
--- a/api/pkg/services/user_service.go
+++ b/api/pkg/services/user_service.go
@@ -3,6 +3,9 @@ package services
import (
"context"
"fmt"
+ "time"
+
+ "github.com/NdoleStudio/httpsms/pkg/emails"
"github.com/NdoleStudio/httpsms/pkg/repositories"
"github.com/google/uuid"
@@ -14,9 +17,11 @@ import (
// UserService is handles user requests
type UserService struct {
- logger telemetry.Logger
- tracer telemetry.Tracer
- repository repositories.UserRepository
+ logger telemetry.Logger
+ tracer telemetry.Tracer
+ emailFactory emails.UserEmailFactory
+ mailer emails.Mailer
+ repository repositories.UserRepository
}
// NewUserService creates a new UserService
@@ -24,11 +29,15 @@ func NewUserService(
logger telemetry.Logger,
tracer telemetry.Tracer,
repository repositories.UserRepository,
+ mailer emails.Mailer,
+ emailFactory emails.UserEmailFactory,
) (s *UserService) {
return &UserService{
- logger: logger.WithService(fmt.Sprintf("%T", s)),
- tracer: tracer,
- repository: repository,
+ logger: logger.WithService(fmt.Sprintf("%T", s)),
+ tracer: tracer,
+ mailer: mailer,
+ emailFactory: emailFactory,
+ repository: repository,
}
}
@@ -74,3 +83,39 @@ func (service *UserService) Update(ctx context.Context, authUser entities.AuthUs
ctxLogger.Info(fmt.Sprintf("user saved with id [%s] in the userRepository", user.ID))
return user, nil
}
+
+// UserSendPhoneDeadEmailParams are parameters for notifying a user when a phone is dead
+type UserSendPhoneDeadEmailParams struct {
+ UserID entities.UserID
+ PhoneID uuid.UUID
+ Owner string
+ LastHeartbeatTimestamp time.Time
+}
+
+// SendPhoneDeadEmail sends an email to an entities.User when a phone is dead
+func (service *UserService) SendPhoneDeadEmail(ctx context.Context, params *UserSendPhoneDeadEmailParams) error {
+ ctx, span := service.tracer.Start(ctx)
+ defer span.End()
+
+ ctxLogger := service.tracer.CtxLogger(service.logger, span)
+
+ user, err := service.repository.Load(ctx, params.UserID)
+ if err != nil {
+ msg := fmt.Sprintf("could not get [%T] with ID [%s]", user, params.UserID)
+ return service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
+ }
+
+ email, err := service.emailFactory.PhoneDead(user, params.LastHeartbeatTimestamp, params.Owner)
+ if err != nil {
+ msg := fmt.Sprintf("cannot create phone dead email for user [%s]", params.UserID)
+ return service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
+ }
+
+ if err = service.mailer.Send(ctx, email); err != nil {
+ msg := fmt.Sprintf("canot send phone dead notification to user [%s]", params.UserID)
+ return service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
+ }
+
+ ctxLogger.Info(fmt.Sprintf("phone dead notification sent successfully to [%s] about [%s]", user.Email, params.Owner))
+ return nil
+}