Improve ID generation of the posts messages
This commit is contained in:
parent
1142f4a1bc
commit
3574001b40
|
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"crypto/sha1"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
@ -41,8 +41,8 @@ func (h *micropubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
item.Read = false
|
item.Read = false
|
||||||
item.ID = hex.EncodeToString([]byte(item.URL))
|
id, err := redis.Int(conn.Do("INCR", "source:"+sourceID+"next_id"))
|
||||||
|
item.ID = fmt.Sprintf("%x", sha1.Sum([]byte(fmt.Sprintf("source:%s:%d", sourceID, id))))
|
||||||
h.Backend.channelAddItem(channel, item)
|
h.Backend.channelAddItem(channel, item)
|
||||||
} else {
|
} else {
|
||||||
http.Error(w, "Unsupported Content-Type", 400)
|
http.Error(w, "Unsupported Content-Type", 400)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user