From cbd1be0e484750c5ef47f6622b0a58107ad47996 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Mon, 28 Oct 2024 13:57:00 +0300 Subject: [PATCH] Add helper Suspended for chats --- pachca.go | 13 +++++++++++++ pachca_test.go | 1 + 2 files changed, 14 insertions(+) diff --git a/pachca.go b/pachca.go index 63f42c3..c5136df 100644 --- a/pachca.go +++ b/pachca.go @@ -1691,6 +1691,19 @@ func (u Users) Active() Users { return result } +// Suspended returns slice with inactive users +func (u Users) Suspended() Users { + var result Users + + for _, uu := range u { + if uu.IsSuspended { + result = append(result, uu) + } + } + + return result +} + // Invited returns all invited users func (u Users) Invited() Users { var result Users diff --git a/pachca_test.go b/pachca_test.go index b805ecc..3fbfacb 100644 --- a/pachca_test.go +++ b/pachca_test.go @@ -365,6 +365,7 @@ func (s *PachcaSuite) TestUsersHelpers(c *C) { } c.Assert(uu.Active(), HasLen, 4) + c.Assert(uu.Suspended(), HasLen, 1) c.Assert(uu.Invited(), HasLen, 1) c.Assert(uu.Invited()[0].ID, Equals, ID(1))