From 09b6649b471486d58e6a0c80f4f7d12a6a1bb230 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 2 Dec 2016 17:13:10 +0000 Subject: [PATCH] Add helper function to find single stage flows --- responses.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/responses.go b/responses.go index a387630..e086824 100644 --- a/responses.go +++ b/responses.go @@ -47,6 +47,16 @@ type RespUserInteractive struct { Error string `json:"error"` } +// HasSingleStageFlow returns true if there exists at least 1 Flow with a single stage of stageName. +func (r RespUserInteractive) HasSingleStageFlow(stageName string) bool { + for _, f := range r.Flows { + if len(f.Stages) == 1 && f.Stages[0] == stageName { + return true + } + } + return false +} + // RespRegister is the JSON response for http://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-register type RespRegister struct { AccessToken string `json:"access_token"`