Skip to content
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

Feat post publish #181

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions commonjs/generated/puppet.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const puppetFileList = [
'../../out/wechaty/puppet/room-member_pb.js',
'../../out/wechaty/puppet/tag_pb.js',
'../../out/wechaty/puppet/url-link_pb.js',
'../../out/wechaty/puppet/post_pb.js',
'../../out/wechaty/puppet/tap_pb.js',
'../../out/wechaty/puppet/pagination_pb.js',

'../../out/wechaty/puppet_grpc_pb.js',
'../../out/wechaty/puppet_pb.js',
Expand Down
3 changes: 3 additions & 0 deletions commonjs/generated/puppet.cjs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export * from '../../out/wechaty/puppet/room-invitation_pb.js'
export * from '../../out/wechaty/puppet/room-member_pb.js'
export * from '../../out/wechaty/puppet/tag_pb.js'
export * from '../../out/wechaty/puppet/url-link_pb.js'
export * from '../../out/wechaty/puppet/post_pb.js'
export * from '../../out/wechaty/puppet/tap_pb.js'
export * from '../../out/wechaty/puppet/pagination_pb.js'

export * from '../../out/wechaty/puppet_grpc_pb.js'
export * from '../../out/wechaty/puppet_pb.js'
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";
import "wechaty/puppet/conversation.proto";

option java_package="io.github.wechaty.grpc";
Expand Down Expand Up @@ -484,6 +485,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
1 change: 1 addition & 0 deletions proto/wechaty/puppet/base.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ enum PayloadType {
PAYLOAD_TYPE_ROOM = 3;
PAYLOAD_TYPE_ROOM_MEMBER = 4;
PAYLOAD_TYPE_FRIENDSHIP = 5;
PAYLOAD_TYPE_POSY = 6;
}

message StartRequest {}
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;
}
99 changes: 99 additions & 0 deletions proto/wechaty/puppet/post.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
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 = 2;

optional string parentId = 3;
optional string root_id = 4;
optional PostType type = 5;

string contact_id = 6;
int32 timestamp = 7;

Counter counter = 8;
}

message PostPayloadClient {
string id = 1;
repeated string sayable = 2;

optional string parentId = 3;
optional string root_id = 4;
optional PostType type = 5;
}

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
Loading