Skip to content

Commit e4f6487

Browse files
committed
fixed matrix message sending
1 parent 258fb73 commit e4f6487

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

internal/notification/notification.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ func (m *MatrixBackend) SendNotification(msg types.NotificationMessage) error {
130130
"msgtype": "m.text",
131131
"body": msg.Content,
132132
"formatted_body": body,
133+
"format": "org.matrix.custom.html",
133134
}
134135

135136
if format == "org.matrix.custom.html" {
@@ -153,19 +154,15 @@ func (m *MatrixBackend) SendNotification(msg types.NotificationMessage) error {
153154

154155
// sendMatrixMessage sends a message to a Matrix room.
155156
func (m *MatrixBackend) sendMatrixMessage(roomID string, message map[string]interface{}) error {
156-
// Generate a transaction ID
157-
//txnID := fmt.Sprintf("patchwork_%d", time.Now().UnixNano())
158-
159157
// Construct the API URL using the configured endpoint
160-
url := fmt.Sprintf("%s/_matrix/client/r0/rooms/%s/send/m.room.message/",
158+
url := fmt.Sprintf("%s/_matrix/client/r0/rooms/%s/send/m.room.message",
161159
m.endpoint, roomID)
162160

163161
m.logger.Debug("Sending Matrix message",
164162
"roomID", roomID,
165163
"message", message,
166164
"matrixUser", m.user,
167165
"endpoint", m.endpoint,
168-
//"txnID", txnID,
169166
"url", url)
170167

171168
// Marshal the message
@@ -175,7 +172,7 @@ func (m *MatrixBackend) sendMatrixMessage(roomID string, message map[string]inte
175172
}
176173

177174
// Create the request
178-
req, err := http.NewRequest("PUT", url, bytes.NewBuffer(payload))
175+
req, err := http.NewRequest("POST", url, bytes.NewBuffer(payload))
179176
if err != nil {
180177
return fmt.Errorf("failed to create request: %w", err)
181178
}

0 commit comments

Comments
 (0)