Add more network methods

- followPeer & unfollowPeer
This commit is contained in:
Roj Serbest 2021-10-18 19:35:02 +03:00
parent 3bc0220535
commit 6ca934041c
1 changed files with 25 additions and 1 deletions

View File

@ -1,5 +1,5 @@
import { Request } from "../request.ts";
import { Peer, Profile } from "../types.ts";
import { Peer, Profile, RelationshipType } from "../types.ts";
import { MethodBase } from "./method_base.ts";
export class Network extends MethodBase {
@ -53,4 +53,28 @@ export class Network extends MethodBase {
true,
);
}
/**
* Follows another peer on the network.
*/
followPeer(peer: string | Peer): Promise<RelationshipType> {
return this.client.invokeRequest(
new Request("network.follow_peer", {
peer: typeof peer == "string" ? peer : peer.id,
}),
true,
);
}
/**
* Unfollows another peer on the network.
*/
unfollowPeer(peer: string | Peer): Promise<RelationshipType> {
return this.client.invokeRequest(
new Request("network.unfollow_peer", {
peer: typeof peer == "string" ? peer : peer.id,
}),
true,
);
}
}