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"
|
||||
AvatarTypeCustom = "custom"
|
||||
)
|
||||
|
||||
var (
|
||||
DefaultSiteURL = ""
|
||||
)
|
||||
|
|
|
@ -184,9 +184,9 @@ func (tc *TemplateController) QuestionInfoeRdirect(ctx *gin.Context, siteInfo *s
|
|||
titleIsAnswerID = true
|
||||
}
|
||||
}
|
||||
|
||||
siteInfo = tc.SiteInfo(ctx)
|
||||
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 {
|
||||
url = fmt.Sprintf("%s?%s", url, ctx.Request.URL.RawQuery)
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import (
|
|||
"github.com/answerdev/answer/internal/service/revision_common"
|
||||
tagcommon "github.com/answerdev/answer/internal/service/tag_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/htmltext"
|
||||
"github.com/answerdev/answer/pkg/uid"
|
||||
|
@ -566,7 +567,10 @@ func (qs *QuestionService) UpdateQuestionInviteUser(ctx context.Context, req *sc
|
|||
for _, item := range req.InviteUser {
|
||||
_, ok := inviteUserInfoList[item]
|
||||
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 := ""
|
||||
|
@ -585,7 +589,17 @@ func (qs *QuestionService) UpdateQuestionInviteUser(ctx context.Context, req *sc
|
|||
if saveerr != nil {
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -126,11 +126,7 @@ func (s *SiteInfoService) SaveSiteGeneral(ctx context.Context, req schema.SiteGe
|
|||
Content: string(content),
|
||||
Status: 1,
|
||||
}
|
||||
err = s.siteInfoRepo.SaveByType(ctx, constant.SiteTypeGeneral, data)
|
||||
if err == nil {
|
||||
constant.DefaultSiteURL = req.SiteUrl
|
||||
}
|
||||
return
|
||||
return s.siteInfoRepo.SaveByType(ctx, constant.SiteTypeGeneral, data)
|
||||
}
|
||||
|
||||
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