restrict v7
This commit is contained in:
@@ -91,12 +91,12 @@ func UpdateProfile(ctx context.Context, f form.UpdateProfile) {
|
||||
uploadedURL, err := storage.UploadAvatarToS3(avatarFile, avatarFileHeader)
|
||||
if err != nil {
|
||||
if errors.Is(err, imagecheck.ErrImageTooLarge) {
|
||||
ctx.SetErrorFlash(err.Error())
|
||||
ctx.SetError(err, f)
|
||||
ctx.Success("user/profile")
|
||||
return
|
||||
}
|
||||
if errors.Is(err, imagecheck.ErrBadAspectRatio) {
|
||||
ctx.SetErrorFlash(i18n.T(ctx.Lang(), "profile.err.avatarRatio"))
|
||||
ctx.SetError(errors.New(i18n.T(ctx.Lang(), "profile.err.avatarRatio")), f)
|
||||
ctx.Success("user/profile")
|
||||
return
|
||||
}
|
||||
@@ -122,12 +122,12 @@ func UpdateProfile(ctx context.Context, f form.UpdateProfile) {
|
||||
uploadedURL, err := storage.UploadBackgroundToS3(backgroundFile, backgroundFileHeader)
|
||||
if err != nil {
|
||||
if errors.Is(err, imagecheck.ErrImageTooLarge) {
|
||||
ctx.SetErrorFlash(err.Error())
|
||||
ctx.SetError(err, f)
|
||||
ctx.Success("user/profile")
|
||||
return
|
||||
}
|
||||
if errors.Is(err, imagecheck.ErrBadAspectRatio) {
|
||||
ctx.SetErrorFlash(i18n.T(ctx.Lang(), "profile.err.backgroundRatio"))
|
||||
ctx.SetError(errors.New(i18n.T(ctx.Lang(), "profile.err.backgroundRatio")), f)
|
||||
ctx.Success("user/profile")
|
||||
return
|
||||
}
|
||||
@@ -150,7 +150,7 @@ func UpdateProfile(ctx context.Context, f form.UpdateProfile) {
|
||||
uploadedURL, err := storage.UploadPictureToS3(backgroundimageFile, backgroundimageFileHeader)
|
||||
if err != nil {
|
||||
if errors.Is(err, imagecheck.ErrImageTooLarge) {
|
||||
ctx.SetErrorFlash(err.Error())
|
||||
ctx.SetError(err, f)
|
||||
ctx.Success("user/profile")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -55,6 +55,12 @@ func QuestionList(ctx context.Context) {
|
||||
if statusParam != "all" && statusParam != "answered" && statusParam != "unanswered" {
|
||||
statusParam = "all"
|
||||
}
|
||||
// reported 筛选:只看当前有「待处理举报」的提问。
|
||||
// 依赖下方 reportCounts(同一份查询复用),不额外打库。
|
||||
reportedParam := ctx.Query("reported")
|
||||
if reportedParam != "reported" {
|
||||
reportedParam = "all"
|
||||
}
|
||||
typeParam := ctx.Query("type")
|
||||
// 私聊已独立成"私聊"标签页(见 ReceivedChats),不再参与提问列表的类型筛选;
|
||||
// 旧的 type=chat 链接统一归一为"全部",避免空列表。
|
||||
@@ -196,6 +202,9 @@ func QuestionList(ctx context.Context) {
|
||||
if readStatus == 2 && isRead {
|
||||
continue
|
||||
}
|
||||
if reportedParam == "reported" && reportCounts[q.ID] == 0 {
|
||||
continue
|
||||
}
|
||||
itemType := "question_public"
|
||||
if q.IsPrivate {
|
||||
itemType = "question_private"
|
||||
@@ -352,6 +361,7 @@ func QuestionList(ctx context.Context) {
|
||||
ctx.Data["SelectedStatus"] = statusParam
|
||||
ctx.Data["SelectedRead"] = readParam
|
||||
ctx.Data["SelectedType"] = typeParam
|
||||
ctx.Data["SelectedReported"] = reportedParam
|
||||
|
||||
// 我发起的私聊 — 同样使用批量查询与分页(复用 chat_cursor 游标)
|
||||
askerConvs, err := db.Conversations.ListByAsker(ctx.Request().Context(), ctx.User.ID, chatPageSize, int(chatOffset))
|
||||
|
||||
Reference in New Issue
Block a user