Documentation
¶
Overview ¶
Package request 寄件码/反向收件(P2):用户创建投递链接,访客凭链接上传, 文件以链接主人名义成为普通分享(复用分享过期/清理/通知机制)。
设计参照 Gokapi File Requests / Pingvin reverse share:
- token 32 hex(crypto/rand),链接 /#/request/<token>
- 约束:单次投递文件数/总大小上限、链接有效期(创建者设定)
- 访客投递不走 upload.open_upload 总闸(显式受邀上传,与 Gokapi 同策略)
Index ¶
- Constants
- type CreateReq
- type NotifySender
- type PublicView
- type Service
- func (s *Service) Create(ctx context.Context, userID uint, req CreateReq) (*model.FileRequest, error)
- func (s *Service) CreateFederationSlot(ctx context.Context, title, fromName, note string) (*model.FileRequest, error)
- func (s *Service) Delete(ctx context.Context, userID uint, token string) (bool, error)
- func (s *Service) GetPublic(ctx context.Context, token string) (*PublicView, error)
- func (s *Service) ListForUser(ctx context.Context, userID uint) ([]*model.FileRequest, error)
- func (s *Service) Submit(ctx context.Context, token string, entries []storage.StoredFileEntry, ...) (*ShareResult, error)
- type ShareCreateRequest
- type ShareGateway
- type ShareResult
Constants ¶
const ( // FederationSlotTTL 槽位有效期:铸出后立即用于转发 ⇒ 短 TTL //(不留长命窗口;过期后链接自然失效)。 FederationSlotTTL = 2 * time.Hour )
跨站投递槽位(联邦前台化,2026-11-01)的参数。
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateReq ¶
type CreateReq struct {
Title string
MaxFiles int
MaxBytes int64
ExpireValue int
ExpireStyle string // minute/hour/day/week/month/year/forever;空 = 7 天(不支持 count:该通道按时间过期)
}
CreateReq 创建投递链接入参
type NotifySender ¶
type NotifySender interface {
CreateForUserSimple(ctx context.Context, userID uint, title, content, notifyType, level string) error
}
NotifySender 投递到件通知(notify service 实现)
type PublicView ¶
type PublicView struct {
Token string `json:"token"`
Title string `json:"title"`
MaxFiles int `json:"max_files"`
MaxBytes int64 `json:"max_bytes"`
ExpiredAt *time.Time `json:"expired_at"`
}
PublicView 访客侧链接信息
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service 寄件码服务
func NewService ¶
func NewService(gormDB *gorm.DB, shareSvc ShareGateway, notify NotifySender) *Service
NewService 构建服务。shareSvc 为分享创建网关(未注入时投递创建分享会失败)。
func (*Service) Create ¶
func (s *Service) Create(ctx context.Context, userID uint, req CreateReq) (*model.FileRequest, error)
Create 创建投递链接
func (*Service) CreateFederationSlot ¶ added in v0.32.44
func (s *Service) CreateFederationSlot(ctx context.Context, title, fromName, note string) (*model.FileRequest, error)
CreateFederationSlot 铸一个「访客投递槽位」(联邦前台化,2026-11-01)。
语义:对面柜(A 柜)请求在本站(B 柜)铸一个投递槽位,拿到 token 后用它 往本站投递文件(POST /api/v1/request/:token/upload)⇒ 落成分享后由**本站** 的 share 域铸 6 位取件码 ⇒ **码归属 = 本站**(取件人在本站取件)。
属主 = 0(无本地用户)⇒ 落成的分享是本站的**匿名分享**(归属天然正确: 文件归本站柜子,不冒充某个用户)。
⚠️ 有效期**不走** Create 的过期样式白名单(utils.CheckExpireStyleAllowed): 槽位是内部通道(不是用户可选的分享过期样式)⇒ 管理员把 allowed_expire_styles 收窄成 ["day","week"] 时,铸槽位不该跟着失败。
func (*Service) ListForUser ¶
ListForUser 用户的投递链接列表
type ShareCreateRequest ¶
type ShareCreateRequest struct {
}
ShareCreateRequest 投递转分享的装配参数(网关实现适配为具体分享域的请求)。
type ShareGateway ¶
type ShareGateway interface {
}
ShareGateway 分享创建网关(消费侧接口;bootstrap 注入 share 域适配器, 本域不直接依赖 share 包——跨域依赖收口为单一装配点)。