chore(grpc): add image field (#485)

This commit is contained in:
Bo-Yi Wu
2020-03-14 00:00:03 +08:00
committed by GitHub
parent 38f11f0592
commit 44bf37941b
7 changed files with 128 additions and 60 deletions

View File

@@ -505,7 +505,8 @@ proto.proto.NotificationRequest.toObject = function(includeInstance, msg) {
contentavailable: jspb.Message.getFieldWithDefault(msg, 11, false),
threadid: jspb.Message.getFieldWithDefault(msg, 12, ""),
mutablecontent: jspb.Message.getFieldWithDefault(msg, 13, false),
data: (f = msg.getData()) && google_protobuf_struct_pb.Struct.toObject(includeInstance, f)
data: (f = msg.getData()) && google_protobuf_struct_pb.Struct.toObject(includeInstance, f),
image: jspb.Message.getFieldWithDefault(msg, 15, "")
};
if (includeInstance) {
@@ -600,6 +601,10 @@ proto.proto.NotificationRequest.deserializeBinaryFromReader = function(msg, read
reader.readMessage(value,google_protobuf_struct_pb.Struct.deserializeBinaryFromReader);
msg.setData(value);
break;
case 15:
var value = /** @type {string} */ (reader.readString());
msg.setImage(value);
break;
default:
reader.skipField();
break;
@@ -729,6 +734,13 @@ proto.proto.NotificationRequest.serializeBinaryToWriter = function(message, writ
google_protobuf_struct_pb.Struct.serializeBinaryToWriter
);
}
f = message.getImage();
if (f.length > 0) {
writer.writeString(
15,
f
);
}
};
@@ -990,6 +1002,21 @@ proto.proto.NotificationRequest.prototype.hasData = function() {
};
/**
* optional string image = 15;
* @return {string}
*/
proto.proto.NotificationRequest.prototype.getImage = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 15, ""));
};
/** @param {string} value */
proto.proto.NotificationRequest.prototype.setImage = function(value) {
jspb.Message.setProto3StringField(this, 15, value);
};
/**
* Generated by JsPbCodeGenerator.

View File

@@ -9,6 +9,8 @@ import (
proto "github.com/golang/protobuf/proto"
_struct "github.com/golang/protobuf/ptypes/struct"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
math "math"
)
@@ -21,7 +23,7 @@ var _ = math.Inf
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type HealthCheckResponse_ServingStatus int32
@@ -177,6 +179,7 @@ type NotificationRequest struct {
ThreadID string `protobuf:"bytes,12,opt,name=threadID,proto3" json:"threadID,omitempty"`
MutableContent bool `protobuf:"varint,13,opt,name=mutableContent,proto3" json:"mutableContent,omitempty"`
Data *_struct.Struct `protobuf:"bytes,14,opt,name=data,proto3" json:"data,omitempty"`
Image string `protobuf:"bytes,15,opt,name=image,proto3" json:"image,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@@ -305,6 +308,13 @@ func (m *NotificationRequest) GetData() *_struct.Struct {
return nil
}
func (m *NotificationRequest) GetImage() string {
if m != nil {
return m.Image
}
return ""
}
type NotificationReply struct {
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
Counts int32 `protobuf:"varint,2,opt,name=counts,proto3" json:"counts,omitempty"`
@@ -439,57 +449,60 @@ func init() {
proto.RegisterType((*HealthCheckResponse)(nil), "proto.HealthCheckResponse")
}
func init() { proto.RegisterFile("gorush.proto", fileDescriptor_40935fa25e258221) }
func init() {
proto.RegisterFile("gorush.proto", fileDescriptor_40935fa25e258221)
}
var fileDescriptor_40935fa25e258221 = []byte{
// 607 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0x4f, 0x6f, 0xd3, 0x4e,
0x10, 0xad, 0x9b, 0x38, 0x4d, 0x26, 0x69, 0x7f, 0xf9, 0x6d, 0x11, 0x2c, 0x11, 0x87, 0xc8, 0x07,
0x14, 0x81, 0xe4, 0x4a, 0xe5, 0xc6, 0xa1, 0xa2, 0x2a, 0x55, 0x5b, 0x15, 0xb9, 0x92, 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xff, 0x46, 0xa4, 0x16, 0xe6, 0xaf, 0x04, 0x00, 0x00,
// 614 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0xdd, 0x6e, 0xd3, 0x30,
0x14, 0x5e, 0xd6, 0xa6, 0x6b, 0x4f, 0xbb, 0xad, 0x78, 0x08, 0x4c, 0xc5, 0x45, 0x95, 0x0b, 0x54,
0x81, 0x94, 0x49, 0xe3, 0x8e, 0x8b, 0x89, 0x69, 0x4c, 0xdb, 0x34, 0x94, 0x49, 0x29, 0x3f, 0x97,
0xc8, 0x71, 0xbc, 0x34, 0x9a, 0x1b, 0x87, 0xd8, 0x99, 0xd4, 0xe7, 0xe0, 0x11, 0x78, 0x11, 0x1e,
0x0d, 0xf9, 0x38, 0x29, 0x2b, 0x94, 0xab, 0xfa, 0xfb, 0xce, 0x8f, 0x3f, 0x9f, 0xf3, 0x35, 0x30,
0xca, 0x54, 0x55, 0xeb, 0x45, 0x58, 0x56, 0xca, 0x28, 0xe2, 0xe3, 0xcf, 0xe4, 0x65, 0xa6, 0x54,
0x26, 0xc5, 0x31, 0xa2, 0xa4, 0xbe, 0x3b, 0xd6, 0xa6, 0xaa, 0xb9, 0x71, 0x49, 0xc1, 0xcf, 0x5d,
0xf0, 0xcf, 0xa4, 0xa8, 0x0c, 0x79, 0x0a, 0xbe, 0xc9, 0x8d, 0x14, 0xd4, 0x9b, 0x7a, 0xb3, 0x41,
0xec, 0x00, 0x21, 0xd0, 0x4d, 0x54, 0xba, 0xa2, 0xbb, 0x48, 0xe2, 0x99, 0x4c, 0xa0, 0xaf, 0xeb,
0xc4, 0x25, 0x77, 0x90, 0x5f, 0x63, 0xf2, 0x0c, 0x7a, 0x8c, 0x9b, 0x5c, 0x15, 0xb4, 0x8b, 0x91,
0x06, 0x91, 0x00, 0x46, 0xee, 0xf4, 0x51, 0xf1, 0x1b, 0xb1, 0xa2, 0x3e, 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e, 0x3d, 0x72,
0x08, 0xc3, 0xe8, 0xf6, 0xd3, 0xb7, 0x96, 0xd8, 0x3d, 0xb9, 0x82, 0xde, 0x25, 0x7e, 0x2a, 0xc8,
0x29, 0x74, 0xe7, 0xa2, 0x48, 0xc9, 0xa4, 0xb9, 0x7f, 0x8b, 0xcb, 0x27, 0x74, 0x6b, 0xac, 0x94,
0xab, 0x60, 0xc7, 0x76, 0x72, 0x92, 0xc9, 0x29, 0xf8, 0x28, 0x9b, 0xbc, 0xd8, 0xf6, 0x14, 0xd7,
0x69, 0xf2, 0xff, 0x57, 0x26, 0x3d, 0x0c, 0xbd, 0xfd, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xa0, 0xcb,
0xd2, 0xf3, 0xc5, 0x04, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
var _ grpc.ClientConnInterface
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
const _ = grpc.SupportPackageIsVersion6
// GorushClient is the client API for Gorush service.
//
@@ -499,10 +512,10 @@ type GorushClient interface {
}
type gorushClient struct {
cc *grpc.ClientConn
cc grpc.ClientConnInterface
}
func NewGorushClient(cc *grpc.ClientConn) GorushClient {
func NewGorushClient(cc grpc.ClientConnInterface) GorushClient {
return &gorushClient{cc}
}
@@ -520,6 +533,14 @@ type GorushServer interface {
Send(context.Context, *NotificationRequest) (*NotificationReply, error)
}
// UnimplementedGorushServer can be embedded to have forward compatible implementations.
type UnimplementedGorushServer struct {
}
func (*UnimplementedGorushServer) Send(ctx context.Context, req *NotificationRequest) (*NotificationReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Send not implemented")
}
func RegisterGorushServer(s *grpc.Server, srv GorushServer) {
s.RegisterService(&_Gorush_serviceDesc, srv)
}
@@ -563,10 +584,10 @@ type HealthClient interface {
}
type healthClient struct {
cc *grpc.ClientConn
cc grpc.ClientConnInterface
}
func NewHealthClient(cc *grpc.ClientConn) HealthClient {
func NewHealthClient(cc grpc.ClientConnInterface) HealthClient {
return &healthClient{cc}
}
@@ -584,6 +605,14 @@ type HealthServer interface {
Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error)
}
// UnimplementedHealthServer can be embedded to have forward compatible implementations.
type UnimplementedHealthServer struct {
}
func (*UnimplementedHealthServer) Check(ctx context.Context, req *HealthCheckRequest) (*HealthCheckResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Check not implemented")
}
func RegisterHealthServer(s *grpc.Server, srv HealthServer) {
s.RegisterService(&_Health_serviceDesc, srv)
}

View File

@@ -31,6 +31,7 @@ message NotificationRequest {
string threadID = 12;
bool mutableContent = 13;
google.protobuf.Struct data = 14;
string image = 15;
}
message NotificationReply {

View File

@@ -61,6 +61,7 @@ func (s *Server) Send(ctx context.Context, in *proto.NotificationRequest) (*prot
ContentAvailable: in.ContentAvailable,
ThreadID: in.ThreadID,
MutableContent: in.MutableContent,
Image: in.Image,
}
if badge > 0 {