diff --git a/contactcard_test.go b/contactcard_test.go index 4d2c749..f3e82a1 100644 --- a/contactcard_test.go +++ b/contactcard_test.go @@ -2,6 +2,8 @@ package meowlib import ( "testing" + + "github.com/stretchr/testify/assert" ) func TestCompress(t *testing.T) { @@ -18,4 +20,9 @@ func TestCompress(t *testing.T) { println(len(serialized)) compressed, _ := cc.Compress() println(len(compressed)) + ncc, err := NewContactCardFromCompressed(compressed) + if err != nil { + println(err) + } + assert.Equal(t, ncc.Name, cc.Name) } diff --git a/server/invitation.go b/server/invitation.go index 9fc27e3..774e44d 100644 --- a/server/invitation.go +++ b/server/invitation.go @@ -2,7 +2,6 @@ package server import ( "errors" - "fmt" "math/rand" "time" @@ -18,11 +17,6 @@ func (r *RedisRouter) CreateInvitation(invitation []byte, timeout int, password if len(password) > 0 { r.Client.Set("mwpw:"+id, password, 0) //, time.Duration(timeout*1000000)) } - mwiv, err := r.Client.Get("mwiv:" + id).Result() - if err != nil { - fmt.Println(err) - } - fmt.Println(len([]byte(mwiv)), len(invitation)) return id, time.Now().Add(time.Duration(timeout * 1000000)).UTC() } diff --git a/server/router.go b/server/router.go index eec573d..97cb650 100644 --- a/server/router.go +++ b/server/router.go @@ -128,16 +128,14 @@ func (r *RedisRouter) Route(msg *meowlib.ToServerMessage) (*meowlib.FromServerMe from_server.Invitation.Shortcode = url from_server.Invitation.Expiry = expiry.UTC().Unix() case 2: // get invitation - invitation, err := r.GetInvitation(msg.Invitation.Shortcode, msg.Invitation.Password) from_server.Invitation = &meowlib.Invitation{} + from_server.Invitation.Payload, err = r.GetInvitation(msg.Invitation.Shortcode, msg.Invitation.Password) if err != nil { if err.Error() == "auth failed" { from_server.Invitation.Payload = []byte("authentication failure") } else { from_server.Invitation.Payload = []byte("invitation expired") } - } else { - from_server.Invitation.Payload = invitation // protobuf invitation } /* should not happen