| 151 | } |
| 152 | |
| 153 | func deleteConnection(e error, connectionId uint64) (*plugin.ApiResourceOutput, errors.Error) { |
| 154 | if e != nil { |
| 155 | return nil, errors.BadInput.WrapRaw(e) |
| 156 | } |
| 157 | var connection models.WebhookConnection |
| 158 | tx := basicRes.GetDal().Begin() |
| 159 | err := tx.Delete(&connection, dal.Where("id = ?", connectionId)) |
| 160 | if err != nil { |
| 161 | if err := tx.Rollback(); err != nil { |
| 162 | logger.Error(err, "transaction Rollback") |
| 163 | } |
| 164 | logger.Error(err, "delete connection: %d", connectionId) |
| 165 | return nil, err |
| 166 | } |
| 167 | extra := fmt.Sprintf("connectionId:%d", connectionId) |
| 168 | err = apiKeyHelper.DeleteForPlugin(tx, pluginName, extra) |
| 169 | if err != nil { |
| 170 | if err := tx.Rollback(); err != nil { |
| 171 | logger.Error(err, "transaction Rollback") |
| 172 | } |
| 173 | logger.Error(err, "delete connection extra: %d, name: %s", extra, pluginName) |
| 174 | return nil, err |
| 175 | } |
| 176 | if err := tx.Commit(); err != nil { |
| 177 | logger.Info("transaction commit: %s", err) |
| 178 | } |
| 179 | |
| 180 | return &plugin.ApiResourceOutput{Status: http.StatusOK}, nil |
| 181 | } |
| 182 | |
| 183 | type WebhookConnectionResponse struct { |
| 184 | models.WebhookConnection |