mirror of https://gitee.com/answerdev/answer.git
Merge remote-tracking branch 'github/feat/1.1.0/report' into feat/1.1.0/context
This commit is contained in:
commit
aeaeb4b127
|
@ -7,7 +7,3 @@ const (
|
||||||
AvatarTypeGravatar = "gravatar"
|
AvatarTypeGravatar = "gravatar"
|
||||||
AvatarTypeCustom = "custom"
|
AvatarTypeCustom = "custom"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
DefaultSiteURL = ""
|
|
||||||
)
|
|
||||||
|
|
|
@ -184,9 +184,9 @@ func (tc *TemplateController) QuestionInfoeRdirect(ctx *gin.Context, siteInfo *s
|
||||||
titleIsAnswerID = true
|
titleIsAnswerID = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
siteInfo = tc.SiteInfo(ctx)
|
||||||
url = fmt.Sprintf("%s/questions/%s", siteInfo.General.SiteUrl, id)
|
url = fmt.Sprintf("%s/questions/%s", siteInfo.General.SiteUrl, id)
|
||||||
if siteInfo.SiteSeo.PermaLink == schema.PermaLinkQuestionID {
|
if siteInfo.SiteSeo.PermaLink == schema.PermaLinkQuestionID || siteInfo.SiteSeo.PermaLink == schema.PermaLinkQuestionIDByShortID {
|
||||||
if len(ctx.Request.URL.Query()) > 0 {
|
if len(ctx.Request.URL.Query()) > 0 {
|
||||||
url = fmt.Sprintf("%s?%s", url, ctx.Request.URL.RawQuery)
|
url = fmt.Sprintf("%s?%s", url, ctx.Request.URL.RawQuery)
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"github.com/answerdev/answer/internal/service/revision_common"
|
"github.com/answerdev/answer/internal/service/revision_common"
|
||||||
tagcommon "github.com/answerdev/answer/internal/service/tag_common"
|
tagcommon "github.com/answerdev/answer/internal/service/tag_common"
|
||||||
usercommon "github.com/answerdev/answer/internal/service/user_common"
|
usercommon "github.com/answerdev/answer/internal/service/user_common"
|
||||||
|
"github.com/answerdev/answer/pkg/converter"
|
||||||
"github.com/answerdev/answer/pkg/encryption"
|
"github.com/answerdev/answer/pkg/encryption"
|
||||||
"github.com/answerdev/answer/pkg/htmltext"
|
"github.com/answerdev/answer/pkg/htmltext"
|
||||||
"github.com/answerdev/answer/pkg/uid"
|
"github.com/answerdev/answer/pkg/uid"
|
||||||
|
@ -566,7 +567,10 @@ func (qs *QuestionService) UpdateQuestionInviteUser(ctx context.Context, req *sc
|
||||||
for _, item := range req.InviteUser {
|
for _, item := range req.InviteUser {
|
||||||
_, ok := inviteUserInfoList[item]
|
_, ok := inviteUserInfoList[item]
|
||||||
if ok {
|
if ok {
|
||||||
inviteUserIDs = append(inviteUserIDs, inviteUserInfoList[item].ID)
|
//The inviter can't be himself.
|
||||||
|
if req.UserID != inviteUserInfoList[item].ID {
|
||||||
|
inviteUserIDs = append(inviteUserIDs, inviteUserInfoList[item].ID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inviteUserStr := ""
|
inviteUserStr := ""
|
||||||
|
@ -585,7 +589,17 @@ func (qs *QuestionService) UpdateQuestionInviteUser(ctx context.Context, req *sc
|
||||||
if saveerr != nil {
|
if saveerr != nil {
|
||||||
return saveerr
|
return saveerr
|
||||||
}
|
}
|
||||||
go qs.notificationInviteUser(ctx, inviteUserIDs, originQuestion.ID, originQuestion.Title, req.UserID)
|
//send notification
|
||||||
|
oldInviteUserIDsStr := originQuestion.InviteUserID
|
||||||
|
oldInviteUserIDs := make([]string, 0)
|
||||||
|
if oldInviteUserIDsStr != "" {
|
||||||
|
err = json.Unmarshal([]byte(oldInviteUserIDsStr), &oldInviteUserIDs)
|
||||||
|
if err == nil {
|
||||||
|
needSendNotificationUserIDs := converter.ArrayNotInArray(oldInviteUserIDs, inviteUserIDs)
|
||||||
|
go qs.notificationInviteUser(ctx, needSendNotificationUserIDs, originQuestion.ID, originQuestion.Title, req.UserID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,11 +126,7 @@ func (s *SiteInfoService) SaveSiteGeneral(ctx context.Context, req schema.SiteGe
|
||||||
Content: string(content),
|
Content: string(content),
|
||||||
Status: 1,
|
Status: 1,
|
||||||
}
|
}
|
||||||
err = s.siteInfoRepo.SaveByType(ctx, constant.SiteTypeGeneral, data)
|
return s.siteInfoRepo.SaveByType(ctx, constant.SiteTypeGeneral, data)
|
||||||
if err == nil {
|
|
||||||
constant.DefaultSiteURL = req.SiteUrl
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SiteInfoService) SaveSiteInterface(ctx context.Context, req schema.SiteInterfaceReq) (err error) {
|
func (s *SiteInfoService) SaveSiteInterface(ctx context.Context, req schema.SiteInterfaceReq) (err error) {
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package converter
|
||||||
|
|
||||||
|
func ArrayNotInArray(original []string, search []string) []string {
|
||||||
|
var result []string
|
||||||
|
originalMap := make(map[string]bool)
|
||||||
|
for _, v := range original {
|
||||||
|
originalMap[v] = true
|
||||||
|
}
|
||||||
|
for _, v := range search {
|
||||||
|
if _, ok := originalMap[v]; !ok {
|
||||||
|
result = append(result, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
Loading…
Reference in New Issue