Update sleep timers
parent
85adb26acd
commit
108571ac15
|
@ -85,13 +85,13 @@ func HandleMicroPub(w http.ResponseWriter, r *http.Request) {
|
|||
} else {
|
||||
w.Header().Add("Location", location)
|
||||
w.WriteHeader(http.StatusAccepted)
|
||||
// Purge CDN in 10 seconds, send webmentions, post to social media
|
||||
// Purge CDN after 30 seconds, send webmentions, post to social media
|
||||
go func() {
|
||||
time.Sleep(30 * time.Second)
|
||||
if SelectedCdn != nil {
|
||||
time.Sleep(10 * time.Second)
|
||||
SelectedCdn.Purge(location)
|
||||
}
|
||||
time.Sleep(10 * time.Second)
|
||||
}
|
||||
// Send webmentions
|
||||
go SendWebmentions(location)
|
||||
go func() {
|
||||
|
|
|
@ -42,17 +42,19 @@ func SendWebmentions(url string) {
|
|||
|
||||
func filterLinks(links []string) []string {
|
||||
var filteredLinks []string
|
||||
checkPrefix := func(link string, prefix string) bool {
|
||||
return strings.HasPrefix(link, strings.TrimSuffix(prefix, "/"))
|
||||
}
|
||||
checkAny := func(link string) bool {
|
||||
for _, ignoredUrl := range IgnoredWebmentionUrls {
|
||||
if checkPrefix(link, ignoredUrl) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
for _, link := range links {
|
||||
if strings.HasPrefix(link, strings.TrimSuffix(BlogUrl, "/")) {
|
||||
continue
|
||||
}
|
||||
ignored := false
|
||||
for _, ignoredURL := range IgnoredWebmentionUrls {
|
||||
if !ignored && strings.HasPrefix(link, strings.TrimSuffix(ignoredURL, "/")) {
|
||||
ignored = true
|
||||
}
|
||||
}
|
||||
if ignored != true {
|
||||
if !(checkPrefix(link, BlogUrl) || checkAny(link)) {
|
||||
filteredLinks = append(filteredLinks, link)
|
||||
}
|
||||
}
|
||||
|
@ -181,10 +183,10 @@ func returnSuccess(target string, w http.ResponseWriter, r *http.Request) {
|
|||
} else {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
// Purge CDN in 10 seconds
|
||||
// Purge CDN after 30 seconds
|
||||
go func() {
|
||||
time.Sleep(30 * time.Second)
|
||||
if SelectedCdn != nil {
|
||||
time.Sleep(10 * time.Second)
|
||||
SelectedCdn.Purge(target)
|
||||
}
|
||||
}()
|
||||
|
|
Loading…
Reference in New Issue