~mariusor/fedbox-spammy

886059ae5ad18a5af49701791b3b01484610641e — Marius Orcsik 5 months ago cfce1a3
Set object names when creating them
2 files changed, 5 insertions(+), 4 deletions(-)

M cmd/main.go
M spammer.go
M cmd/main.go => cmd/main.go +1 -1
@@ 26,7 26,7 @@ func main() {
		secret     = fs.String("secret", "", "The application secret")
		serv       = fs.String("url", spammy.ServiceIRI.String(), "The FedBOX url to connect to")
		cc         = fs.String("cc", "", "CC all the activities that we generate to these IRIs")
		actorCount = fs.Int("clients", DefaultActorCount, "How many actors to create")
		actorCount = fs.Int("actors", DefaultActorCount, "How many actors to create")
	)

	ff.Parse(fs, os.Args[1:])

M spammer.go => spammer.go +4 -3
@@ 218,13 218,14 @@ func RandomObject(parent ap.Item) ap.Item {
		buf := make([]byte, base64.RawStdEncoding.EncodedLen(len(data)))
		base64.RawStdEncoding.Encode(buf, data)
		data = buf
		ob.Name = ap.NaturalLanguageValues{
			{ap.NilLangRef, []byte(fmt.Sprintf("random %s", mime))},
		}
	} else {
		ob.Name = getNameFromData(data, 5)
		ob.Summary = ap.NaturalLanguageValues{
			{ap.NilLangRef, data[:bytes.Index(data, []byte{'.'})]},
		}
		if rr := rand.Int31n(4); rr > 1 {
			ob.Name = getNameFromData(data, int(rr))
		}
	}
	ob.Content = ap.NaturalLanguageValues{
		{ap.NilLangRef, data},