forked from tangled.org/core
this repo has no description

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

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

authored by anirudh.fi and committed by Tangled ab00c35e 04e7c6ff

Changed files
+34
appview
+18
appview/notify/merged_notifier.go
··· 66 notifier.UpdateProfile(ctx, profile) 67 } 68 }
··· 66 notifier.UpdateProfile(ctx, profile) 67 } 68 } 69 + 70 + func (m *mergedNotifier) NewString(ctx context.Context, string *db.String) { 71 + for _, notifier := range m.notifiers { 72 + notifier.NewString(ctx, string) 73 + } 74 + } 75 + 76 + func (m *mergedNotifier) EditString(ctx context.Context, string *db.String) { 77 + for _, notifier := range m.notifiers { 78 + notifier.EditString(ctx, string) 79 + } 80 + } 81 + 82 + func (m *mergedNotifier) DeleteString(ctx context.Context, did, rkey string) { 83 + for _, notifier := range m.notifiers { 84 + notifier.DeleteString(ctx, did, rkey) 85 + } 86 + }
+8
appview/notify/notifier.go
··· 21 NewPullComment(ctx context.Context, comment *db.PullComment) 22 23 UpdateProfile(ctx context.Context, profile *db.Profile) 24 } 25 26 // BaseNotifier is a listener that does nothing ··· 42 func (m *BaseNotifier) NewPullComment(ctx context.Context, comment *db.PullComment) {} 43 44 func (m *BaseNotifier) UpdateProfile(ctx context.Context, profile *db.Profile) {}
··· 21 NewPullComment(ctx context.Context, comment *db.PullComment) 22 23 UpdateProfile(ctx context.Context, profile *db.Profile) 24 + 25 + NewString(ctx context.Context, s *db.String) 26 + EditString(ctx context.Context, s *db.String) 27 + DeleteString(ctx context.Context, did, rkey string) 28 } 29 30 // BaseNotifier is a listener that does nothing ··· 46 func (m *BaseNotifier) NewPullComment(ctx context.Context, comment *db.PullComment) {} 47 48 func (m *BaseNotifier) UpdateProfile(ctx context.Context, profile *db.Profile) {} 49 + 50 + func (m *BaseNotifier) NewString(ctx context.Context, s *db.String) {} 51 + func (m *BaseNotifier) EditString(ctx context.Context, s *db.String) {} 52 + func (m *BaseNotifier) DeleteString(ctx context.Context, did, rkey string) {}
+8
appview/strings/strings.go
··· 12 "tangled.sh/tangled.sh/core/appview/config" 13 "tangled.sh/tangled.sh/core/appview/db" 14 "tangled.sh/tangled.sh/core/appview/middleware" 15 "tangled.sh/tangled.sh/core/appview/oauth" 16 "tangled.sh/tangled.sh/core/appview/pages" 17 "tangled.sh/tangled.sh/core/appview/pages/markup" ··· 36 IdResolver *idresolver.Resolver 37 Logger *slog.Logger 38 Knotstream *eventconsumer.Consumer 39 } 40 41 func (s *Strings) Router(mw *middleware.Middleware) http.Handler { ··· 284 return 285 } 286 287 // if that went okay, redir to the string 288 s.Pages.HxRedirect(w, "/strings/"+user.Handle+"/"+entry.Rkey) 289 } ··· 358 return 359 } 360 361 // successful 362 s.Pages.HxRedirect(w, "/strings/"+user.Handle+"/"+string.Rkey) 363 } ··· 399 fail("Failed to delete string.", err) 400 return 401 } 402 403 s.Pages.HxRedirect(w, "/strings/"+user.Handle) 404 }
··· 12 "tangled.sh/tangled.sh/core/appview/config" 13 "tangled.sh/tangled.sh/core/appview/db" 14 "tangled.sh/tangled.sh/core/appview/middleware" 15 + "tangled.sh/tangled.sh/core/appview/notify" 16 "tangled.sh/tangled.sh/core/appview/oauth" 17 "tangled.sh/tangled.sh/core/appview/pages" 18 "tangled.sh/tangled.sh/core/appview/pages/markup" ··· 37 IdResolver *idresolver.Resolver 38 Logger *slog.Logger 39 Knotstream *eventconsumer.Consumer 40 + Notifier notify.Notifier 41 } 42 43 func (s *Strings) Router(mw *middleware.Middleware) http.Handler { ··· 286 return 287 } 288 289 + s.Notifier.EditString(r.Context(), &entry) 290 + 291 // if that went okay, redir to the string 292 s.Pages.HxRedirect(w, "/strings/"+user.Handle+"/"+entry.Rkey) 293 } ··· 362 return 363 } 364 365 + s.Notifier.NewString(r.Context(), &string) 366 + 367 // successful 368 s.Pages.HxRedirect(w, "/strings/"+user.Handle+"/"+string.Rkey) 369 } ··· 405 fail("Failed to delete string.", err) 406 return 407 } 408 + 409 + s.Notifier.DeleteString(r.Context(), user.Did, rkey) 410 411 s.Pages.HxRedirect(w, "/strings/"+user.Handle) 412 }