mirror of
				https://github.com/matrix-org/gomatrix
				synced 2025-11-04 06:18:05 +00:00 
			
		
		
		
	Functions to send basic image and video events
This commit is contained in:
		
							parent
							
								
									4da59c5538
								
							
						
					
					
						commit
						4bc46014ae
					
				
					 2 changed files with 41 additions and 0 deletions
				
			
		
							
								
								
									
										22
									
								
								client.go
									
										
									
									
									
								
							
							
						
						
									
										22
									
								
								client.go
									
										
									
									
									
								
							| 
						 | 
					@ -450,6 +450,28 @@ func (cli *Client) SendText(roomID, text string) (*RespSendEvent, error) {
 | 
				
			||||||
		TextMessage{"m.text", text})
 | 
							TextMessage{"m.text", text})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// SendImage sends an m.room.message event into the given room with a msgtype of m.image
 | 
				
			||||||
 | 
					// See https://matrix.org/docs/spec/client_server/r0.2.0.html#m-image
 | 
				
			||||||
 | 
					func (cli *Client) SendImage(roomID, body string, url string) (*RespSendEvent, error) {
 | 
				
			||||||
 | 
						return cli.SendMessageEvent(roomID, "m.room.message",
 | 
				
			||||||
 | 
							ImageMessage{
 | 
				
			||||||
 | 
								MsgType: "m.image",
 | 
				
			||||||
 | 
								Body:    body,
 | 
				
			||||||
 | 
								URL:     url,
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// SendVideo sends an m.room.message event into the given room with a msgtype of m.video
 | 
				
			||||||
 | 
					// See https://matrix.org/docs/spec/client_server/r0.2.0.html#m-video
 | 
				
			||||||
 | 
					func (cli *Client) SendVideo(roomID, body string, url string) (*RespSendEvent, error) {
 | 
				
			||||||
 | 
						return cli.SendMessageEvent(roomID, "m.room.message",
 | 
				
			||||||
 | 
							VideoMessage{
 | 
				
			||||||
 | 
								MsgType: "m.video",
 | 
				
			||||||
 | 
								Body:    body,
 | 
				
			||||||
 | 
								URL:     url,
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// RedactEvent redacts the given event. See http://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-redact-eventid-txnid
 | 
					// RedactEvent redacts the given event. See http://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-redact-eventid-txnid
 | 
				
			||||||
func (cli *Client) RedactEvent(roomID, eventID string, req *ReqRedact) (resp *RespSendEvent, err error) {
 | 
					func (cli *Client) RedactEvent(roomID, eventID string, req *ReqRedact) (resp *RespSendEvent, err error) {
 | 
				
			||||||
	txnID := txnID()
 | 
						txnID := txnID()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										19
									
								
								events.go
									
										
									
									
									
								
							
							
						
						
									
										19
									
								
								events.go
									
										
									
									
									
								
							| 
						 | 
					@ -52,6 +52,25 @@ type ImageInfo struct {
 | 
				
			||||||
	Size     uint   `json:"size"`
 | 
						Size     uint   `json:"size"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// VideoInfo contains info about a video
 | 
				
			||||||
 | 
					type VideoInfo struct {
 | 
				
			||||||
 | 
						Mimetype      string    `json:"mimetype"`
 | 
				
			||||||
 | 
						ThumbnailInfo ImageInfo `json:"thumbnail_info"`
 | 
				
			||||||
 | 
						ThumbnailURL  string    `json:"thumbnail_url"`
 | 
				
			||||||
 | 
						Height        uint      `json:"h"`
 | 
				
			||||||
 | 
						Width         uint      `json:"w"`
 | 
				
			||||||
 | 
						Duration      uint      `json:"duration"`
 | 
				
			||||||
 | 
						Size          uint      `json:"size"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// VideoMessage is an m.video event
 | 
				
			||||||
 | 
					type VideoMessage struct {
 | 
				
			||||||
 | 
						MsgType string    `json:"msgtype"`
 | 
				
			||||||
 | 
						Body    string    `json:"body"`
 | 
				
			||||||
 | 
						URL     string    `json:"url"`
 | 
				
			||||||
 | 
						Info    VideoInfo `json:"info"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ImageMessage is an m.image event
 | 
					// ImageMessage is an m.image event
 | 
				
			||||||
type ImageMessage struct {
 | 
					type ImageMessage struct {
 | 
				
			||||||
	MsgType string    `json:"msgtype"`
 | 
						MsgType string    `json:"msgtype"`
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue