add ability to send sms in emoji (#165)

This commit is contained in:
Asim Aslam
2021-06-17 18:24:54 +01:00
committed by GitHub
parent a71e51581a
commit e258e98ba5
7 changed files with 291 additions and 22 deletions

View File

@@ -20,12 +20,13 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// Find an alias and return the emoji
// Find an emoji by its alias e.g :beer:
type FindRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// the alias code e.g :beer:
Alias string `protobuf:"bytes,1,opt,name=alias,proto3" json:"alias,omitempty"`
}
@@ -73,6 +74,7 @@ type FindResponse struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// the unicode emoji 🍺
Emoji string `protobuf:"bytes,2,opt,name=emoji,proto3" json:"emoji,omitempty"`
}
@@ -121,6 +123,7 @@ type FlagRequest struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// country code e.g GB
Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"`
}
@@ -168,6 +171,7 @@ type FlagResponse struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// the emoji flag
Flag string `protobuf:"bytes,2,opt,name=flag,proto3" json:"flag,omitempty"`
}
@@ -308,6 +312,121 @@ func (x *PrintResponse) GetText() string {
return ""
}
// Send an emoji to anyone via SMS
type SendRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// who the message is from e.g Alice
From string `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"`
// phone number to send to (including international dialing code)
To string `protobuf:"bytes,2,opt,name=to,proto3" json:"to,omitempty"`
// message to send including emoji aliases
Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"`
}
func (x *SendRequest) Reset() {
*x = SendRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_emoji_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SendRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SendRequest) ProtoMessage() {}
func (x *SendRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_emoji_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SendRequest.ProtoReflect.Descriptor instead.
func (*SendRequest) Descriptor() ([]byte, []int) {
return file_proto_emoji_proto_rawDescGZIP(), []int{6}
}
func (x *SendRequest) GetFrom() string {
if x != nil {
return x.From
}
return ""
}
func (x *SendRequest) GetTo() string {
if x != nil {
return x.To
}
return ""
}
func (x *SendRequest) GetMessage() string {
if x != nil {
return x.Message
}
return ""
}
type SendResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// whether or not it succeeded
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
}
func (x *SendResponse) Reset() {
*x = SendResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_emoji_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SendResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SendResponse) ProtoMessage() {}
func (x *SendResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_emoji_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SendResponse.ProtoReflect.Descriptor instead.
func (*SendResponse) Descriptor() ([]byte, []int) {
return file_proto_emoji_proto_rawDescGZIP(), []int{7}
}
func (x *SendResponse) GetSuccess() bool {
if x != nil {
return x.Success
}
return false
}
var File_proto_emoji_proto protoreflect.FileDescriptor
var file_proto_emoji_proto_rawDesc = []byte{
@@ -326,19 +445,29 @@ var file_proto_emoji_proto_rawDesc = []byte{
0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74,
0x22, 0x23, 0x0a, 0x0d, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x04, 0x74, 0x65, 0x78, 0x74, 0x32, 0xa3, 0x01, 0x0a, 0x05, 0x45, 0x6d, 0x6f, 0x6a, 0x69, 0x12,
0x31, 0x0a, 0x04, 0x46, 0x69, 0x6e, 0x64, 0x12, 0x12, 0x2e, 0x65, 0x6d, 0x6f, 0x6a, 0x69, 0x2e,
0x46, 0x69, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x65, 0x6d,
0x6f, 0x6a, 0x69, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x12, 0x31, 0x0a, 0x04, 0x46, 0x6c, 0x61, 0x67, 0x12, 0x12, 0x2e, 0x65, 0x6d, 0x6f,
0x6a, 0x69, 0x2e, 0x46, 0x6c, 0x61, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13,
0x2e, 0x65, 0x6d, 0x6f, 0x6a, 0x69, 0x2e, 0x46, 0x6c, 0x61, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x34, 0x0a, 0x05, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x12, 0x13,
0x2e, 0x65, 0x6d, 0x6f, 0x6a, 0x69, 0x2e, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x65, 0x6d, 0x6f, 0x6a, 0x69, 0x2e, 0x50, 0x72, 0x69, 0x6e,
0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0f, 0x5a, 0x0d, 0x2e,
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x65, 0x6d, 0x6f, 0x6a, 0x69, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0x4b, 0x0a, 0x0b, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x74, 0x6f, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73,
0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x22, 0x28, 0x0a, 0x0c, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20,
0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x32, 0xd6, 0x01, 0x0a,
0x05, 0x45, 0x6d, 0x6f, 0x6a, 0x69, 0x12, 0x31, 0x0a, 0x04, 0x46, 0x69, 0x6e, 0x64, 0x12, 0x12,
0x2e, 0x65, 0x6d, 0x6f, 0x6a, 0x69, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x13, 0x2e, 0x65, 0x6d, 0x6f, 0x6a, 0x69, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x31, 0x0a, 0x04, 0x46, 0x6c, 0x61,
0x67, 0x12, 0x12, 0x2e, 0x65, 0x6d, 0x6f, 0x6a, 0x69, 0x2e, 0x46, 0x6c, 0x61, 0x67, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x65, 0x6d, 0x6f, 0x6a, 0x69, 0x2e, 0x46, 0x6c,
0x61, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x34, 0x0a, 0x05,
0x50, 0x72, 0x69, 0x6e, 0x74, 0x12, 0x13, 0x2e, 0x65, 0x6d, 0x6f, 0x6a, 0x69, 0x2e, 0x50, 0x72,
0x69, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x65, 0x6d, 0x6f,
0x6a, 0x69, 0x2e, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x12, 0x31, 0x0a, 0x04, 0x53, 0x65, 0x6e, 0x64, 0x12, 0x12, 0x2e, 0x65, 0x6d, 0x6f,
0x6a, 0x69, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13,
0x2e, 0x65, 0x6d, 0x6f, 0x6a, 0x69, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0f, 0x5a, 0x0d, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x3b, 0x65, 0x6d, 0x6f, 0x6a, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -353,7 +482,7 @@ func file_proto_emoji_proto_rawDescGZIP() []byte {
return file_proto_emoji_proto_rawDescData
}
var file_proto_emoji_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_proto_emoji_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_proto_emoji_proto_goTypes = []interface{}{
(*FindRequest)(nil), // 0: emoji.FindRequest
(*FindResponse)(nil), // 1: emoji.FindResponse
@@ -361,16 +490,20 @@ var file_proto_emoji_proto_goTypes = []interface{}{
(*FlagResponse)(nil), // 3: emoji.FlagResponse
(*PrintRequest)(nil), // 4: emoji.PrintRequest
(*PrintResponse)(nil), // 5: emoji.PrintResponse
(*SendRequest)(nil), // 6: emoji.SendRequest
(*SendResponse)(nil), // 7: emoji.SendResponse
}
var file_proto_emoji_proto_depIdxs = []int32{
0, // 0: emoji.Emoji.Find:input_type -> emoji.FindRequest
2, // 1: emoji.Emoji.Flag:input_type -> emoji.FlagRequest
4, // 2: emoji.Emoji.Print:input_type -> emoji.PrintRequest
1, // 3: emoji.Emoji.Find:output_type -> emoji.FindResponse
3, // 4: emoji.Emoji.Flag:output_type -> emoji.FlagResponse
5, // 5: emoji.Emoji.Print:output_type -> emoji.PrintResponse
3, // [3:6] is the sub-list for method output_type
0, // [0:3] is the sub-list for method input_type
6, // 3: emoji.Emoji.Send:input_type -> emoji.SendRequest
1, // 4: emoji.Emoji.Find:output_type -> emoji.FindResponse
3, // 5: emoji.Emoji.Flag:output_type -> emoji.FlagResponse
5, // 6: emoji.Emoji.Print:output_type -> emoji.PrintResponse
7, // 7: emoji.Emoji.Send:output_type -> emoji.SendResponse
4, // [4:8] is the sub-list for method output_type
0, // [0:4] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
@@ -454,6 +587,30 @@ func file_proto_emoji_proto_init() {
return nil
}
}
file_proto_emoji_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SendRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_emoji_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SendResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@@ -461,7 +618,7 @@ func file_proto_emoji_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_proto_emoji_proto_rawDesc,
NumEnums: 0,
NumMessages: 6,
NumMessages: 8,
NumExtensions: 0,
NumServices: 1,
},

View File

@@ -45,6 +45,7 @@ type EmojiService interface {
Find(ctx context.Context, in *FindRequest, opts ...client.CallOption) (*FindResponse, error)
Flag(ctx context.Context, in *FlagRequest, opts ...client.CallOption) (*FlagResponse, error)
Print(ctx context.Context, in *PrintRequest, opts ...client.CallOption) (*PrintResponse, error)
Send(ctx context.Context, in *SendRequest, opts ...client.CallOption) (*SendResponse, error)
}
type emojiService struct {
@@ -89,12 +90,23 @@ func (c *emojiService) Print(ctx context.Context, in *PrintRequest, opts ...clie
return out, nil
}
func (c *emojiService) Send(ctx context.Context, in *SendRequest, opts ...client.CallOption) (*SendResponse, error) {
req := c.c.NewRequest(c.name, "Emoji.Send", in)
out := new(SendResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for Emoji service
type EmojiHandler interface {
Find(context.Context, *FindRequest, *FindResponse) error
Flag(context.Context, *FlagRequest, *FlagResponse) error
Print(context.Context, *PrintRequest, *PrintResponse) error
Send(context.Context, *SendRequest, *SendResponse) error
}
func RegisterEmojiHandler(s server.Server, hdlr EmojiHandler, opts ...server.HandlerOption) error {
@@ -102,6 +114,7 @@ func RegisterEmojiHandler(s server.Server, hdlr EmojiHandler, opts ...server.Han
Find(ctx context.Context, in *FindRequest, out *FindResponse) error
Flag(ctx context.Context, in *FlagRequest, out *FlagResponse) error
Print(ctx context.Context, in *PrintRequest, out *PrintResponse) error
Send(ctx context.Context, in *SendRequest, out *SendResponse) error
}
type Emoji struct {
emoji
@@ -125,3 +138,7 @@ func (h *emojiHandler) Flag(ctx context.Context, in *FlagRequest, out *FlagRespo
func (h *emojiHandler) Print(ctx context.Context, in *PrintRequest, out *PrintResponse) error {
return h.EmojiHandler.Print(ctx, in, out)
}
func (h *emojiHandler) Send(ctx context.Context, in *SendRequest, out *SendResponse) error {
return h.EmojiHandler.Send(ctx, in, out)
}

View File

@@ -8,6 +8,7 @@ service Emoji {
rpc Find(FindRequest) returns (FindResponse) {}
rpc Flag(FlagRequest) returns (FlagResponse) {}
rpc Print(PrintRequest) returns (PrintResponse) {}
rpc Send(SendRequest) returns (SendResponse) {}
}
// Find an emoji by its alias e.g :beer:
@@ -43,3 +44,18 @@ message PrintResponse {
// text with rendered emojis
string text = 1;
}
// Send an emoji to anyone via SMS
message SendRequest {
// who the message is from e.g Alice
string from = 1;
// phone number to send to (including international dialing code)
string to = 2;
// message to send including emoji aliases
string message = 3;
}
message SendResponse {
// whether or not it succeeded
bool success = 1;
}