mirror of
https://github.com/go-gitea/gitea
synced 2025-12-07 13:28:25 +00:00
Merge branch 'master' into refactor_issues-subscription
This commit is contained in:
+11
-9
@@ -79,12 +79,11 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) {
|
||||
}
|
||||
|
||||
u := &models.User{
|
||||
Name: form.UserName,
|
||||
Email: form.Email,
|
||||
Passwd: form.Password,
|
||||
IsActive: true,
|
||||
LoginType: models.LoginPlain,
|
||||
MustChangePassword: form.MustChangePassword,
|
||||
Name: form.UserName,
|
||||
Email: form.Email,
|
||||
Passwd: form.Password,
|
||||
IsActive: true,
|
||||
LoginType: models.LoginPlain,
|
||||
}
|
||||
|
||||
if len(form.LoginType) > 0 {
|
||||
@@ -95,9 +94,12 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) {
|
||||
u.LoginName = form.LoginName
|
||||
}
|
||||
}
|
||||
if !password.IsComplexEnough(form.Password) {
|
||||
ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplUserNew, &form)
|
||||
return
|
||||
if u.LoginType == models.LoginPlain {
|
||||
if !password.IsComplexEnough(form.Password) {
|
||||
ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplUserNew, &form)
|
||||
return
|
||||
}
|
||||
u.MustChangePassword = form.MustChangePassword
|
||||
}
|
||||
if err := models.CreateUser(u); err != nil {
|
||||
switch {
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
"code.gitea.io/gitea/modules/webhook"
|
||||
|
||||
"github.com/unknwon/com"
|
||||
)
|
||||
@@ -166,7 +167,7 @@ func ToHook(repoLink string, w *models.Webhook) *api.Hook {
|
||||
"content_type": w.ContentType.Name(),
|
||||
}
|
||||
if w.HookTaskType == models.SLACK {
|
||||
s := w.GetSlackHook()
|
||||
s := webhook.GetSlackHook(w)
|
||||
config["channel"] = s.Channel
|
||||
config["username"] = s.Username
|
||||
config["icon_url"] = s.IconURL
|
||||
|
||||
@@ -458,9 +458,16 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
|
||||
issue.Content = *form.Body
|
||||
}
|
||||
|
||||
// Update the deadline
|
||||
if form.Deadline != nil && ctx.Repo.CanWrite(models.UnitTypeIssues) {
|
||||
deadlineUnix := timeutil.TimeStamp(form.Deadline.Unix())
|
||||
// Update or remove the deadline, only if set and allowed
|
||||
if (form.Deadline != nil || form.RemoveDeadline != nil) && ctx.Repo.CanWrite(models.UnitTypeIssues) {
|
||||
var deadlineUnix timeutil.TimeStamp
|
||||
|
||||
if (form.RemoveDeadline == nil || !*form.RemoveDeadline) && !form.Deadline.IsZero() {
|
||||
deadline := time.Date(form.Deadline.Year(), form.Deadline.Month(), form.Deadline.Day(),
|
||||
23, 59, 59, 0, form.Deadline.Location())
|
||||
deadlineUnix = timeutil.TimeStamp(deadline.Unix())
|
||||
}
|
||||
|
||||
if err := models.UpdateIssueDeadline(issue, deadlineUnix, ctx.User); err != nil {
|
||||
ctx.Error(500, "UpdateIssueDeadline", err)
|
||||
return
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/auth"
|
||||
@@ -326,7 +327,7 @@ func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption
|
||||
func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
|
||||
// swagger:operation PATCH /repos/{owner}/{repo}/pulls/{index} repository repoEditPullRequest
|
||||
// ---
|
||||
// summary: Update a pull request
|
||||
// summary: Update a pull request. If using deadline only the date will be taken into account, and time of day ignored.
|
||||
// consumes:
|
||||
// - application/json
|
||||
// produces:
|
||||
@@ -385,9 +386,15 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
|
||||
issue.Content = form.Body
|
||||
}
|
||||
|
||||
// Update Deadline
|
||||
if form.Deadline != nil {
|
||||
deadlineUnix := timeutil.TimeStamp(form.Deadline.Unix())
|
||||
// Update or remove deadline if set
|
||||
if form.Deadline != nil || form.RemoveDeadline != nil {
|
||||
var deadlineUnix timeutil.TimeStamp
|
||||
if (form.RemoveDeadline == nil || !*form.RemoveDeadline) && !form.Deadline.IsZero() {
|
||||
deadline := time.Date(form.Deadline.Year(), form.Deadline.Month(), form.Deadline.Day(),
|
||||
23, 59, 59, 0, form.Deadline.Location())
|
||||
deadlineUnix = timeutil.TimeStamp(deadline.Unix())
|
||||
}
|
||||
|
||||
if err := models.UpdateIssueDeadline(issue, deadlineUnix, ctx.User); err != nil {
|
||||
ctx.Error(500, "UpdateIssueDeadline", err)
|
||||
return
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/webhook"
|
||||
"code.gitea.io/gitea/routers/api/v1/convert"
|
||||
"code.gitea.io/gitea/routers/utils"
|
||||
|
||||
@@ -129,7 +130,7 @@ func addHook(ctx *context.APIContext, form *api.CreateHookOption, orgID, repoID
|
||||
return nil, false
|
||||
}
|
||||
|
||||
meta, err := json.Marshal(&models.SlackMeta{
|
||||
meta, err := json.Marshal(&webhook.SlackMeta{
|
||||
Channel: strings.TrimSpace(channel),
|
||||
Username: form.Config["username"],
|
||||
IconURL: form.Config["icon_url"],
|
||||
@@ -203,7 +204,7 @@ func editHook(ctx *context.APIContext, form *api.EditHookOption, w *models.Webho
|
||||
|
||||
if w.HookTaskType == models.SLACK {
|
||||
if channel, ok := form.Config["channel"]; ok {
|
||||
meta, err := json.Marshal(&models.SlackMeta{
|
||||
meta, err := json.Marshal(&webhook.SlackMeta{
|
||||
Channel: channel,
|
||||
Username: form.Config["username"],
|
||||
IconURL: form.Config["icon_url"],
|
||||
|
||||
@@ -35,6 +35,12 @@ func Activity(ctx *context.Context) {
|
||||
timeFrom = timeUntil.Add(-time.Hour * 168)
|
||||
case "monthly":
|
||||
timeFrom = timeUntil.AddDate(0, -1, 0)
|
||||
case "quarterly":
|
||||
timeFrom = timeUntil.AddDate(0, -3, 0)
|
||||
case "semiyearly":
|
||||
timeFrom = timeUntil.AddDate(0, -6, 0)
|
||||
case "yearly":
|
||||
timeFrom = timeUntil.AddDate(-1, 0, 0)
|
||||
default:
|
||||
ctx.Data["Period"] = "weekly"
|
||||
timeFrom = timeUntil.Add(-time.Hour * 168)
|
||||
@@ -70,6 +76,12 @@ func ActivityAuthors(ctx *context.Context) {
|
||||
timeFrom = timeUntil.Add(-time.Hour * 168)
|
||||
case "monthly":
|
||||
timeFrom = timeUntil.AddDate(0, -1, 0)
|
||||
case "quarterly":
|
||||
timeFrom = timeUntil.AddDate(0, -3, 0)
|
||||
case "semiyearly":
|
||||
timeFrom = timeUntil.AddDate(0, -6, 0)
|
||||
case "yearly":
|
||||
timeFrom = timeUntil.AddDate(-1, 0, 0)
|
||||
default:
|
||||
timeFrom = timeUntil.Add(-time.Hour * 168)
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ func DiscordHooksNewPost(ctx *context.Context, form auth.NewDiscordHookForm) {
|
||||
return
|
||||
}
|
||||
|
||||
meta, err := json.Marshal(&models.DiscordMeta{
|
||||
meta, err := json.Marshal(&webhook.DiscordMeta{
|
||||
Username: form.Username,
|
||||
IconURL: form.IconURL,
|
||||
})
|
||||
@@ -357,7 +357,7 @@ func TelegramHooksNewPost(ctx *context.Context, form auth.NewTelegramHookForm) {
|
||||
return
|
||||
}
|
||||
|
||||
meta, err := json.Marshal(&models.TelegramMeta{
|
||||
meta, err := json.Marshal(&webhook.TelegramMeta{
|
||||
BotToken: form.BotToken,
|
||||
ChatID: form.ChatID,
|
||||
})
|
||||
@@ -452,7 +452,7 @@ func SlackHooksNewPost(ctx *context.Context, form auth.NewSlackHookForm) {
|
||||
return
|
||||
}
|
||||
|
||||
meta, err := json.Marshal(&models.SlackMeta{
|
||||
meta, err := json.Marshal(&webhook.SlackMeta{
|
||||
Channel: strings.TrimSpace(form.Channel),
|
||||
Username: form.Username,
|
||||
IconURL: form.IconURL,
|
||||
@@ -515,11 +515,11 @@ func checkWebhook(ctx *context.Context) (*orgRepoCtx, *models.Webhook) {
|
||||
ctx.Data["HookType"] = w.HookTaskType.Name()
|
||||
switch w.HookTaskType {
|
||||
case models.SLACK:
|
||||
ctx.Data["SlackHook"] = w.GetSlackHook()
|
||||
ctx.Data["SlackHook"] = webhook.GetSlackHook(w)
|
||||
case models.DISCORD:
|
||||
ctx.Data["DiscordHook"] = w.GetDiscordHook()
|
||||
ctx.Data["DiscordHook"] = webhook.GetDiscordHook(w)
|
||||
case models.TELEGRAM:
|
||||
ctx.Data["TelegramHook"] = w.GetTelegramHook()
|
||||
ctx.Data["TelegramHook"] = webhook.GetTelegramHook(w)
|
||||
}
|
||||
|
||||
ctx.Data["History"], err = w.History(1)
|
||||
@@ -646,7 +646,7 @@ func SlackHooksEditPost(ctx *context.Context, form auth.NewSlackHookForm) {
|
||||
return
|
||||
}
|
||||
|
||||
meta, err := json.Marshal(&models.SlackMeta{
|
||||
meta, err := json.Marshal(&webhook.SlackMeta{
|
||||
Channel: strings.TrimSpace(form.Channel),
|
||||
Username: form.Username,
|
||||
IconURL: form.IconURL,
|
||||
@@ -690,7 +690,7 @@ func DiscordHooksEditPost(ctx *context.Context, form auth.NewDiscordHookForm) {
|
||||
return
|
||||
}
|
||||
|
||||
meta, err := json.Marshal(&models.DiscordMeta{
|
||||
meta, err := json.Marshal(&webhook.DiscordMeta{
|
||||
Username: form.Username,
|
||||
IconURL: form.IconURL,
|
||||
})
|
||||
@@ -763,7 +763,7 @@ func TelegramHooksEditPost(ctx *context.Context, form auth.NewTelegramHookForm)
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
meta, err := json.Marshal(&models.TelegramMeta{
|
||||
meta, err := json.Marshal(&webhook.TelegramMeta{
|
||||
BotToken: form.BotToken,
|
||||
ChatID: form.ChatID,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user