Add support for MSC4193 media spoilers (#189)
This commit is contained in:
@@ -1639,6 +1639,10 @@ func (portal *Portal) handleMatrixMessage(sender *User, evt *event.Event) {
|
|||||||
sendReq.Content, sendReq.AllowedMentions = portal.parseMatrixHTML(content)
|
sendReq.Content, sendReq.AllowedMentions = portal.parseMatrixHTML(content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if evt.Content.Raw["page.codeberg.everypizza.msc4193.spoiler"] == true {
|
||||||
|
filename = "SPOILER_" + filename
|
||||||
|
}
|
||||||
|
|
||||||
if portal.bridge.Config.Bridge.UseDiscordCDNUpload && !isWebhookSend && sess.IsUser {
|
if portal.bridge.Config.Bridge.UseDiscordCDNUpload && !isWebhookSend && sess.IsUser {
|
||||||
att := &discordgo.MessageAttachment{
|
att := &discordgo.MessageAttachment{
|
||||||
ID: "0",
|
ID: "0",
|
||||||
|
|||||||
@@ -154,24 +154,27 @@ func (portal *Portal) convertDiscordAttachment(ctx context.Context, intent *apps
|
|||||||
Size: att.Size,
|
Size: att.Size,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var extra = make(map[string]any)
|
||||||
|
|
||||||
|
if strings.HasPrefix(att.Filename, "SPOILER_") {
|
||||||
|
extra["page.codeberg.everypizza.msc4193.spoiler"] = true
|
||||||
|
}
|
||||||
|
|
||||||
if att.Description != "" {
|
if att.Description != "" {
|
||||||
content.Body = att.Description
|
content.Body = att.Description
|
||||||
content.FileName = att.Filename
|
content.FileName = att.Filename
|
||||||
}
|
}
|
||||||
|
|
||||||
var extra map[string]any
|
|
||||||
|
|
||||||
switch strings.ToLower(strings.Split(att.ContentType, "/")[0]) {
|
switch strings.ToLower(strings.Split(att.ContentType, "/")[0]) {
|
||||||
case "audio":
|
case "audio":
|
||||||
content.MsgType = event.MsgAudio
|
content.MsgType = event.MsgAudio
|
||||||
if att.Waveform != nil {
|
if att.Waveform != nil {
|
||||||
// TODO convert waveform
|
// TODO convert waveform
|
||||||
extra = map[string]any{
|
extra["org.matrix.msc1767.audio"] = map[string]any{
|
||||||
"org.matrix.msc1767.audio": map[string]any{
|
|
||||||
"duration": int(att.DurationSeconds * 1000),
|
"duration": int(att.DurationSeconds * 1000),
|
||||||
},
|
|
||||||
"org.matrix.msc3245.voice": map[string]any{},
|
|
||||||
}
|
}
|
||||||
|
extra["org.matrix.msc3245.voice"] = map[string]any{}
|
||||||
}
|
}
|
||||||
case "image":
|
case "image":
|
||||||
content.MsgType = event.MsgImage
|
content.MsgType = event.MsgImage
|
||||||
|
|||||||
Reference in New Issue
Block a user