Misc improvements
Some checks failed
Go / Lint (latest) (push) Has been cancelled
Go / Build (old, libolm) (push) Has been cancelled
Go / Build (latest, libolm) (push) Has been cancelled
Go / Build (old, goolm) (push) Has been cancelled
Go / Build (latest, goolm) (push) Has been cancelled

This commit is contained in:
Radon Rosborough 2026-02-24 13:29:18 -08:00
commit 40bee754d3
3 changed files with 54 additions and 12 deletions

View file

@ -276,8 +276,8 @@ func sendQR(ce *Event, qr string, prevEventID *id.EventID) error {
func sendUserInputAttachments(ce *Event, atts []*bridgev2.LoginUserInputAttachment) error {
for _, att := range atts {
filename := "captcha" + exmime.ExtensionFromMimetype(att.MimeType)
mxc, file, err := ce.Bot.UploadMedia(ce.Ctx, ce.RoomID, att.Content, filename, att.MimeType)
filename := "captcha" + exmime.ExtensionFromMimetype(att.Info.MimeType)
mxc, file, err := ce.Bot.UploadMedia(ce.Ctx, ce.RoomID, att.Content, filename, att.Info.MimeType)
if err != nil {
return fmt.Errorf("failed to upload attachment %q: %w", filename, err)
}
@ -286,6 +286,12 @@ func sendUserInputAttachments(ce *Event, atts []*bridgev2.LoginUserInputAttachme
FileName: filename,
URL: mxc,
File: file,
Info: &event.FileInfo{
Width: att.Info.Width,
Height: att.Info.Height,
Size: att.Info.Size,
},
Body: filename,
}
_, err = ce.Bot.SendMessage(ce.Ctx, ce.RoomID, event.EventMessage, &event.Content{Parsed: content}, nil)
if err != nil {

View file

@ -59,11 +59,6 @@ type LoginProcessCookies interface {
SubmitCookies(ctx context.Context, cookies map[string]string) (*LoginStep, error)
}
type LoginProcessCaptcha interface {
LoginProcess
SubmitCaptcha(ctx context.Context, code string) (*LoginStep, error)
}
type LoginFlow struct {
Name string `json:"name"`
Description string `json:"description"`
@ -76,7 +71,6 @@ const (
LoginStepTypeUserInput LoginStepType = "user_input"
LoginStepTypeCookies LoginStepType = "cookies"
LoginStepTypeDisplayAndWait LoginStepType = "display_and_wait"
LoginStepTypeCaptcha LoginStepType = "captcha"
LoginStepTypeComplete LoginStepType = "complete"
)
@ -285,10 +279,17 @@ type LoginUserInputParams struct {
}
type LoginUserInputAttachment struct {
Type event.MessageType
Filename string
MimeType string
Content []byte
Type event.MessageType `json:"type,omitempty"`
FileName string `json:"filename,omitempty"`
Content []byte `json:"content,omitempty"`
Info LoginUserInputAttachmentInfo `json:"info,omitempty"`
}
type LoginUserInputAttachmentInfo struct {
MimeType string `json:"mimetype,omitempty"`
Width int `json:"w,omitempty"`
Height int `json:"h,omitempty"`
Size int `json:"size,omitempty"`
}
type LoginCompleteParams struct {

View file

@ -740,6 +740,41 @@ components:
description: For fields of type select, the valid options.
items:
type: string
attachments:
type: array
description: A list of media attachments to show the user alongside the form fields.
items:
type: object
description: A media attachment to show the user.
required: [ type, filename, content ]
properties:
type:
type: string
description: The type of media attachment, using the same media type identifiers as Matrix attachments. Only some are supported.
enum: [ m.image, m.audio ]
filename:
type: string
description: The filename for the media attachment.
content:
type: string
description: The raw file content for the attachment encoded in base64.
info:
type: object
description: Optional but recommended metadata for the attachment. Can generally be derived from the raw content if omitted.
properties:
mimetype:
type: string
description: The MIME type for the media content.
examples: [ image/png, audio/mpeg ]
width:
type: number
description: The width of the media in pixels. Only applicable for images and videos.
height:
type: number
description: The height of the media in pixels. Only applicable for images and videos.
size:
type: number
description: The size of the media content in number of bytes. Strongly recommended to include.
- description: Cookie login step
required: [ type, cookies ]
properties: