more robust shortcut.. return hash of long xid instead of tail.
sometimes the suffix is common to many activities. noticed by micropub.
This commit is contained in:
parent
acd96f17ee
commit
aebc6c8981
|
@ -1176,6 +1176,8 @@ func honkworldwide(user *WhatAbout, honk *Honk) {
|
||||||
jonk.Write(&buf)
|
jonk.Write(&buf)
|
||||||
msg := buf.Bytes()
|
msg := buf.Bytes()
|
||||||
|
|
||||||
|
log.Printf("obj for transmission: %s", msg)
|
||||||
|
|
||||||
rcpts := make(map[string]bool)
|
rcpts := make(map[string]bool)
|
||||||
for _, a := range honk.Audience {
|
for _, a := range honk.Audience {
|
||||||
if a == thewholeworld || a == user.URL || strings.HasSuffix(a, "/followers") {
|
if a == thewholeworld || a == user.URL || strings.HasSuffix(a, "/followers") {
|
||||||
|
|
28
fun.go
28
fun.go
|
@ -18,8 +18,10 @@ package main
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
|
"crypto/sha512"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
@ -230,25 +232,27 @@ func translate(honk *Honk, redoimages bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func shortxid(xid string) string {
|
func xcelerate(b []byte) string {
|
||||||
idx := strings.LastIndexByte(xid, '/')
|
|
||||||
if idx == -1 {
|
|
||||||
return xid
|
|
||||||
}
|
|
||||||
return xid[idx+1:]
|
|
||||||
}
|
|
||||||
|
|
||||||
func xfiltrate() string {
|
|
||||||
letters := "BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz1234567891234567891234"
|
letters := "BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz1234567891234567891234"
|
||||||
var b [18]byte
|
|
||||||
rand.Read(b[:])
|
|
||||||
for i, c := range b {
|
for i, c := range b {
|
||||||
b[i] = letters[c&63]
|
b[i] = letters[c&63]
|
||||||
}
|
}
|
||||||
s := string(b[:])
|
s := string(b)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func shortxid(xid string) string {
|
||||||
|
h := sha512.New512_256()
|
||||||
|
io.WriteString(h, xid)
|
||||||
|
return xcelerate(h.Sum(nil)[:20])
|
||||||
|
}
|
||||||
|
|
||||||
|
func xfiltrate() string {
|
||||||
|
var b [18]byte
|
||||||
|
rand.Read(b[:])
|
||||||
|
return xcelerate(b[:])
|
||||||
|
}
|
||||||
|
|
||||||
var re_hashes = regexp.MustCompile(`(?:^| )#[[:alnum:]][[:alnum:]_-]*`)
|
var re_hashes = regexp.MustCompile(`(?:^| )#[[:alnum:]][[:alnum:]_-]*`)
|
||||||
|
|
||||||
func ontologies(s string) []string {
|
func ontologies(s string) []string {
|
||||||
|
|
Loading…
Reference in New Issue