bloat.go (view raw)
1//
2// Copyright (c) 2019 Ted Unangst <tedu@tedunangst.com>
3//
4// Permission to use, copy, modify, and distribute this software for any
5// purpose with or without fee is hereby granted, provided that the above
6// copyright notice and this permission notice appear in all copies.
7//
8// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
16package main
17
18import (
19 "fmt"
20 "time"
21
22 "humungus.tedunangst.com/r/webs/junk"
23)
24
25func updateMe() {
26 var user *WhatAbout
27 somenumberedusers.Get(1, &user)
28 dt := time.Now().UTC().Format(time.RFC3339)
29 j := junk.New()
30 j["@context"] = itiswhatitis
31 j["id"] = fmt.Sprintf("%s/upme/%s/%d", user.URL, user.Name, time.Now().Unix())
32 j["actor"] = user.URL
33 j["published"] = dt
34 j["to"] = []string{thewholeworld, user.URL + "/followers"}
35 j["type"] = "Update"
36 jo := junkuser(user)
37 j["object"] = jo
38
39 msg := j.ToBytes()
40
41 rcpts := make(map[string]bool)
42 for _, f := range getdubs(user.ID) {
43 if f.XID == user.URL {
44 continue
45 }
46 var box *Box
47 boxofboxes.Get(f.XID, &box)
48 if box != nil && box.Shared != "" {
49 rcpts["%"+box.Shared] = true
50 } else {
51 rcpts[f.XID] = true
52 }
53 }
54 for a := range rcpts {
55 deliverate(0, user.ID, a, msg)
56 }
57}