@@ -2,7 +2,6 @@ package webapp
22
33import (
44 "context"
5- "errors"
65 "fmt"
76 "net/http"
87
@@ -315,19 +314,16 @@ func (c *Controller) rewindSessionHistory(session *webapp.Session) error {
315314 return nil
316315}
317316
318- func (c * Controller ) GetWebappSession (ctx context.Context ) (* webapp.Session , error ) {
317+ func (c * Controller ) InteractionSession (ctx context.Context ) (* webapp.Session , error ) {
319318 s := webapp .GetSession (ctx )
320- if s == nil {
319+ if s == nil || s . IsCompleted {
321320 return nil , webapp .ErrSessionNotFound
322321 }
323- if s .IsCompleted {
324- return nil , webapp .ErrSessionCompleted
325- }
326322 return s , nil
327323}
328324
329325func (c * Controller ) InteractionGet (ctx context.Context ) (* interaction.Graph , error ) {
330- s , err := c .GetWebappSession (ctx )
326+ s , err := c .InteractionSession (ctx )
331327 if err != nil {
332328 return nil , err
333329 }
@@ -348,7 +344,7 @@ func (c *Controller) InteractionGetWithSession(ctx context.Context, s *webapp.Se
348344}
349345
350346func (c * Controller ) InteractionPost (ctx context.Context , inputFn func () (interface {}, error )) (* webapp.Result , error ) {
351- s , err := c .GetWebappSession (ctx )
347+ s , err := c .InteractionSession (ctx )
352348 if err != nil {
353349 return nil , err
354350 }
@@ -381,13 +377,9 @@ func (c *Controller) InteractionOAuthCallback(ctx context.Context, oauthInput In
381377}
382378
383379func (c * Controller ) getSettingsActionWebSession (ctx context.Context , r * http.Request ) (* webapp.Session , error ) {
384- webappSession , err := c .GetWebappSession (ctx )
385- if err != nil {
386- // No session means it is not in settings action
387- if errors .Is (err , webapp .ErrSessionNotFound ) {
388- return nil , nil
389- }
390- return nil , err
380+ webappSession := webapp .GetSession (ctx )
381+ if webappSession == nil {
382+ return nil , nil
391383 }
392384 if webappSession .SettingsActionID == "" {
393385 // This session is not for a settings action, ignore it
@@ -401,6 +393,9 @@ func (c *Controller) getSettingsActionWebSession(ctx context.Context, r *http.Re
401393 // This session is not for the current settings action, ignore it
402394 return nil , nil
403395 }
396+ if webappSession .IsCompleted {
397+ return nil , webapp .ErrSessionCompleted
398+ }
404399 return webappSession , nil
405400}
406401
0 commit comments