mirror of
https://gitlab.com/commento/commento.git
synced 2025-06-29 22:56:37 -04:00
everywhere: add email notifications
This commit is contained in:
28
api/page_title.go
Normal file
28
api/page_title.go
Normal file
@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import ()
|
||||
|
||||
func pageTitleUpdate(domain string, path string) (string, error) {
|
||||
title, err := htmlTitleGet("http://" + domain + path)
|
||||
if err != nil {
|
||||
// This could fail due to a variety of reasons that we can't control such
|
||||
// as the user's URL 404 or something, so let's not pollute the error log
|
||||
// with messages. Just use a sane title. Maybe we'll have the ability to
|
||||
// retry later.
|
||||
logger.Errorf("%v", err)
|
||||
title = domain
|
||||
}
|
||||
|
||||
statement := `
|
||||
UPDATE pages
|
||||
SET title = $3
|
||||
WHERE domain = $1 AND path = $2;
|
||||
`
|
||||
_, err = db.Exec(statement, domain, path, title)
|
||||
if err != nil {
|
||||
logger.Errorf("cannot update pages table with title: %v", err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
return title, nil
|
||||
}
|
Reference in New Issue
Block a user