Add missing GRPC data field (#412)
* feat(grpc): add support for data field in request body * docs: update Readme with embedmd
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
structpb "github.com/golang/protobuf/ptypes/struct"
|
||||
"log"
|
||||
|
||||
"github.com/appleboy/gorush/rpc/proto"
|
||||
@@ -36,6 +37,16 @@ func main() {
|
||||
LocKey: "Test loc key",
|
||||
LocArgs: []string{"test", "test"},
|
||||
},
|
||||
Data: &structpb.Struct{
|
||||
Fields: map[string]*structpb.Value{
|
||||
"key1": {
|
||||
Kind: &structpb.Value_StringValue{StringValue: "welcome"},
|
||||
},
|
||||
"key2": {
|
||||
Kind: &structpb.Value_NumberValue{NumberValue: 2},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("could not greet: %v", err)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,5 @@
|
||||
syntax = "proto3";
|
||||
import "google/protobuf/struct.proto";
|
||||
|
||||
package proto;
|
||||
|
||||
@@ -29,6 +30,7 @@ message NotificationRequest {
|
||||
bool contentAvailable = 11;
|
||||
string threadID = 12;
|
||||
bool mutableContent = 13;
|
||||
google.protobuf.Struct data = 14;
|
||||
}
|
||||
|
||||
message NotificationReply {
|
||||
|
||||
@@ -82,6 +82,13 @@ func (s *Server) Send(ctx context.Context, in *proto.NotificationRequest) (*prot
|
||||
}
|
||||
}
|
||||
|
||||
if in.Data != nil {
|
||||
notification.Data = map[string]interface{}{}
|
||||
for k, v := range in.Data.Fields {
|
||||
notification.Data[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
go gorush.SendNotification(notification)
|
||||
|
||||
return &proto.NotificationReply{
|
||||
|
||||
Reference in New Issue
Block a user