Skip to content

Feat post publish #181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wechaty-grpc",
"version": "1.5.2",
"version": "1.5.3",
"description": "gRPC for Wechaty",
"type": "module",
"exports": {
Expand Down
23 changes: 23 additions & 0 deletions proto/wechaty/puppet.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import "wechaty/puppet/room-invitation.proto";
import "wechaty/puppet/room-member.proto";
import "wechaty/puppet/room.proto";
import "wechaty/puppet/tag.proto";
import "wechaty/puppet/post.proto";

option java_package="io.github.wechaty.grpc";
option go_package="github.com/wechaty/go-grpc/wechaty";
Expand Down Expand Up @@ -471,6 +472,28 @@ service Puppet {
};
}

/**
*
* Post
*
*/
rpc PostPayload (puppet.PostPayloadRequest) returns (puppet.PostPayloadResponse) {
option (google.api.http) = {
get: "/posts/{id}"
};
}

rpc PostSearch (puppet.PostSearchRequest) returns (puppet.PostSearchResponse) {
}

rpc PostPublish (puppet.PostPublishRequest) returns (puppet.PostPublishResponse) {
option (google.api.http) = {
post: "/posts/publish"
body: "*"
};
}


/**
* Operate Sub-Collections
* https://cloud.google.com/apis/design/design_patterns#list_sub-collections
Expand Down
11 changes: 11 additions & 0 deletions proto/wechaty/puppet/pagination.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";
package wechaty.puppet;

option go_package="github.com/wechaty/go-grpc/wechaty/puppet";
option java_package="io.github.wechaty.grpc.puppet";
option csharp_namespace = "github.wechaty.grpc.puppet";

message PaginationRequest {
optional int32 page_size = 1;
optional string page_token = 2;
}
91 changes: 91 additions & 0 deletions proto/wechaty/puppet/post.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
syntax = "proto3";
package wechaty.puppet;

option go_package="github.com/wechaty/go-grpc/wechaty/puppet";
option java_package="io.github.wechaty.grpc.puppet";
option csharp_namespace = "github.wechaty.grpc.puppet";

import "google/protobuf/timestamp.proto";

/**
* @deprecated
* Huan(202109): will be removed after Dec 31, 2022
* https://cloud.google.com/apis/design/design_patterns#optional_primitive_fields
*/
import "google/protobuf/wrappers.proto";

import "wechaty/puppet/tap.proto";
import "wechaty/puppet/pagination.proto";

enum PostType {
POST_TYPE_UNSPECIFIED = 0;

POST_TYPE_MOMENT = 1;
POST_TYPE_CHANNEL = 2;
POST_TYPE_MESSAGE = 3;
}

message Counter {
optional int32 children = 1;
optional int32 descendant = 2;

Taps taps = 3;
}

message PostPayloadRequest {
string id = 1;
}

message PostPayloadResponse {
oneof PostPayload {
PostPayloadServer post_payload_server = 1;
PostPayloadClient post_payload_client = 2;
}
}

message PostSearchRequest {
PostQueryFilter filter = 1;
optional PaginationRequest pagination = 2;
}

message PostSearchResponse {
optional string next_page_token = 1;
repeated string response = 2;
}

message PostPublishRequest {
oneof PostPayload {
PostPayloadServer post_payload_server = 1;
PostPayloadClient post_payload_client = 2;
}
}

message PostPublishResponse {
optional string id = 1;
}


message PostPayloadServer {
string id = 1;
repeated string sayable_list = 2;

string contact_id = 3;
int32 timestamp = 4;

Counter counter = 5;
}

message PostPayloadClient {
string id = 1;
repeated string sayable_list = 2;
}

message PostQueryFilter {
optional string contact_id = 1;
optional string id = 2;
optional string order_by = 3;
optional string parent_id = 4;
optional string root_id = 5;
optional PostType type = 6;
}

16 changes: 16 additions & 0 deletions proto/wechaty/puppet/tap.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";
package wechaty.puppet;

option go_package="github.com/wechaty/go-grpc/wechaty/puppet";
option java_package="io.github.wechaty.grpc.puppet";
option csharp_namespace = "github.wechaty.grpc.puppet";

enum TapType {
TAP_TYPE_UNSPECIFIED = 0;
TAP_TYPE_LIKE = 1;
}

message Taps {
optional int32 unspecified = 1;
optional int32 like = 2;
}
18 changes: 18 additions & 0 deletions tests/puppet-server-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,24 @@ export const puppetServerImpl: IPuppetServer = {
throw new Error('not implemented.')
},

postPayload: (call, callback) => {
void call
void callback
throw new Error('not implemented.')
},

postSearch: (call, callback) => {
void call
void callback
throw new Error('not implemented.')
},

postPublish: (call, callback) => {
void call
void callback
throw new Error('not implemented.')
},

version: (call, callback) => {
void call
void callback
Expand Down