Skip to content

Commit

Permalink
Merge pull request #4 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 0.0.4
  • Loading branch information
andyone authored Oct 28, 2024
2 parents fd9609e + dd77c58 commit 0895687
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pachca.go
Original file line number Diff line number Diff line change
Expand Up @@ -1671,8 +1671,13 @@ func (p *Property) Int() int {

// FullName returns user full name
func (u *User) FullName() string {
if u == nil {
switch {
case u == nil, u.FirstName == "" && u.LastName == "":
return ""
case u.FirstName == "" && u.LastName != "":
return u.LastName
case u.FirstName != "" && u.LastName == "":
return u.FirstName
}

return u.FirstName + " " + u.LastName
Expand Down Expand Up @@ -1709,7 +1714,7 @@ func (u Users) Invited() Users {
var result Users

for _, uu := range u {
if uu.InviteStatus == INVITE_SENT {
if !uu.IsBot && uu.InviteStatus == INVITE_SENT {
result = append(result, uu)
}
}
Expand Down
4 changes: 4 additions & 0 deletions pachca_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ func (s *PachcaSuite) TestUsersHelpers(c *C) {
c.Assert(u.FullName(), Equals, "")
u = &User{ID: 1234, FirstName: "John", LastName: "Doe", Nickname: "j.doe"}
c.Assert(u.FullName(), Equals, "John Doe")
u = &User{ID: 1234, LastName: "Doe", Nickname: "j.doe"}
c.Assert(u.FullName(), Equals, "Doe")
u = &User{ID: 1234, FirstName: "John", Nickname: "j.doe"}
c.Assert(u.FullName(), Equals, "John")

uu := Users{
{ID: 1, IsSuspended: true, InviteStatus: INVITE_SENT, IsBot: false, Role: ROLE_USER},
Expand Down

0 comments on commit 0895687

Please sign in to comment.