👽 Update account delete handler
This commit is contained in:
		| @@ -2,10 +2,11 @@ package grpc | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
|  | ||||
| 	"git.solsynth.dev/hypernet/interactive/pkg/internal/database" | ||||
| 	"git.solsynth.dev/hypernet/nexus/pkg/nex" | ||||
| 	"git.solsynth.dev/hypernet/nexus/pkg/proto" | ||||
| 	"strconv" | ||||
| 	jsoniter "github.com/json-iterator/go" | ||||
| ) | ||||
|  | ||||
| func (v *App) BroadcastEvent(ctx context.Context, in *proto.EventInfo) (*proto.EventResponse, error) { | ||||
| @@ -18,19 +19,17 @@ func (v *App) BroadcastEvent(ctx context.Context, in *proto.EventInfo) (*proto.E | ||||
| 		} | ||||
| 		switch resType { | ||||
| 		case "account": | ||||
| 			id, ok := data["id"].(string) | ||||
| 			if !ok { | ||||
| 				break | ||||
| 			var data struct { | ||||
| 				ID int `json:"id"` | ||||
| 			} | ||||
| 			numericId, err := strconv.Atoi(id) | ||||
| 			if err != nil { | ||||
| 			if err := jsoniter.Unmarshal(in.GetData(), &data); err != nil { | ||||
| 				break | ||||
| 			} | ||||
| 			tx := database.C.Begin() | ||||
| 			for _, model := range database.AutoMaintainRange { | ||||
| 				switch model.(type) { | ||||
| 				default: | ||||
| 					tx.Delete(model, "account_id = ?", numericId) | ||||
| 					tx.Delete(model, "account_id = ?", data) | ||||
| 				} | ||||
| 			} | ||||
| 			tx.Commit() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user