Skip to content

Commit b166c7e

Browse files
committed
Fix hermes template and add new mailer
1 parent dfbc564 commit b166c7e

4 files changed

Lines changed: 39 additions & 2 deletions

File tree

api/cmd/experiments/main.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,39 @@
11
package main
22

33
import (
4+
"context"
45
"log"
56

7+
"github.com/NdoleStudio/httpsms/pkg/di"
8+
"github.com/NdoleStudio/httpsms/pkg/entities"
69
"github.com/joho/godotenv"
10+
"github.com/palantir/stacktrace"
711
)
812

913
func main() {
1014
err := godotenv.Load("../../.env")
1115
if err != nil {
1216
log.Fatal("Error loading .env file")
1317
}
18+
19+
container := di.NewLiteContainer()
20+
mailer := container.Mailer()
21+
22+
factory := container.UserEmailFactory()
23+
24+
user := &entities.User{
25+
Email: "arnoldewin@gmail.com",
26+
SubscriptionName: entities.SubscriptionNameUltraMonthly,
27+
}
28+
29+
mail, err := factory.UsageLimitExceeded(user)
30+
if err != nil {
31+
container.Logger().Fatal(stacktrace.Propagate(err, "cannot create email"))
32+
}
33+
34+
if err = mailer.Send(context.Background(), mail); err != nil {
35+
container.Logger().Fatal(stacktrace.Propagate(err, "cannot send email"))
36+
}
37+
38+
container.Logger().Info("email sent")
1439
}

api/pkg/di/container.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ type Container struct {
7575
logger telemetry.Logger
7676
}
7777

78+
// NewLiteContainer creates a Container without any routes or listeners
79+
func NewLiteContainer() (container *Container) {
80+
// Set location to UTC
81+
now.DefaultConfig = &now.Config{
82+
TimeLocation: time.UTC,
83+
}
84+
85+
return &Container{
86+
logger: logger(3).WithService(fmt.Sprintf("%T", container)),
87+
}
88+
}
89+
7890
// NewContainer creates a new dependency injection container
7991
func NewContainer(projectID string, version string) (container *Container) {
8092
// Set location to UTC

api/pkg/emails/hermes_theme.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,11 @@ func (dt *hermesTheme) HTMLTemplate() string {
291291
<td class="email-masthead">
292292
<a class="email-masthead_name" style="color: white;" href="{{.Hermes.Product.Link}}" target="_blank">
293293
{{ if .Hermes.Product.Logo }}
294-
HTTP SMS
294+
<img src="proxy.php?url=https%3A%2F%2Fgithub.com%2FwirelessCharge%2Fhttpsms%2Fcommit%2F%7B%7B.Hermes.Product.Logo+%7C+url+%7D%7D" class="email-logo" />
295295
{{ else }}
296296
{{ .Hermes.Product.Name }}
297297
{{ end }}
298-
</a>
298+
</a>
299299
</td>
300300
</tr>
301301

web/static/logo-bg-none.png

11.7 KB
Loading

0 commit comments

Comments
 (0)