Have got removing parameters working
This commit is contained in:
parent
599c72d465
commit
2d42a0ef90
5 changed files with 103 additions and 20 deletions
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"image"
|
||||
"image/color"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
|
|
@ -46,6 +47,8 @@ func (s *Service) reprocess(ctx context.Context, session *models.ImageEditSessio
|
|||
img = imageImageSource{resImg}
|
||||
}
|
||||
|
||||
log.Printf("result of processed image: %T", img)
|
||||
|
||||
return img, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
"lmika.dev/lmika/weiro/models"
|
||||
"lmika.dev/lmika/weiro/services/uploads"
|
||||
"lmika.dev/pkg/modash/moslice"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
|
|
@ -114,6 +115,25 @@ func (s *Service) AddProcessor(ctx context.Context, sessionID string, req AddPro
|
|||
return session, nil
|
||||
}
|
||||
|
||||
func (s *Service) DeleteProcessor(ctx context.Context, sessionID, processorID string) (*models.ImageEditSession, error) {
|
||||
session, err := s.loadAndVerifySession(ctx, sessionID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
session.Processors = moslice.Filter(session.Processors, func(p models.ImageEditProcessor) bool { return p.ID != processorID })
|
||||
session.RecalcVersionIDs()
|
||||
if err := s.sessionStore.save(session); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, err := s.reprocess(ctx, session); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return session, nil
|
||||
}
|
||||
|
||||
func (s *Service) loadAndVerifySession(ctx context.Context, sessionID string) (*models.ImageEditSession, error) {
|
||||
site, user, err := s.fetchSiteAndUser(ctx)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue