Commit 022eec8f authored by Mo Firouz's avatar Mo Firouz
Browse files

Improve protocol field wrappers.

parent cc092221
Loading
Loading
Loading
Loading
+245 −244

File changed.

Preview size limit exceeded, changes collapsed.

+3 −3
Original line number Diff line number Diff line
@@ -565,7 +565,7 @@ message ChannelMessage {
  // The unique ID of this message.
  string message_id = 2;
  // The code representing a message type or category.
  int32 code = 3;
  google.protobuf.Int32Value code = 3;
  // Message sender, usually a user ID.
  string sender_id = 4;
  // The username of the message sender, if any.
@@ -573,13 +573,13 @@ message ChannelMessage {
  // The content payload.
  string content = 6;
  // Another message ID reference, if any.
  string reference_id = 7;
  google.protobuf.StringValue reference_id = 7;
  // The UNIX time when the message was created.
  google.protobuf.Timestamp create_time = 8;
  // The UNIX time when the message was last updated.
  google.protobuf.Timestamp update_time = 9;
  // True if the message was persisted to the channel's history, false otherwise.
  bool persistent = 10;
  google.protobuf.BoolValue persistent = 10;
}

// A list of channel messages, usually a result of a list operation.
+103 −103

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ message ChannelMessageAck {
  // The UNIX time when the message was last updated.
  google.protobuf.Timestamp update_time = 5;
  // True if the message was persisted to the channel's history, false otherwise.
  bool persistent = 6;
  google.protobuf.BoolValue persistent = 6;
}

// Send a message to a realtime channel.
+11 −4
Original line number Diff line number Diff line
@@ -20,13 +20,15 @@ import (
	"encoding/base64"
	"encoding/gob"
	"fmt"
	"strings"

	"github.com/golang/protobuf/ptypes/timestamp"
	"github.com/golang/protobuf/ptypes/wrappers"
	"github.com/heroiclabs/nakama/api"
	"github.com/lib/pq"
	"github.com/pkg/errors"
	"github.com/satori/go.uuid"
	"go.uber.org/zap"
	"strings"
)

var (
@@ -141,17 +143,22 @@ WHERE stream_mode = $1 AND stream_subject = $2::UUID AND stream_descriptor = $3:
			return nil, err
		}

		var refId *wrappers.StringValue
		if dbReferenceId.Valid {
			refId = &wrappers.StringValue{Value: dbReferenceId.String}
		}

		messages = append(messages, &api.ChannelMessage{
			ChannelId:   channelId,
			MessageId:   dbId,
			Code:        dbCode,
			Code:        &wrappers.Int32Value{Value: dbCode},
			SenderId:    dbSenderId,
			Username:    dbUsername,
			Content:     dbContent,
			ReferenceId: dbReferenceId.String,
			ReferenceId: refId,
			CreateTime:  &timestamp.Timestamp{Seconds: dbCreateTime.Time.Unix()},
			UpdateTime:  &timestamp.Timestamp{Seconds: dbUpdateTime.Time.Unix()},
			Persistent:  true,
			Persistent:  &wrappers.BoolValue{Value: true},
		})

		// There can only be a previous page if this is a paginated listing.
Loading