fix(grpc): check alert exist. (#324)

* fix(grpc): check alert exist.

* fix: update readme.
This commit is contained in:
Bo-Yi Wu 2018-01-03 17:08:28 +08:00 committed by GitHub
parent 3b30bb6346
commit 651a2b76db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 322 additions and 294 deletions

View File

@ -771,7 +771,7 @@ func main() {
Message: "test message", Message: "test message",
Badge: 1, Badge: 1,
Category: "test", Category: "test",
Alert: &proto.NotificationRequest_Alert{ Alert: &proto.Alert{
Title: "Test Title", Title: "Test Title",
Body: "Test Alert Body", Body: "Test Alert Body",
Subtitle: "Test Alert Sub Title", Subtitle: "Test Alert Sub Title",
@ -798,12 +798,22 @@ function main() {
var client = new services.GorushClient('localhost:9000', var client = new services.GorushClient('localhost:9000',
grpc.credentials.createInsecure()); grpc.credentials.createInsecure());
var request = new messages.NotificationRequest(); var request = new messages.NotificationRequest();
var alert = new messages.Alert();
request.setPlatform(2); request.setPlatform(2);
request.setTokensList(["1234567890"]); request.setTokensList(["1234567890"]);
request.setMessage("Hello!!"); request.setMessage("Hello!!");
request.setTitle("hello2");
request.setBadge(2);
request.setCategory("mycategory");
alert.setTitle("title");
request.setAlert(alert);
client.send(request, function (err, response) { client.send(request, function (err, response) {
console.log('Success:', response.getSuccess()); if(err) {
console.log('Counts:', response.getCounts()); console.log(err);
} else {
console.log("Success:", response.getSuccess());
console.log("Counts:", response.getCounts());
}
}); });
} }
@ -844,7 +854,7 @@ func main() {
Message: "test message", Message: "test message",
Badge: 1, Badge: 1,
Category: "test", Category: "test",
Alert: &proto.NotificationRequest_Alert{ Alert: &proto.Alert{
Title: "Test Title", Title: "Test Title",
Body: "Test Alert Body", Body: "Test Alert Body",
Subtitle: "Test Alert Sub Title", Subtitle: "Test Alert Sub Title",

View File

@ -28,7 +28,7 @@ func main() {
Message: "test message", Message: "test message",
Badge: 1, Badge: 1,
Category: "test", Category: "test",
Alert: &proto.NotificationRequest_Alert{ Alert: &proto.Alert{
Title: "Test Title", Title: "Test Title",
Body: "Test Alert Body", Body: "Test Alert Body",
Subtitle: "Test Alert Sub Title", Subtitle: "Test Alert Sub Title",

View File

@ -7,12 +7,22 @@ function main() {
var client = new services.GorushClient('localhost:9000', var client = new services.GorushClient('localhost:9000',
grpc.credentials.createInsecure()); grpc.credentials.createInsecure());
var request = new messages.NotificationRequest(); var request = new messages.NotificationRequest();
var alert = new messages.Alert();
request.setPlatform(2); request.setPlatform(2);
request.setTokensList(["1234567890"]); request.setTokensList(["1234567890"]);
request.setMessage("Hello!!"); request.setMessage("Hello!!");
request.setTitle("hello2");
request.setBadge(2);
request.setCategory("mycategory");
alert.setTitle("title");
request.setAlert(alert);
client.send(request, function (err, response) { client.send(request, function (err, response) {
console.log('Success:', response.getSuccess()); if(err) {
console.log('Counts:', response.getCounts()); console.log(err);
} else {
console.log("Success:", response.getSuccess());
console.log("Counts:", response.getCounts());
}
}); });
} }

View File

@ -9,12 +9,206 @@ var jspb = require('google-protobuf');
var goog = jspb; var goog = jspb;
var global = Function('return this')(); var global = Function('return this')();
goog.exportSymbol('proto.proto.Alert', null, global);
goog.exportSymbol('proto.proto.HealthCheckRequest', null, global); goog.exportSymbol('proto.proto.HealthCheckRequest', null, global);
goog.exportSymbol('proto.proto.HealthCheckResponse', null, global); goog.exportSymbol('proto.proto.HealthCheckResponse', null, global);
goog.exportSymbol('proto.proto.HealthCheckResponse.ServingStatus', null, global); goog.exportSymbol('proto.proto.HealthCheckResponse.ServingStatus', null, global);
goog.exportSymbol('proto.proto.NotificationReply', null, global); goog.exportSymbol('proto.proto.NotificationReply', null, global);
goog.exportSymbol('proto.proto.NotificationRequest', null, global); goog.exportSymbol('proto.proto.NotificationRequest', null, global);
goog.exportSymbol('proto.proto.NotificationRequest.Alert', null, global);
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.proto.Alert = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.proto.Alert, jspb.Message);
if (goog.DEBUG && !COMPILED) {
proto.proto.Alert.displayName = 'proto.proto.Alert';
}
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.proto.Alert.prototype.toObject = function(opt_includeInstance) {
return proto.proto.Alert.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.proto.Alert} msg The msg instance to transform.
* @return {!Object}
*/
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, "")
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}
/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.proto.Alert}
*/
proto.proto.Alert.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.proto.Alert;
return proto.proto.Alert.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.proto.Alert} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.proto.Alert}
*/
proto.proto.Alert.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {string} */ (reader.readString());
msg.setTitle(value);
break;
case 2:
var value = /** @type {string} */ (reader.readString());
msg.setBody(value);
break;
case 3:
var value = /** @type {string} */ (reader.readString());
msg.setSubtitle(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.proto.Alert.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.proto.Alert.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.proto.Alert} message
* @param {!jspb.BinaryWriter} writer
*/
proto.proto.Alert.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getTitle();
if (f.length > 0) {
writer.writeString(
1,
f
);
}
f = message.getBody();
if (f.length > 0) {
writer.writeString(
2,
f
);
}
f = message.getSubtitle();
if (f.length > 0) {
writer.writeString(
3,
f
);
}
};
/**
* optional string title = 1;
* @return {string}
*/
proto.proto.Alert.prototype.getTitle = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};
/** @param {string} value */
proto.proto.Alert.prototype.setTitle = function(value) {
jspb.Message.setField(this, 1, value);
};
/**
* optional string body = 2;
* @return {string}
*/
proto.proto.Alert.prototype.getBody = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
};
/** @param {string} value */
proto.proto.Alert.prototype.setBody = function(value) {
jspb.Message.setField(this, 2, value);
};
/**
* optional string subtitle = 3;
* @return {string}
*/
proto.proto.Alert.prototype.getSubtitle = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
};
/** @param {string} value */
proto.proto.Alert.prototype.setSubtitle = function(value) {
jspb.Message.setField(this, 3, value);
};
/** /**
* Generated by JsPbCodeGenerator. * Generated by JsPbCodeGenerator.
@ -76,7 +270,7 @@ proto.proto.NotificationRequest.toObject = function(includeInstance, msg) {
key: jspb.Message.getFieldWithDefault(msg, 6, ""), key: jspb.Message.getFieldWithDefault(msg, 6, ""),
badge: jspb.Message.getFieldWithDefault(msg, 7, 0), badge: jspb.Message.getFieldWithDefault(msg, 7, 0),
category: jspb.Message.getFieldWithDefault(msg, 8, ""), category: jspb.Message.getFieldWithDefault(msg, 8, ""),
alert: (f = msg.getAlert()) && proto.proto.NotificationRequest.Alert.toObject(includeInstance, f) alert: (f = msg.getAlert()) && proto.proto.Alert.toObject(includeInstance, f)
}; };
if (includeInstance) { if (includeInstance) {
@ -146,8 +340,8 @@ proto.proto.NotificationRequest.deserializeBinaryFromReader = function(msg, read
msg.setCategory(value); msg.setCategory(value);
break; break;
case 9: case 9:
var value = new proto.proto.NotificationRequest.Alert; var value = new proto.proto.Alert;
reader.readMessage(value,proto.proto.NotificationRequest.Alert.deserializeBinaryFromReader); reader.readMessage(value,proto.proto.Alert.deserializeBinaryFromReader);
msg.setAlert(value); msg.setAlert(value);
break; break;
default: default:
@ -239,206 +433,12 @@ proto.proto.NotificationRequest.serializeBinaryToWriter = function(message, writ
writer.writeMessage( writer.writeMessage(
9, 9,
f, f,
proto.proto.NotificationRequest.Alert.serializeBinaryToWriter proto.proto.Alert.serializeBinaryToWriter
); );
} }
}; };
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.proto.NotificationRequest.Alert = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.proto.NotificationRequest.Alert, jspb.Message);
if (goog.DEBUG && !COMPILED) {
proto.proto.NotificationRequest.Alert.displayName = 'proto.proto.NotificationRequest.Alert';
}
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.proto.NotificationRequest.Alert.prototype.toObject = function(opt_includeInstance) {
return proto.proto.NotificationRequest.Alert.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.proto.NotificationRequest.Alert} msg The msg instance to transform.
* @return {!Object}
*/
proto.proto.NotificationRequest.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, "")
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}
/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.proto.NotificationRequest.Alert}
*/
proto.proto.NotificationRequest.Alert.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.proto.NotificationRequest.Alert;
return proto.proto.NotificationRequest.Alert.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.proto.NotificationRequest.Alert} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.proto.NotificationRequest.Alert}
*/
proto.proto.NotificationRequest.Alert.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {string} */ (reader.readString());
msg.setTitle(value);
break;
case 2:
var value = /** @type {string} */ (reader.readString());
msg.setBody(value);
break;
case 3:
var value = /** @type {string} */ (reader.readString());
msg.setSubtitle(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.proto.NotificationRequest.Alert.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.proto.NotificationRequest.Alert.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.proto.NotificationRequest.Alert} message
* @param {!jspb.BinaryWriter} writer
*/
proto.proto.NotificationRequest.Alert.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getTitle();
if (f.length > 0) {
writer.writeString(
1,
f
);
}
f = message.getBody();
if (f.length > 0) {
writer.writeString(
2,
f
);
}
f = message.getSubtitle();
if (f.length > 0) {
writer.writeString(
3,
f
);
}
};
/**
* optional string title = 1;
* @return {string}
*/
proto.proto.NotificationRequest.Alert.prototype.getTitle = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, ""));
};
/** @param {string} value */
proto.proto.NotificationRequest.Alert.prototype.setTitle = function(value) {
jspb.Message.setField(this, 1, value);
};
/**
* optional string body = 2;
* @return {string}
*/
proto.proto.NotificationRequest.Alert.prototype.getBody = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
};
/** @param {string} value */
proto.proto.NotificationRequest.Alert.prototype.setBody = function(value) {
jspb.Message.setField(this, 2, value);
};
/**
* optional string subtitle = 3;
* @return {string}
*/
proto.proto.NotificationRequest.Alert.prototype.getSubtitle = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
};
/** @param {string} value */
proto.proto.NotificationRequest.Alert.prototype.setSubtitle = function(value) {
jspb.Message.setField(this, 3, value);
};
/** /**
* repeated string tokens = 1; * repeated string tokens = 1;
* If you change this array by adding, removing or replacing elements, or if you * If you change this array by adding, removing or replacing elements, or if you
@ -577,15 +577,15 @@ proto.proto.NotificationRequest.prototype.setCategory = function(value) {
/** /**
* optional Alert alert = 9; * optional Alert alert = 9;
* @return {?proto.proto.NotificationRequest.Alert} * @return {?proto.proto.Alert}
*/ */
proto.proto.NotificationRequest.prototype.getAlert = function() { proto.proto.NotificationRequest.prototype.getAlert = function() {
return /** @type{?proto.proto.NotificationRequest.Alert} */ ( return /** @type{?proto.proto.Alert} */ (
jspb.Message.getWrapperField(this, proto.proto.NotificationRequest.Alert, 9)); jspb.Message.getWrapperField(this, proto.proto.Alert, 9));
}; };
/** @param {?proto.proto.NotificationRequest.Alert|undefined} value */ /** @param {?proto.proto.Alert|undefined} value */
proto.proto.NotificationRequest.prototype.setAlert = function(value) { proto.proto.NotificationRequest.prototype.setAlert = function(value) {
jspb.Message.setWrapperField(this, 9, value); jspb.Message.setWrapperField(this, 9, value);
}; };

View File

@ -8,6 +8,7 @@ It is generated from these files:
gorush.proto gorush.proto
It has these top-level messages: It has these top-level messages:
Alert
NotificationRequest NotificationRequest
NotificationReply NotificationReply
HealthCheckRequest HealthCheckRequest
@ -58,25 +59,57 @@ func (x HealthCheckResponse_ServingStatus) String() string {
return proto1.EnumName(HealthCheckResponse_ServingStatus_name, int32(x)) return proto1.EnumName(HealthCheckResponse_ServingStatus_name, int32(x))
} }
func (HealthCheckResponse_ServingStatus) EnumDescriptor() ([]byte, []int) { func (HealthCheckResponse_ServingStatus) EnumDescriptor() ([]byte, []int) {
return fileDescriptor0, []int{3, 0} return fileDescriptor0, []int{4, 0}
}
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"`
}
func (m *Alert) Reset() { *m = Alert{} }
func (m *Alert) String() string { return proto1.CompactTextString(m) }
func (*Alert) ProtoMessage() {}
func (*Alert) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *Alert) GetTitle() string {
if m != nil {
return m.Title
}
return ""
}
func (m *Alert) GetBody() string {
if m != nil {
return m.Body
}
return ""
}
func (m *Alert) GetSubtitle() string {
if m != nil {
return m.Subtitle
}
return ""
} }
type NotificationRequest struct { type NotificationRequest struct {
Tokens []string `protobuf:"bytes,1,rep,name=tokens" json:"tokens,omitempty"` Tokens []string `protobuf:"bytes,1,rep,name=tokens" json:"tokens,omitempty"`
Platform int32 `protobuf:"varint,2,opt,name=platform" json:"platform,omitempty"` Platform int32 `protobuf:"varint,2,opt,name=platform" json:"platform,omitempty"`
Message string `protobuf:"bytes,3,opt,name=message" json:"message,omitempty"` Message string `protobuf:"bytes,3,opt,name=message" json:"message,omitempty"`
Title string `protobuf:"bytes,4,opt,name=title" json:"title,omitempty"` Title string `protobuf:"bytes,4,opt,name=title" json:"title,omitempty"`
Topic string `protobuf:"bytes,5,opt,name=topic" json:"topic,omitempty"` Topic string `protobuf:"bytes,5,opt,name=topic" json:"topic,omitempty"`
Key string `protobuf:"bytes,6,opt,name=key" json:"key,omitempty"` Key string `protobuf:"bytes,6,opt,name=key" json:"key,omitempty"`
Badge int32 `protobuf:"varint,7,opt,name=badge" json:"badge,omitempty"` Badge int32 `protobuf:"varint,7,opt,name=badge" json:"badge,omitempty"`
Category string `protobuf:"bytes,8,opt,name=category" json:"category,omitempty"` Category string `protobuf:"bytes,8,opt,name=category" json:"category,omitempty"`
Alert *NotificationRequest_Alert `protobuf:"bytes,9,opt,name=alert" json:"alert,omitempty"` Alert *Alert `protobuf:"bytes,9,opt,name=alert" json:"alert,omitempty"`
} }
func (m *NotificationRequest) Reset() { *m = NotificationRequest{} } func (m *NotificationRequest) Reset() { *m = NotificationRequest{} }
func (m *NotificationRequest) String() string { return proto1.CompactTextString(m) } func (m *NotificationRequest) String() string { return proto1.CompactTextString(m) }
func (*NotificationRequest) ProtoMessage() {} func (*NotificationRequest) ProtoMessage() {}
func (*NotificationRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } func (*NotificationRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *NotificationRequest) GetTokens() []string { func (m *NotificationRequest) GetTokens() []string {
if m != nil { if m != nil {
@ -134,45 +167,13 @@ func (m *NotificationRequest) GetCategory() string {
return "" return ""
} }
func (m *NotificationRequest) GetAlert() *NotificationRequest_Alert { func (m *NotificationRequest) GetAlert() *Alert {
if m != nil { if m != nil {
return m.Alert return m.Alert
} }
return nil return nil
} }
type NotificationRequest_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"`
}
func (m *NotificationRequest_Alert) Reset() { *m = NotificationRequest_Alert{} }
func (m *NotificationRequest_Alert) String() string { return proto1.CompactTextString(m) }
func (*NotificationRequest_Alert) ProtoMessage() {}
func (*NotificationRequest_Alert) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0, 0} }
func (m *NotificationRequest_Alert) GetTitle() string {
if m != nil {
return m.Title
}
return ""
}
func (m *NotificationRequest_Alert) GetBody() string {
if m != nil {
return m.Body
}
return ""
}
func (m *NotificationRequest_Alert) GetSubtitle() string {
if m != nil {
return m.Subtitle
}
return ""
}
type NotificationReply struct { type NotificationReply struct {
Success bool `protobuf:"varint,1,opt,name=success" json:"success,omitempty"` Success bool `protobuf:"varint,1,opt,name=success" json:"success,omitempty"`
Counts int32 `protobuf:"varint,2,opt,name=counts" json:"counts,omitempty"` Counts int32 `protobuf:"varint,2,opt,name=counts" json:"counts,omitempty"`
@ -181,7 +182,7 @@ type NotificationReply struct {
func (m *NotificationReply) Reset() { *m = NotificationReply{} } func (m *NotificationReply) Reset() { *m = NotificationReply{} }
func (m *NotificationReply) String() string { return proto1.CompactTextString(m) } func (m *NotificationReply) String() string { return proto1.CompactTextString(m) }
func (*NotificationReply) ProtoMessage() {} func (*NotificationReply) ProtoMessage() {}
func (*NotificationReply) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } func (*NotificationReply) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
func (m *NotificationReply) GetSuccess() bool { func (m *NotificationReply) GetSuccess() bool {
if m != nil { if m != nil {
@ -204,7 +205,7 @@ type HealthCheckRequest struct {
func (m *HealthCheckRequest) Reset() { *m = HealthCheckRequest{} } func (m *HealthCheckRequest) Reset() { *m = HealthCheckRequest{} }
func (m *HealthCheckRequest) String() string { return proto1.CompactTextString(m) } func (m *HealthCheckRequest) String() string { return proto1.CompactTextString(m) }
func (*HealthCheckRequest) ProtoMessage() {} func (*HealthCheckRequest) ProtoMessage() {}
func (*HealthCheckRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } func (*HealthCheckRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
func (m *HealthCheckRequest) GetService() string { func (m *HealthCheckRequest) GetService() string {
if m != nil { if m != nil {
@ -220,7 +221,7 @@ type HealthCheckResponse struct {
func (m *HealthCheckResponse) Reset() { *m = HealthCheckResponse{} } func (m *HealthCheckResponse) Reset() { *m = HealthCheckResponse{} }
func (m *HealthCheckResponse) String() string { return proto1.CompactTextString(m) } func (m *HealthCheckResponse) String() string { return proto1.CompactTextString(m) }
func (*HealthCheckResponse) ProtoMessage() {} func (*HealthCheckResponse) ProtoMessage() {}
func (*HealthCheckResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } func (*HealthCheckResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
func (m *HealthCheckResponse) GetStatus() HealthCheckResponse_ServingStatus { func (m *HealthCheckResponse) GetStatus() HealthCheckResponse_ServingStatus {
if m != nil { if m != nil {
@ -230,8 +231,8 @@ func (m *HealthCheckResponse) GetStatus() HealthCheckResponse_ServingStatus {
} }
func init() { func init() {
proto1.RegisterType((*Alert)(nil), "proto.Alert")
proto1.RegisterType((*NotificationRequest)(nil), "proto.NotificationRequest") proto1.RegisterType((*NotificationRequest)(nil), "proto.NotificationRequest")
proto1.RegisterType((*NotificationRequest_Alert)(nil), "proto.NotificationRequest.Alert")
proto1.RegisterType((*NotificationReply)(nil), "proto.NotificationReply") proto1.RegisterType((*NotificationReply)(nil), "proto.NotificationReply")
proto1.RegisterType((*HealthCheckRequest)(nil), "proto.HealthCheckRequest") proto1.RegisterType((*HealthCheckRequest)(nil), "proto.HealthCheckRequest")
proto1.RegisterType((*HealthCheckResponse)(nil), "proto.HealthCheckResponse") proto1.RegisterType((*HealthCheckResponse)(nil), "proto.HealthCheckResponse")
@ -377,32 +378,32 @@ var _Health_serviceDesc = grpc.ServiceDesc{
func init() { proto1.RegisterFile("gorush.proto", fileDescriptor0) } func init() { proto1.RegisterFile("gorush.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{ var fileDescriptor0 = []byte{
// 429 bytes of a gzipped FileDescriptorProto // 424 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xcf, 0x8e, 0x9b, 0x30, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xcf, 0x8e, 0xd3, 0x30,
0x10, 0xc6, 0x97, 0x24, 0x90, 0x64, 0xd2, 0x3f, 0xe9, 0x6c, 0x55, 0xb9, 0x9c, 0x10, 0x27, 0x4e, 0x10, 0xc6, 0x37, 0xdb, 0x26, 0x6d, 0xa7, 0x0b, 0x94, 0x59, 0x84, 0x4c, 0x4f, 0x95, 0x4f, 0x3d,
0x1c, 0x52, 0xa9, 0x87, 0x1e, 0x56, 0xad, 0xaa, 0xd5, 0x6e, 0x55, 0x95, 0x95, 0x9c, 0xfe, 0x39, 0xf5, 0x50, 0x6e, 0x1c, 0x56, 0x20, 0xb4, 0xda, 0x45, 0x88, 0xac, 0xe4, 0xf2, 0xe7, 0x88, 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x00, 0x00, 0xff, 0xff,
0x02, 0x00, 0x00, 0xff, 0xff, 0x56, 0xd0, 0x68, 0x0d, 0x1b, 0x03, 0x00, 0x00, 0xd4, 0x3a, 0x7f, 0x33, 0x07, 0x03, 0x00, 0x00,
} }

View File

@ -2,6 +2,12 @@ syntax = "proto3";
package proto; package proto;
message Alert {
string title = 1;
string body = 2;
string subtitle = 3;
}
message NotificationRequest { message NotificationRequest {
repeated string tokens = 1; repeated string tokens = 1;
int32 platform = 2; int32 platform = 2;
@ -11,11 +17,6 @@ message NotificationRequest {
string key = 6; string key = 6;
int32 badge = 7; int32 badge = 7;
string category = 8; string category = 8;
message Alert {
string title = 1;
string body = 2;
string subtitle = 3;
}
Alert alert = 9; Alert alert = 9;
} }

View File

@ -57,12 +57,18 @@ func (s *Server) Send(ctx context.Context, in *proto.NotificationRequest) (*prot
Topic: in.Topic, Topic: in.Topic,
APIKey: in.Key, APIKey: in.Key,
Category: in.Category, Category: in.Category,
Badge: &badge, }
Alert: gorush.Alert{
if badge > 0 {
notification.Badge = &badge
}
if in.Alert != nil {
notification.Alert = gorush.Alert{
Title: in.Alert.Title, Title: in.Alert.Title,
Body: in.Alert.Body, Body: in.Alert.Body,
Subtitle: in.Alert.Subtitle, Subtitle: in.Alert.Subtitle,
}, }
} }
go gorush.SendNotification(notification) go gorush.SendNotification(notification)