refactor: remove workbench code from im server

This commit is contained in:
richjohnrambo
2026-09-17 23:38:44 +08:00
parent 69a777c81f
commit 0e2f4e73d1
28 changed files with 79 additions and 9182 deletions
-34
View File
@@ -38,8 +38,6 @@ import (
// See https://www.iana.org/assignments/media-types/media-types.xhtml
var allowedMimeTypes = []string{"application/", "audio/", "font/", "image/", "text/", "video/"}
const fileUploadPurposeMeetingNote = "meeting_note"
// RequestPrincipal is a tenant-scoped identity authenticated for HTTP/gRPC file access.
type RequestPrincipal struct {
TenantID types.TenantID
@@ -257,12 +255,6 @@ func largeFileReceiveHTTP(wrt http.ResponseWriter, req *http.Request) {
writeHttpResponse(ErrAuthRequired(msgID, "", now, now), nil)
return
}
meetingID, _, err := meetingNoteUploadParams(req, principal)
if err != nil {
writeHttpResponse(decodeStoreError(err, msgID, now, nil), err)
return
}
// Check if uploads are handled elsewhere.
headers, statusCode, err := mh.Headers(principal.TenantID, req.Method, req.URL, req.Header, true)
if err != nil {
@@ -374,36 +366,10 @@ func largeFileReceiveHTTP(wrt http.ResponseWriter, req *http.Request) {
// How long this file is guaranteed to exist without being attached to a message or a topic.
params["expires"] = now.Add(globals.mediaGcPeriod).Format(types.TimeFormatRFC3339)
}
if meetingID != "" {
params["purpose"] = fileUploadPurposeMeetingNote
params["meeting_id"] = meetingID
}
writeHttpResponse(NoErrParams(msgID, "", now, params), nil)
logs.Info.Println("media upload: ok", fdef.Id, fdef.Location)
}
func meetingNoteUploadParams(req *http.Request, principal RequestPrincipal) (string, string, error) {
if strings.TrimSpace(req.FormValue("purpose")) != fileUploadPurposeMeetingNote {
return "", "", nil
}
if principal.UID.IsZero() {
return "", "", types.ErrPermissionDenied
}
meetingID := strings.TrimSpace(req.FormValue("meeting_id"))
if meetingID == "" {
return "", "", types.ErrMalformed
}
idempotencyKey := strings.TrimSpace(req.Header.Get("Idempotency-Key"))
if idempotencyKey == "" {
idempotencyKey = strings.TrimSpace(req.FormValue("id"))
}
if idempotencyKey == "" {
return "", "", types.ErrMalformed
}
return meetingID, idempotencyKey, nil
}
// LargeFileServe is the gRPC equivalent of largeFileServeHTTP.
func (*grpcNodeServer) LargeFileServe(req *pbx.FileDownReq, stream pbx.Node_LargeFileServeServer) error {
now := types.TimeNow()