summaryrefslogtreecommitdiff
path: root/internal/processing/admin/report.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-03-19 13:11:46 +0100
committerLibravatar GitHub <noreply@github.com>2023-03-19 13:11:46 +0100
commit7db81cde444f6bc95e79527af0997de1788d48c7 (patch)
treef6c077ec298a4f018d0870798bc46bd64ba70069 /internal/processing/admin/report.go
parent[docs] Update docs on how to login (#1626) (diff)
downloadgotosocial-7db81cde444f6bc95e79527af0997de1788d48c7.tar.xz
[feature] Email notifications for new / closed moderation reports (#1628)
* start fiddling about with email sending to allow multiple recipients * do some fiddling * notifs working * notify on closed report * finishing up * envparsing * use strings.ContainsAny
Diffstat (limited to 'internal/processing/admin/report.go')
-rw-r--r--internal/processing/admin/report.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/internal/processing/admin/report.go b/internal/processing/admin/report.go
index 3a5435d9e..174bd3c24 100644
--- a/internal/processing/admin/report.go
+++ b/internal/processing/admin/report.go
@@ -23,10 +23,12 @@ import (
"strconv"
"time"
+ "github.com/superseriousbusiness/gotosocial/internal/ap"
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/messages"
"github.com/superseriousbusiness/gotosocial/internal/util"
)
@@ -110,7 +112,10 @@ func (p *Processor) ReportGet(ctx context.Context, account *gtsmodel.Account, id
return apimodelReport, nil
}
-// ReportResolve marks a report with the given id as resolved, and stores the provided actionTakenComment (if not null).
+// ReportResolve marks a report with the given id as resolved,
+// and stores the provided actionTakenComment (if not null).
+// If the report creator is from this instance, an email will
+// be sent to them to let them know that the report is resolved.
func (p *Processor) ReportResolve(ctx context.Context, account *gtsmodel.Account, id string, actionTakenComment *string) (*apimodel.AdminReport, gtserror.WithCode) {
report, err := p.state.DB.GetReportByID(ctx, id)
if err != nil {
@@ -138,6 +143,15 @@ func (p *Processor) ReportResolve(ctx context.Context, account *gtsmodel.Account
return nil, gtserror.NewErrorInternalError(err)
}
+ // Process side effects of closing the report.
+ p.state.Workers.EnqueueClientAPI(ctx, messages.FromClientAPI{
+ APObjectType: ap.ActivityFlag,
+ APActivityType: ap.ActivityUpdate,
+ GTSModel: report,
+ OriginAccount: account,
+ TargetAccount: report.Account,
+ })
+
apimodelReport, err := p.tc.ReportToAdminAPIReport(ctx, updatedReport, account)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)