aboutsummaryrefslogtreecommitdiff
path: root/activitypub
diff options
context:
space:
mode:
Diffstat (limited to 'activitypub')
-rw-r--r--activitypub/actor.go10
-rw-r--r--activitypub/object.go21
2 files changed, 31 insertions, 0 deletions
diff --git a/activitypub/actor.go b/activitypub/actor.go
index 4142685..540d159 100644
--- a/activitypub/actor.go
+++ b/activitypub/actor.go
@@ -1221,6 +1221,16 @@ func (actor Actor) ProcessInboxCreate(activity Activity) error {
if err := actor.ArchivePosts(); err != nil {
return util.MakeError(err, "ActorInbox")
}
+
+ activity.Object.Actor = actor.Id
+
+ go func(obj ObjectBase) {
+ err := obj.SendEmailNotify()
+
+ if err != nil {
+ config.Log.Println(err)
+ }
+ }(activity.Object)
}
}
diff --git a/activitypub/object.go b/activitypub/object.go
index acbe4a1..9e6a97b 100644
--- a/activitypub/object.go
+++ b/activitypub/object.go
@@ -3,6 +3,7 @@ package activitypub
import (
"database/sql"
"fmt"
+ "net/smtp"
"os"
"os/exec"
"regexp"
@@ -1460,3 +1461,23 @@ func (obj ObjectBase) IsLocked() (bool, error) {
return false, nil
}
+
+func (obj ObjectBase) SendEmailNotify() error {
+ actor, _ := GetActorFromDB(obj.Actor)
+
+ from := config.SiteEmail
+ pass := config.SiteEmailPassword
+ to := ""
+ body := fmt.Sprintf("New post: %s", config.Domain+"/"+actor.Name+"/"+util.ShortURL(actor.Outbox, obj.Id))
+
+ msg := "From: " + from + "\n" +
+ "To: " + to + "\n" +
+ "Subject: Image Board Post\n\n" +
+ body
+
+ err := smtp.SendMail(config.SiteEmailServer+":"+config.SiteEmailPort,
+ smtp.PlainAuth("", from, pass, config.SiteEmailServer),
+ from, []string{to}, []byte(msg))
+
+ return util.MakeError(err, "SendEmailNotify")
+}