feat(grpc): add alert other fields. (#327)

This commit is contained in:
Bo-Yi Wu 2018-01-06 15:03:21 +08:00 committed by GitHub
parent 230cfb23fa
commit ffd78ffaec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 345 additions and 37 deletions

View File

@ -776,6 +776,8 @@ func main() {
Title: "Test Title",
Body: "Test Alert Body",
Subtitle: "Test Alert Sub Title",
LocKey: "Test loc key",
LocArgs: []string{"test", "test"},
},
})
if err != nil {
@ -861,6 +863,8 @@ func main() {
Title: "Test Title",
Body: "Test Alert Body",
Subtitle: "Test Alert Sub Title",
LocKey: "Test loc key",
LocArgs: []string{"test", "test"},
},
})
if err != nil {

View File

@ -33,6 +33,8 @@ func main() {
Title: "Test Title",
Body: "Test Alert Body",
Subtitle: "Test Alert Sub Title",
LocKey: "Test loc key",
LocArgs: []string{"test", "test"},
},
})
if err != nil {

View File

@ -27,12 +27,19 @@ goog.exportSymbol('proto.proto.NotificationRequest', null, global);
* @constructor
*/
proto.proto.Alert = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
jspb.Message.initialize(this, opt_data, 0, -1, proto.proto.Alert.repeatedFields_, null);
};
goog.inherits(proto.proto.Alert, jspb.Message);
if (goog.DEBUG && !COMPILED) {
proto.proto.Alert.displayName = 'proto.proto.Alert';
}
/**
* List of repeated fields within this message type.
* @private {!Array<number>}
* @const
*/
proto.proto.Alert.repeatedFields_ = [9,10];
if (jspb.Message.GENERATE_TO_OBJECT) {
@ -63,7 +70,14 @@ proto.proto.Alert.toObject = function(includeInstance, msg) {
var f, obj = {
title: jspb.Message.getFieldWithDefault(msg, 1, ""),
body: jspb.Message.getFieldWithDefault(msg, 2, ""),
subtitle: jspb.Message.getFieldWithDefault(msg, 3, "")
subtitle: jspb.Message.getFieldWithDefault(msg, 3, ""),
action: jspb.Message.getFieldWithDefault(msg, 4, ""),
actionlockey: jspb.Message.getFieldWithDefault(msg, 5, ""),
launchimage: jspb.Message.getFieldWithDefault(msg, 6, ""),
lockey: jspb.Message.getFieldWithDefault(msg, 7, ""),
titlelockey: jspb.Message.getFieldWithDefault(msg, 8, ""),
locargsList: jspb.Message.getField(msg, 9),
titlelocargsList: jspb.Message.getField(msg, 10)
};
if (includeInstance) {
@ -112,6 +126,34 @@ proto.proto.Alert.deserializeBinaryFromReader = function(msg, reader) {
var value = /** @type {string} */ (reader.readString());
msg.setSubtitle(value);
break;
case 4:
var value = /** @type {string} */ (reader.readString());
msg.setAction(value);
break;
case 5:
var value = /** @type {string} */ (reader.readString());
msg.setActionlockey(value);
break;
case 6:
var value = /** @type {string} */ (reader.readString());
msg.setLaunchimage(value);
break;
case 7:
var value = /** @type {string} */ (reader.readString());
msg.setLockey(value);
break;
case 8:
var value = /** @type {string} */ (reader.readString());
msg.setTitlelockey(value);
break;
case 9:
var value = /** @type {string} */ (reader.readString());
msg.addLocargs(value);
break;
case 10:
var value = /** @type {string} */ (reader.readString());
msg.addTitlelocargs(value);
break;
default:
reader.skipField();
break;
@ -161,6 +203,55 @@ proto.proto.Alert.serializeBinaryToWriter = function(message, writer) {
f
);
}
f = message.getAction();
if (f.length > 0) {
writer.writeString(
4,
f
);
}
f = message.getActionlockey();
if (f.length > 0) {
writer.writeString(
5,
f
);
}
f = message.getLaunchimage();
if (f.length > 0) {
writer.writeString(
6,
f
);
}
f = message.getLockey();
if (f.length > 0) {
writer.writeString(
7,
f
);
}
f = message.getTitlelockey();
if (f.length > 0) {
writer.writeString(
8,
f
);
}
f = message.getLocargsList();
if (f.length > 0) {
writer.writeRepeatedString(
9,
f
);
}
f = message.getTitlelocargsList();
if (f.length > 0) {
writer.writeRepeatedString(
10,
f
);
}
};
@ -209,6 +300,143 @@ proto.proto.Alert.prototype.setSubtitle = function(value) {
};
/**
* optional string action = 4;
* @return {string}
*/
proto.proto.Alert.prototype.getAction = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, ""));
};
/** @param {string} value */
proto.proto.Alert.prototype.setAction = function(value) {
jspb.Message.setField(this, 4, value);
};
/**
* optional string actionLocKey = 5;
* @return {string}
*/
proto.proto.Alert.prototype.getActionlockey = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, ""));
};
/** @param {string} value */
proto.proto.Alert.prototype.setActionlockey = function(value) {
jspb.Message.setField(this, 5, value);
};
/**
* optional string launchImage = 6;
* @return {string}
*/
proto.proto.Alert.prototype.getLaunchimage = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, ""));
};
/** @param {string} value */
proto.proto.Alert.prototype.setLaunchimage = function(value) {
jspb.Message.setField(this, 6, value);
};
/**
* optional string locKey = 7;
* @return {string}
*/
proto.proto.Alert.prototype.getLockey = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 7, ""));
};
/** @param {string} value */
proto.proto.Alert.prototype.setLockey = function(value) {
jspb.Message.setField(this, 7, value);
};
/**
* optional string titleLocKey = 8;
* @return {string}
*/
proto.proto.Alert.prototype.getTitlelockey = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 8, ""));
};
/** @param {string} value */
proto.proto.Alert.prototype.setTitlelockey = function(value) {
jspb.Message.setField(this, 8, value);
};
/**
* repeated string locArgs = 9;
* If you change this array by adding, removing or replacing elements, or if you
* replace the array itself, then you must call the setter to update it.
* @return {!Array.<string>}
*/
proto.proto.Alert.prototype.getLocargsList = function() {
return /** @type {!Array.<string>} */ (jspb.Message.getField(this, 9));
};
/** @param {!Array.<string>} value */
proto.proto.Alert.prototype.setLocargsList = function(value) {
jspb.Message.setField(this, 9, value || []);
};
/**
* @param {!string} value
* @param {number=} opt_index
*/
proto.proto.Alert.prototype.addLocargs = function(value, opt_index) {
jspb.Message.addToRepeatedField(this, 9, value, opt_index);
};
proto.proto.Alert.prototype.clearLocargsList = function() {
this.setLocargsList([]);
};
/**
* repeated string titleLocArgs = 10;
* If you change this array by adding, removing or replacing elements, or if you
* replace the array itself, then you must call the setter to update it.
* @return {!Array.<string>}
*/
proto.proto.Alert.prototype.getTitlelocargsList = function() {
return /** @type {!Array.<string>} */ (jspb.Message.getField(this, 10));
};
/** @param {!Array.<string>} value */
proto.proto.Alert.prototype.setTitlelocargsList = function(value) {
jspb.Message.setField(this, 10, value || []);
};
/**
* @param {!string} value
* @param {number=} opt_index
*/
proto.proto.Alert.prototype.addTitlelocargs = function(value, opt_index) {
jspb.Message.addToRepeatedField(this, 10, value, opt_index);
};
proto.proto.Alert.prototype.clearTitlelocargsList = function() {
this.setTitlelocargsList([]);
};
/**
* Generated by JsPbCodeGenerator.

View File

@ -66,6 +66,13 @@ type Alert struct {
Title string `protobuf:"bytes,1,opt,name=title" json:"title,omitempty"`
Body string `protobuf:"bytes,2,opt,name=body" json:"body,omitempty"`
Subtitle string `protobuf:"bytes,3,opt,name=subtitle" json:"subtitle,omitempty"`
Action string `protobuf:"bytes,4,opt,name=action" json:"action,omitempty"`
ActionLocKey string `protobuf:"bytes,5,opt,name=actionLocKey" json:"actionLocKey,omitempty"`
LaunchImage string `protobuf:"bytes,6,opt,name=launchImage" json:"launchImage,omitempty"`
LocKey string `protobuf:"bytes,7,opt,name=locKey" json:"locKey,omitempty"`
TitleLocKey string `protobuf:"bytes,8,opt,name=titleLocKey" json:"titleLocKey,omitempty"`
LocArgs []string `protobuf:"bytes,9,rep,name=locArgs" json:"locArgs,omitempty"`
TitleLocArgs []string `protobuf:"bytes,10,rep,name=titleLocArgs" json:"titleLocArgs,omitempty"`
}
func (m *Alert) Reset() { *m = Alert{} }
@ -94,6 +101,55 @@ func (m *Alert) GetSubtitle() string {
return ""
}
func (m *Alert) GetAction() string {
if m != nil {
return m.Action
}
return ""
}
func (m *Alert) GetActionLocKey() string {
if m != nil {
return m.ActionLocKey
}
return ""
}
func (m *Alert) GetLaunchImage() string {
if m != nil {
return m.LaunchImage
}
return ""
}
func (m *Alert) GetLocKey() string {
if m != nil {
return m.LocKey
}
return ""
}
func (m *Alert) GetTitleLocKey() string {
if m != nil {
return m.TitleLocKey
}
return ""
}
func (m *Alert) GetLocArgs() []string {
if m != nil {
return m.LocArgs
}
return nil
}
func (m *Alert) GetTitleLocArgs() []string {
if m != nil {
return m.TitleLocArgs
}
return nil
}
type NotificationRequest struct {
Tokens []string `protobuf:"bytes,1,rep,name=tokens" json:"tokens,omitempty"`
Platform int32 `protobuf:"varint,2,opt,name=platform" json:"platform,omitempty"`
@ -386,33 +442,37 @@ var _Health_serviceDesc = grpc.ServiceDesc{
func init() { proto1.RegisterFile("gorush.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 433 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xcf, 0x8e, 0xd3, 0x30,
0x10, 0xc6, 0x37, 0x6d, 0x93, 0xb6, 0xd3, 0x05, 0xca, 0x2c, 0x42, 0xa6, 0xa7, 0xca, 0xa7, 0x9e,
0x7a, 0x28, 0x37, 0x0e, 0x2b, 0x10, 0x5a, 0xed, 0x22, 0x44, 0x56, 0x72, 0xf9, 0x73, 0x44, 0xae,
0xeb, 0x4d, 0xa3, 0x66, 0xe3, 0x10, 0x3b, 0x48, 0x79, 0x08, 0x4e, 0xbc, 0x30, 0xb2, 0x1d, 0x17,
0x2a, 0x85, 0x53, 0xfc, 0x9b, 0x19, 0xcf, 0x37, 0xf3, 0xc5, 0x70, 0x99, 0xa9, 0xba, 0xd1, 0x87,
0x75, 0x55, 0x2b, 0xa3, 0x30, 0x76, 0x1f, 0xfa, 0x09, 0xe2, 0x77, 0x85, 0xac, 0x0d, 0xbe, 0x80,
0xd8, 0xe4, 0xa6, 0x90, 0x24, 0x5a, 0x46, 0xab, 0x29, 0xf3, 0x80, 0x08, 0xa3, 0x9d, 0xda, 0xb7,
0x64, 0xe0, 0x82, 0xee, 0x8c, 0x0b, 0x98, 0xe8, 0x66, 0xe7, 0x8b, 0x87, 0x2e, 0x7e, 0x62, 0xfa,
0x6b, 0x00, 0x57, 0xa9, 0x32,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 0x4d, 0xe3, 0x85,
0x9f, 0x6e, 0x56, 0xdd, 0x26, 0x3d, 0xb5, 0xeb, 0xad, 0xed, 0x55, 0x66, 0x5b, 0x57, 0xcf, 0xba,
0x7b, 0xf4, 0x0d, 0x3c, 0x39, 0x4b, 0xe0, 0x0c, 0xc6, 0x5f, 0xd2, 0x8f, 0xe9, 0xfd, 0xb7, 0x74,
0x7e, 0x61, 0x61, 0x7b, 0xc3, 0xbe, 0x7e, 0x48, 0x6f, 0xe7, 0x11, 0x3e, 0x83, 0x59, 0x7a, 0xff,
0xf9, 0x7b, 0x08, 0x0c, 0x36, 0x77, 0x90, 0xdc, 0xba, 0x27, 0x88, 0xd7, 0x30, 0xda, 0xca, 0x72,
0x8f, 0x8b, 0x4e, 0xbf, 0xe7, 0xc9, 0x2c, 0x48, 0x6f, 0xae, 0x2a, 0x5a, 0x7a, 0x61, 0x3b, 0xf9,
0x91, 0xf1, 0x1a, 0x62, 0x37, 0x36, 0xbe, 0xea, 0x5b, 0xc5, 0x77, 0x5a, 0xfc, 0x7f, 0xcb, 0x5d,
0xe2, 0x52, 0xaf, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0xa8, 0xf6, 0xa7, 0x4d, 0x1d, 0x03, 0x00,
0x00,
// 510 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x53, 0x4d, 0x8f, 0xda, 0x30,
0x10, 0xdd, 0x00, 0x09, 0x30, 0xd0, 0x96, 0x7a, 0xab, 0xca, 0xe5, 0x84, 0x72, 0xe2, 0xc4, 0x81,
0xde, 0x7a, 0x58, 0x75, 0x55, 0xad, 0x76, 0x57, 0x5b, 0x65, 0xa5, 0xd0, 0x8f, 0x63, 0x65, 0x8c,
0x37, 0x44, 0x98, 0x38, 0x8d, 0x9d, 0x4a, 0xfc, 0x88, 0x9e, 0xfa, 0x13, 0xfa, 0x47, 0x2b, 0x8f,
0x1d, 0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 0x49, 0x40, 0x5e, 0xc1, 0x28, 0x79, 0xfc, 0xf2, 0xa3, 0x09,
0x74, 0x96, 0x77, 0x10, 0xdd, 0xe2, 0x9f, 0x45, 0xae, 0xa0, 0xb7, 0x12, 0xc5, 0x86, 0x4c, 0xfd,
0xfd, 0x67, 0x56, 0x66, 0x4a, 0xcf, 0x72, 0xa5, 0x3c, 0xc4, 0x17, 0x56, 0xc9, 0xb5, 0x4c, 0xae,
0x20, 0xc4, 0xb6, 0xc9, 0xbb, 0x73, 0xa3, 0x38, 0xa5, 0xe9, 0xf3, 0x53, 0xae, 0x23, 0xa4, 0xde,
0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x48, 0x9a, 0x50, 0x65, 0xf4, 0x03, 0x00, 0x00,
}

View File

@ -6,6 +6,13 @@ message Alert {
string title = 1;
string body = 2;
string subtitle = 3;
string action = 4;
string actionLocKey = 5;
string launchImage = 6;
string locKey = 7;
string titleLocKey = 8;
repeated string locArgs = 9;
repeated string titleLocArgs = 10;
}
message NotificationRequest {

View File

@ -69,6 +69,13 @@ func (s *Server) Send(ctx context.Context, in *proto.NotificationRequest) (*prot
Title: in.Alert.Title,
Body: in.Alert.Body,
Subtitle: in.Alert.Subtitle,
Action: in.Alert.Action,
ActionLocKey: in.Alert.Action,
LaunchImage: in.Alert.LaunchImage,
LocArgs: in.Alert.LocArgs,
LocKey: in.Alert.LocKey,
TitleLocArgs: in.Alert.TitleLocArgs,
TitleLocKey: in.Alert.TitleLocKey,
}
}