restrict v1
This commit is contained in:
@@ -810,6 +810,26 @@ func QuestionShareCard(ctx context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 站方处置:任何级别都禁止生成分享图。
|
||||
// 分享卡会把「提问 + 回答」渲染成一张带箱主水印与二维码的图片,是挂人内容外流的主要通道
|
||||
// —— 图片离开原页面后没有上下文、没有原链接、无法回溯,比页面本身传播得更远。
|
||||
// 因此 L1「停止分发」首先就落在这里。查询失败按已处置处理(fail-closed):
|
||||
// 宁可少出一张卡,也不要让处置在 DB 抖动时静默失效。
|
||||
level, _, err := db.Restrictions.ActiveLevel(ctx.Request().Context(), user.ID)
|
||||
if err != nil {
|
||||
logrus.WithContext(ctx.Request().Context()).WithError(err).Error("Failed to query user restriction")
|
||||
ctx.Redirect("/")
|
||||
return
|
||||
}
|
||||
if level != "" {
|
||||
logrus.WithContext(ctx.Request().Context()).
|
||||
WithField("domain", domain).
|
||||
WithField("level", level).
|
||||
Info("Share card blocked by restriction")
|
||||
ctx.Redirect("/")
|
||||
return
|
||||
}
|
||||
|
||||
cacheKey := questionShareCardCacheKey(user, question)
|
||||
if cached, ok := questionShareCache.Get(cacheKey); ok {
|
||||
writeShareCardResponse(ctx, cached.([]byte))
|
||||
|
||||
Reference in New Issue
Block a user