Hook blobstore into Grumble.

This commit is contained in:
Mikkel Krautz 2011-04-11 17:55:11 +02:00
parent b3fec9315a
commit ed602e9d8c
8 changed files with 159 additions and 72 deletions

31
user.go
View file

@ -5,6 +5,7 @@
package main
import (
"encoding/hex"
"os"
)
@ -37,3 +38,33 @@ func NewUser(id uint32, name string) (user *User, err os.Error) {
Name: name,
},nil
}
// Does the channel have comment?
func (user *User) HasComment() bool {
return len(user.CommentBlob) > 0
}
// Get the hash of the user's comment blob as a byte slice for transmitting via a protobuf message.
// Returns nil if there is no such blob.
func (user *User) CommentBlobHashBytes() (buf []byte) {
buf, err := hex.DecodeString(user.CommentBlob)
if err != nil {
return nil
}
return buf
}
// Does the user have a texture?
func (user *User) HasTexture() bool {
return len(user.TextureBlob) > 0
}
// Get the hash of the user's texture blob as a byte slice for transmitting via a protobuf message.
// Returns nil if there is no such blob.
func (user *User) TextureBlobHashBytes() (buf []byte) {
buf, err := hex.DecodeString(user.TextureBlob)
if err != nil {
return nil
}
return buf
}