Skip to content

Commit

Permalink
chore(gRPC): add PushType and Development (#702)
Browse files Browse the repository at this point in the history
fix #697
  • Loading branch information
appleboy committed Dec 17, 2022
1 parent a8ad48c commit 1d839f5
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 34 deletions.
95 changes: 93 additions & 2 deletions rpc/example/node/gorush_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/**
* @fileoverview
* @enhanceable
* @suppress {missingRequire} reports error on implicit type usages.
* @suppress {messageConventions} JS Compiler reports an error if a variable or
* field starts with 'MSG_' and isn't a translatable message.
* @public
Expand All @@ -12,7 +13,7 @@

var jspb = require('google-protobuf');
var goog = jspb;
var global = Function('return this')();
var global = (function() { return this || window || global || self || Function('return this')(); }).call(null);

var google_protobuf_struct_pb = require('google-protobuf/google/protobuf/struct_pb.js');
goog.object.extend(proto, google_protobuf_struct_pb);
Expand Down Expand Up @@ -627,7 +628,10 @@ proto.proto.NotificationRequest.toObject = function(includeInstance, msg) {
mutablecontent: jspb.Message.getBooleanFieldWithDefault(msg, 13, false),
data: (f = msg.getData()) && google_protobuf_struct_pb.Struct.toObject(includeInstance, f),
image: jspb.Message.getFieldWithDefault(msg, 15, ""),
priority: jspb.Message.getFieldWithDefault(msg, 16, 0)
priority: jspb.Message.getFieldWithDefault(msg, 16, 0),
id: jspb.Message.getFieldWithDefault(msg, 17, ""),
pushtype: jspb.Message.getFieldWithDefault(msg, 18, ""),
development: jspb.Message.getBooleanFieldWithDefault(msg, 19, false)
};

if (includeInstance) {
Expand Down Expand Up @@ -730,6 +734,18 @@ proto.proto.NotificationRequest.deserializeBinaryFromReader = function(msg, read
var value = /** @type {!proto.proto.NotificationRequest.Priority} */ (reader.readEnum());
msg.setPriority(value);
break;
case 17:
var value = /** @type {string} */ (reader.readString());
msg.setId(value);
break;
case 18:
var value = /** @type {string} */ (reader.readString());
msg.setPushtype(value);
break;
case 19:
var value = /** @type {boolean} */ (reader.readBool());
msg.setDevelopment(value);
break;
default:
reader.skipField();
break;
Expand Down Expand Up @@ -873,6 +889,27 @@ proto.proto.NotificationRequest.serializeBinaryToWriter = function(message, writ
f
);
}
f = message.getId();
if (f.length > 0) {
writer.writeString(
17,
f
);
}
f = message.getPushtype();
if (f.length > 0) {
writer.writeString(
18,
f
);
}
f = message.getDevelopment();
if (f) {
writer.writeBool(
19,
f
);
}
};


Expand Down Expand Up @@ -1229,6 +1266,60 @@ proto.proto.NotificationRequest.prototype.setPriority = function(value) {
};


/**
* optional string ID = 17;
* @return {string}
*/
proto.proto.NotificationRequest.prototype.getId = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 17, ""));
};


/**
* @param {string} value
* @return {!proto.proto.NotificationRequest} returns this
*/
proto.proto.NotificationRequest.prototype.setId = function(value) {
return jspb.Message.setProto3StringField(this, 17, value);
};


/**
* optional string pushType = 18;
* @return {string}
*/
proto.proto.NotificationRequest.prototype.getPushtype = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 18, ""));
};


/**
* @param {string} value
* @return {!proto.proto.NotificationRequest} returns this
*/
proto.proto.NotificationRequest.prototype.setPushtype = function(value) {
return jspb.Message.setProto3StringField(this, 18, value);
};


/**
* optional bool development = 19;
* @return {boolean}
*/
proto.proto.NotificationRequest.prototype.getDevelopment = function() {
return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 19, false));
};


/**
* @param {boolean} value
* @return {!proto.proto.NotificationRequest} returns this
*/
proto.proto.NotificationRequest.prototype.setDevelopment = function(value) {
return jspb.Message.setProto3BooleanField(this, 19, value);
};





Expand Down
85 changes: 53 additions & 32 deletions rpc/proto/gorush.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rpc/proto/gorush.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ message NotificationRequest {
}
Priority priority = 16;
string ID = 17;
string pushType = 18;
// default is production
bool development = 19;
}

message NotificationReply {
Expand Down
2 changes: 2 additions & 0 deletions rpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ func (s *Server) Send(ctx context.Context, in *proto.NotificationRequest) (*prot
MutableContent: in.MutableContent,
Image: in.Image,
Priority: strings.ToLower(in.GetPriority().String()),
PushType: in.PushType,
Development: in.Development,
}

if badge > 0 {
Expand Down

0 comments on commit 1d839f5

Please sign in to comment.