* Add missing `X-Total-Count` and fix some related bugs
Adds `X-Total-Count` header to APIs that return a list but doesn't have it yet.
Fixed bugs:
* not returned after reporting error (39eb82446c/routers/api/v1/user/star.go (L70))
* crash with index out of bounds, API issue/issueSubscriptions
I also found various endpoints that return lists but do not apply/support pagination yet:
```
/repos/{owner}/{repo}/issues/{index}/labels
/repos/{owner}/{repo}/issues/comments/{id}/reactions
/repos/{owner}/{repo}/branch_protections
/repos/{owner}/{repo}/contents
/repos/{owner}/{repo}/hooks/git
/repos/{owner}/{repo}/issue_templates
/repos/{owner}/{repo}/releases/{id}/assets
/repos/{owner}/{repo}/reviewers
/repos/{owner}/{repo}/teams
/user/emails
/users/{username}/heatmap
```
If this is not expected, an new issue should be opened.
Closes#13043
* fmt
* Update routers/api/v1/repo/issue_subscription.go
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Use FindAndCount
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: 6543 <6543@obermui.de>
* DBContext is just a Context
This PR removes some of the specialness from the DBContext and makes it context
This allows us to simplify the GetEngine code to wrap around any context in future
and means that we can change our loadRepo(e Engine) functions to simply take contexts.
Signed-off-by: Andrew Thornton <art27@cantab.net>
* fix unit tests
Signed-off-by: Andrew Thornton <art27@cantab.net>
* another place that needs to set the initial context
Signed-off-by: Andrew Thornton <art27@cantab.net>
* avoid race
Signed-off-by: Andrew Thornton <art27@cantab.net>
* change attachment error
Signed-off-by: Andrew Thornton <art27@cantab.net>
This PR adds a `ListOptions` type which is not paged but uses absolute values. It is implemented as discussed in Discord.
Extracted from #16510 to clean that PR.
* chore: rewrite format.
* chore: update format
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* chore: update format
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* chore: Adjacent parameters with the same type should be grouped together
* chore: update format.
* refactor
* optimize
* remove Iretating function
LoadWatchUsers do not load Users into IW object and it is used only in api ... so move this logic
* remove unessesary
* Apply suggestions from code review
Thx
Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>
* make Tests more robust
* fix rebase
* restart CI
* CI no dont hit sqlites deadlock
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
* FIX: getIssueWatchers() get only aktive suscriber
* save query to work later with it or not ...
* fix test + add new case
* corect tests + GetIssueWatch
* API issue_subscripton: Put/Delete require tocken
* remove redundant code
* swagger specify return value
* remove unused binding
* remove note
because I'll implement this in a different way and in another PR
* ID should be unique!
* use xorm session
* Revert "use xorm session"
This reverts commit c1de540147199f2f1a8dd0d008f54af3603e2229.
* better test code
* more acurate comments
* use assert.False/True instead of Equal
* use more assert methodes
* Mail issue subscribers, rework the function
* Simplify a little more
* Fix unused variable
* Refactor mail delivery to avoid heavy load on server
* Avoid splitting into too many goroutines
* Fix comments and optimize GetMaileableUsersByIDs()
* Fix return on errors
* add issue subscriber API
* subscribers return []user.APIFormat
* add comments
* more meaningfull description
* without "reqToken()" api works ...
* should be still secure beause ctx.user has to be there or nothing will hapen
* FIX: getIssueWatchers() get only aktive suscriber
* add return avter error on right position
* Revert "FIX: getIssueWatchers() get only aktive suscriber"
This reverts commit 5eca9291858a821981992b0aaa38cef610d84bca.
* Update routers/api/v1/repo/issue.go
Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>
* test go linter again
* update swagger
* GetIssueWatchers -> GetIssueSubscribers
part one
Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>
* GetIssueWatchers -> GetIssueSubscribers
part two
* Revert "test go linter again"
This reverts commit bab12356227e44334de113b76f12099de0b8aaa6.
* change description for unsubscribe too
* golangci-lint timeout avter 5min
* move issueSubscription to seperate file
* dont create black entitys
* use IsWatching until refactoring
* Update License Info
* better swagger description
* Update .golangci.yml
because functions moved from issue.go to issue_subscription.go
* add IssueWatchList type
* batch tasks
* use e Engien
* add error handling
* error should be the last type when returning multiple items
* short version
* reurn empy UserList instead of nil
* display ui time with customize time location
* fix lint
* rename UILocation to DefaultUILocation
* move time related functions to modules/timeutil
* fix tests
* fix tests
* fix build
* fix swagger
* refactor struct's time to remove unnecessary memory usage
* use AsTimePtr simple code
* fix tests
* fix time compare
* fix template on gpg
* use AddDuration instead of Add
* Filter inactive users before sending emails or creating browser notifications
Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
* fix formatting issues
Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
* included requested changes
Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>
* optimized database queries
* rebasing new master and add tablenames for clarification in xorm queries
* remove escaped quotationmarks using backticks
Signed-off-by: David Schneiderbauer <dschneiderbauer@gmail.com>