Merge pull request #12 from matrix-org/kegan/api-put-state-event

Add PUT /room/roomId/state/type/key endpoint
This commit is contained in:
Kegsay 2017-01-05 17:29:02 +00:00 committed by GitHub
commit fd0a0c56cc
1 changed files with 8 additions and 0 deletions

View File

@ -393,6 +393,14 @@ func (cli *Client) SendMessageEvent(roomID string, eventType string, contentJSON
return return
} }
// SendStateEvent sends a state event into a room. See http://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype-statekey
// contentJSON should be a pointer to something that can be encoded as JSON using json.Marshal.
func (cli *Client) SendStateEvent(roomID, eventType, stateKey string, contentJSON interface{}) (resp *RespSendEvent, err error) {
urlPath := cli.BuildURL("rooms", roomID, "state", eventType, stateKey)
_, err = cli.MakeRequest("PUT", urlPath, contentJSON, &resp)
return
}
// SendText sends an m.room.message event into the given room with a msgtype of m.text // SendText sends an m.room.message event into the given room with a msgtype of m.text
// See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-text // See http://matrix.org/docs/spec/client_server/r0.2.0.html#m-text
func (cli *Client) SendText(roomID, text string) (*RespSendEvent, error) { func (cli *Client) SendText(roomID, text string) (*RespSendEvent, error) {