appview/{notify,strings}: notify on string create/edit/delete ops #572

merged
opened by anirudh.fi targeting master from push-zwoymssunvsp

Signed-off-by: Anirudh Oppiliappan did:plc:hwevmowznbiukdf6uk5dwrrq

Changed files
+34
appview
+18
appview/notify/merged_notifier.go
···
notifier.UpdateProfile(ctx, profile)
}
}
+
+
func (m *mergedNotifier) NewString(ctx context.Context, string *db.String) {
+
for _, notifier := range m.notifiers {
+
notifier.NewString(ctx, string)
+
}
+
}
+
+
func (m *mergedNotifier) EditString(ctx context.Context, string *db.String) {
+
for _, notifier := range m.notifiers {
+
notifier.EditString(ctx, string)
+
}
+
}
+
+
func (m *mergedNotifier) DeleteString(ctx context.Context, did, rkey string) {
+
for _, notifier := range m.notifiers {
+
notifier.DeleteString(ctx, did, rkey)
+
}
+
}
+8
appview/notify/notifier.go
···
NewPullComment(ctx context.Context, comment *db.PullComment)
UpdateProfile(ctx context.Context, profile *db.Profile)
+
+
NewString(ctx context.Context, s *db.String)
+
EditString(ctx context.Context, s *db.String)
+
DeleteString(ctx context.Context, did, rkey string)
}
// BaseNotifier is a listener that does nothing
···
func (m *BaseNotifier) NewPullComment(ctx context.Context, comment *db.PullComment) {}
func (m *BaseNotifier) UpdateProfile(ctx context.Context, profile *db.Profile) {}
+
+
func (m *BaseNotifier) NewString(ctx context.Context, s *db.String) {}
+
func (m *BaseNotifier) EditString(ctx context.Context, s *db.String) {}
+
func (m *BaseNotifier) DeleteString(ctx context.Context, did, rkey string) {}
+8
appview/strings/strings.go
···
"tangled.sh/tangled.sh/core/appview/config"
"tangled.sh/tangled.sh/core/appview/db"
"tangled.sh/tangled.sh/core/appview/middleware"
+
"tangled.sh/tangled.sh/core/appview/notify"
"tangled.sh/tangled.sh/core/appview/oauth"
"tangled.sh/tangled.sh/core/appview/pages"
"tangled.sh/tangled.sh/core/appview/pages/markup"
···
IdResolver *idresolver.Resolver
Logger *slog.Logger
Knotstream *eventconsumer.Consumer
+
Notifier notify.Notifier
}
func (s *Strings) Router(mw *middleware.Middleware) http.Handler {
···
return
}
+
s.Notifier.EditString(r.Context(), &entry)
+
// if that went okay, redir to the string
s.Pages.HxRedirect(w, "/strings/"+user.Handle+"/"+entry.Rkey)
}
···
return
}
+
s.Notifier.NewString(r.Context(), &string)
+
// successful
s.Pages.HxRedirect(w, "/strings/"+user.Handle+"/"+string.Rkey)
}
···
return
}
+
s.Notifier.DeleteString(r.Context(), user.Did, rkey)
+
s.Pages.HxRedirect(w, "/strings/"+user.Handle)
}