aboutsummaryrefslogtreecommitdiffstats
path: root/docs/dist/doc/README-164.adoc
diff options
context:
space:
mode:
Diffstat (limited to 'docs/dist/doc/README-164.adoc')
-rw-r--r--docs/dist/doc/README-164.adoc12
1 files changed, 4 insertions, 8 deletions
diff --git a/docs/dist/doc/README-164.adoc b/docs/dist/doc/README-164.adoc
index dd5deea5a..b1de0e9b0 100644
--- a/docs/dist/doc/README-164.adoc
+++ b/docs/dist/doc/README-164.adoc
@@ -9,8 +9,7 @@
'''''
-[#compilation]##
-
+[[compilation]]
=== Compilation times
In AspectJ 1.6.4 the goal was to improve the IDE experience, through a
@@ -122,8 +121,7 @@ http://andrewclement.blogspot.com/2009/02/aspectj-fixing-reverse-cascade-errors.
'''''
-[#language]##
-
+[[language]]
=== Language Enhancements
*Optimizing support for maintaining per join point state*
@@ -214,8 +212,7 @@ deprecated.
'''''
-[#bugsfixed]##
-
+[[bugsfixed]]
=== Bugs fixed
The complete list of issues resolved for AspectJ 1.6.4 (more than 70)
@@ -226,8 +223,7 @@ resolved]
'''''
-[#whatsnext]##
-
+[[whatsnext]]
=== What's next?
*More incremental build enhancements*
88 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package private

import (
	"context"
	"fmt"
	"io"
	"net/http"

	"code.gitea.io/gitea/modules/json"
	"code.gitea.io/gitea/modules/setting"
)

// Email structure holds a data for sending general emails
type Email struct {
	Subject string
	Message string
	To      []string
}

// SendEmail calls the internal SendEmail function
//
// It accepts a list of usernames.
// If DB contains these users it will send the email to them.
//
// If to list == nil its supposed to send an email to every
// user present in DB
func SendEmail(ctx context.Context, subject, message string, to []string) (int, string) {
	reqURL := setting.LocalURL + "api/internal/mail/send"

	req := newInternalRequest(ctx, reqURL, "POST")
	req = req.Header("Content-Type", "application/json")
	jsonBytes, _ := json.Marshal(Email{
		Subject: subject,
		Message: message,
		To:      to,
	})
	req.Body(jsonBytes)
	resp, err := req.Response()
	if err != nil {
		return http.StatusInternalServerError, fmt.Sprintf("Unable to contact gitea: %v", err.Error())
	}
	defer resp.Body.Close()

	body, err := io.ReadAll(resp.Body)
	if err != nil {
		return http.StatusInternalServerError, fmt.Sprintf("Response body error: %v", err.Error())
	}

	users := fmt.Sprintf("%d", len(to))
	if len(to) == 0 {
		users = "all"
	}

	return http.StatusOK, fmt.Sprintf("Sent %s email(s) to %s users", body, users)
}