Esempio n. 1
0
func cmdClearReport(ctx *Context) {
	args := strings.Split(ctx.Ev.Text, " ")
	if len(args) < 2 {
		ctx.Respond("clearreport <id>")
		return
	}
	sid := args[1]
	id, err := strconv.Atoi(sid)
	if err != nil {
		ctx.Respond("couldn't parse ID")
		return
	}

	r := db.GetReport(id)
	if r == nil {
		ctx.Respond("That report doesn't exist")
		return
	}

	if !isAdmin(ctx) && !(r.Reporter == ctx.Ev.User) {
		ctx.Respond("You do not have permission to do that")
		return
	}

	r.ToggleClear()
	if r.Cleared {
		ctx.Respond("The issue was marked as resolved")
	} else {
		ctx.Respond("The issue was re-opened")
	}
}
Esempio n. 2
0
func cmdDeleteReport(ctx *Context) {
	args := strings.Split(ctx.Ev.Text, " ")
	if len(args) < 2 {
		ctx.Respond("deletereport <id>")
		return
	}
	sid := args[1]
	id, err := strconv.Atoi(sid)
	if err != nil {
		ctx.Respond("couldn't parse ID")
		return
	}

	r := db.GetReport(id)
	if r == nil {
		ctx.Respond("That report doesn't exist")
	}

	if !isAdmin(ctx) && !(r.Reporter == ctx.Ev.User) {
		log.Printf("! %v == %v", r.Reporter, ctx.Ev.User)
		ctx.Respond("You do not have permission to do that")
		return
	}

	db.DB.Delete(r)
	ctx.Respond("That report was successfully deleted")
}