diff options
author | FChannel <> | 2022-06-19 01:39:41 -0700 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | 0a8c71360230f0439257d56d77a0755bfc030b06 (patch) | |
tree | 76e09318aaf71e2e4b90aa538f0ac774b73eb355 | |
parent | 25829d2d0e379c323b8f2ae6e7c2aad7548f0a30 (diff) |
new line for cookiekey in config-init
-rw-r--r-- | activitypub/actor.go | 10 | ||||
-rw-r--r-- | activitypub/object.go | 21 | ||||
-rw-r--r-- | route/util.go | 8 | ||||
-rw-r--r-- | util/key.go | 2 |
4 files changed, 40 insertions, 1 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") +} diff --git a/route/util.go b/route/util.go index 5a7d57c..7a50822 100644 --- a/route/util.go +++ b/route/util.go @@ -172,6 +172,14 @@ func ParseOutboxRequest(ctx *fiber.Ctx, actor activitypub.Actor) error { } }(nObj) + go func(obj activitypub.ObjectBase) { + err := obj.SendEmailNotify() + + if err != nil { + config.Log.Println(err) + } + }(nObj) + var id string op := len(nObj.InReplyTo) - 1 if op >= 0 { diff --git a/util/key.go b/util/key.go index 60eeb43..bd9c07e 100644 --- a/util/key.go +++ b/util/key.go @@ -42,7 +42,7 @@ func GetCookieKey() (string, error) { defer file.Close() config.CookieKey = encryptcookie.GenerateKey() - file.WriteString("cookiekey:" + config.CookieKey) + file.WriteString("\ncookiekey:" + config.CookieKey) } return config.CookieKey, nil |