From 0a8c71360230f0439257d56d77a0755bfc030b06 Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Sun, 19 Jun 2022 01:39:41 -0700 Subject: new line for cookiekey in config-init --- activitypub/actor.go | 10 ++++++++++ activitypub/object.go | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'activitypub') 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") +} -- cgit v1.2.3