invitation bytearray copy debug #1
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
6511ff6280
commit
289e39c677
@ -2,6 +2,8 @@ package meowlib
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCompress(t *testing.T) {
|
func TestCompress(t *testing.T) {
|
||||||
@ -18,4 +20,9 @@ func TestCompress(t *testing.T) {
|
|||||||
println(len(serialized))
|
println(len(serialized))
|
||||||
compressed, _ := cc.Compress()
|
compressed, _ := cc.Compress()
|
||||||
println(len(compressed))
|
println(len(compressed))
|
||||||
|
ncc, err := NewContactCardFromCompressed(compressed)
|
||||||
|
if err != nil {
|
||||||
|
println(err)
|
||||||
|
}
|
||||||
|
assert.Equal(t, ncc.Name, cc.Name)
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -18,11 +17,6 @@ func (r *RedisRouter) CreateInvitation(invitation []byte, timeout int, password
|
|||||||
if len(password) > 0 {
|
if len(password) > 0 {
|
||||||
r.Client.Set("mwpw:"+id, password, 0) //, time.Duration(timeout*1000000))
|
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()
|
return id, time.Now().Add(time.Duration(timeout * 1000000)).UTC()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,16 +128,14 @@ func (r *RedisRouter) Route(msg *meowlib.ToServerMessage) (*meowlib.FromServerMe
|
|||||||
from_server.Invitation.Shortcode = url
|
from_server.Invitation.Shortcode = url
|
||||||
from_server.Invitation.Expiry = expiry.UTC().Unix()
|
from_server.Invitation.Expiry = expiry.UTC().Unix()
|
||||||
case 2: // get invitation
|
case 2: // get invitation
|
||||||
invitation, err := r.GetInvitation(msg.Invitation.Shortcode, msg.Invitation.Password)
|
|
||||||
from_server.Invitation = &meowlib.Invitation{}
|
from_server.Invitation = &meowlib.Invitation{}
|
||||||
|
from_server.Invitation.Payload, err = r.GetInvitation(msg.Invitation.Shortcode, msg.Invitation.Password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err.Error() == "auth failed" {
|
if err.Error() == "auth failed" {
|
||||||
from_server.Invitation.Payload = []byte("authentication failure")
|
from_server.Invitation.Payload = []byte("authentication failure")
|
||||||
} else {
|
} else {
|
||||||
from_server.Invitation.Payload = []byte("invitation expired")
|
from_server.Invitation.Payload = []byte("invitation expired")
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
from_server.Invitation.Payload = invitation // protobuf invitation
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* should not happen
|
/* should not happen
|
||||||
|
Loading…
Reference in New Issue
Block a user