summaryrefslogtreecommitdiff
path: root/internal/processing/workers/surfacenotify.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2024-04-11 11:45:53 +0200
committerLibravatar GitHub <noreply@github.com>2024-04-11 11:45:53 +0200
commit9fb8a78f91adffd5f4d28df1270e407c25a7a16e (patch)
treed68200744e28d07e75a52bb0c9f6593c86a38a91 /internal/processing/workers/surfacenotify.go
parent[performance] massively improved ActivityPub delivery worker efficiency (#2812) (diff)
downloadgotosocial-9fb8a78f91adffd5f4d28df1270e407c25a7a16e.tar.xz
[feature] New user sign-up via web page (#2796)
* [feature] User sign-up form and admin notifs * add chosen + filtered languages to migration * remove stray comment * chosen languages schmosen schmanguages * proper error on local account missing
Diffstat (limited to 'internal/processing/workers/surfacenotify.go')
-rw-r--r--internal/processing/workers/surfacenotify.go41
1 files changed, 40 insertions, 1 deletions
diff --git a/internal/processing/workers/surfacenotify.go b/internal/processing/workers/surfacenotify.go
index a8c36248c..9c82712f2 100644
--- a/internal/processing/workers/surfacenotify.go
+++ b/internal/processing/workers/surfacenotify.go
@@ -333,6 +333,45 @@ func (s *surface) notifyPollClose(ctx context.Context, status *gtsmodel.Status)
return errs.Combine()
}
+func (s *surface) notifySignup(ctx context.Context, newUser *gtsmodel.User) error {
+ modAccounts, err := s.state.DB.GetInstanceModerators(ctx)
+ if err != nil {
+ if errors.Is(err, db.ErrNoEntries) {
+ // No registered
+ // mod accounts.
+ return nil
+ }
+
+ // Real error.
+ return gtserror.Newf("error getting instance moderator accounts: %w", err)
+ }
+
+ // Ensure user + account populated.
+ if err := s.state.DB.PopulateUser(ctx, newUser); err != nil {
+ return gtserror.Newf("db error populating new user: %w", err)
+ }
+
+ if err := s.state.DB.PopulateAccount(ctx, newUser.Account); err != nil {
+ return gtserror.Newf("db error populating new user's account: %w", err)
+ }
+
+ // Notify each moderator.
+ var errs gtserror.MultiError
+ for _, mod := range modAccounts {
+ if err := s.notify(ctx,
+ gtsmodel.NotificationSignup,
+ mod,
+ newUser.Account,
+ "",
+ ); err != nil {
+ errs.Appendf("error notifying moderator %s: %w", mod.ID, err)
+ continue
+ }
+ }
+
+ return errs.Combine()
+}
+
// notify creates, inserts, and streams a new
// notification to the target account if it
// doesn't yet exist with the given parameters.
@@ -342,7 +381,7 @@ func (s *surface) notifyPollClose(ctx context.Context, status *gtsmodel.Status)
// targets into this function without filtering
// for non-local first.
//
-// targetAccountID and originAccountID must be
+// targetAccount and originAccount must be
// set, but statusID can be an empty string.
func (s *surface) notify(
ctx context.Context,