update profile when hostname changes

This commit is contained in:
Roland Osborne 2023-05-20 22:05:14 -07:00
parent 643417eb1e
commit 758dcfb3c8
2 changed files with 10 additions and 7 deletions

View File

@ -27,12 +27,12 @@ func SetNodeConfig(w http.ResponseWriter, r *http.Request) {
err := store.DB.Transaction(func(tx *gorm.DB) error {
// upsert domain config
if res := tx.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "config_id"}},
DoUpdates: clause.AssignmentColumns([]string{"str_value"}),
}).Create(&store.Config{ConfigID: CNFDomain, StrValue: config.Domain}).Error; res != nil {
return res
}
if res := tx.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "config_id"}},
DoUpdates: clause.AssignmentColumns([]string{"str_value"}),
}).Create(&store.Config{ConfigID: CNFDomain, StrValue: config.Domain}).Error; res != nil {
return res
}
// upsert account storage config
if res := tx.Clauses(clause.OnConflict{
@ -132,6 +132,9 @@ func SetNodeConfig(w http.ResponseWriter, r *http.Request) {
if res := tx.Model(account).Update("account_revision", account.AccountRevision+1).Error; res != nil {
return res
}
if res := tx.Model(account).Update("profile_revision", account.ProfileRevision+1).Error; res != nil {
return res
}
}
return nil
})

View File

@ -34,7 +34,7 @@ func SendNotifications() {
select {
case notification := <-notify:
node := getStrConfigValue(CNFDomain, "")
if notification.Node == node {
if notification.Node == "" || notification.Node == node {
sendLocalNotification(notification)
} else {
sendRemoteNotification(notification)