From 52ce2d2743caf8a4803ce9ef5589f2b358c9b327 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Tue, 31 Mar 2020 23:50:47 -0400 Subject: [PATCH] send updates for profile changes --- activity.go | 35 +++++++++++++++++++++++++++++++++++ web.go | 2 ++ 2 files changed, 37 insertions(+) diff --git a/activity.go b/activity.go index 0af0eb5..d9a9e82 100644 --- a/activity.go +++ b/activity.go @@ -1524,3 +1524,38 @@ func ingesthandle(origin string, obj junk.Junk) { } } } + +func updateMe(username string) { + var user *WhatAbout + somenamedusers.Get(username, &user) + dt := time.Now().UTC().Format(time.RFC3339) + j := junk.New() + j["@context"] = itiswhatitis + j["id"] = fmt.Sprintf("%s/upme/%s/%d", user.URL, user.Name, time.Now().Unix()) + j["actor"] = user.URL + j["published"] = dt + j["to"] = []string{thewholeworld, user.URL + "/followers"} + j["type"] = "Update" + jo := junkuser(user) + j["object"] = jo + + msg := j.ToBytes() + + rcpts := make(map[string]bool) + for _, f := range getdubs(user.ID) { + if f.XID == user.URL { + continue + } + var box *Box + boxofboxes.Get(f.XID, &box) + if box != nil && box.Shared != "" { + rcpts["%"+box.Shared] = true + } else { + rcpts[f.XID] = true + } + } + for a := range rcpts { + go deliverate(0, user.ID, a, msg) + } +} + diff --git a/web.go b/web.go index c83915f..a6054c7 100644 --- a/web.go +++ b/web.go @@ -1156,6 +1156,8 @@ func saveuser(w http.ResponseWriter, r *http.Request) { somenamedusers.Clear(u.Username) somenumberedusers.Clear(u.UserID) + updateMe(u.Username) + http.Redirect(w, r, "/account", http.StatusSeeOther) }