Introduce NotifySubjectState (#520)
close #515 Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/520 Reviewed-by: Andrew Thornton <art27@cantab.net> Reviewed-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: 6543 <6543@obermui.de> Co-committed-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
42fed7165c
commit
fb42ca1c8d
6 changed files with 49 additions and 18 deletions
|
@ -1,9 +1,7 @@
|
||||||
# Migration Guide: v0.11 to v0.12
|
# Migration Guide: v0.11 to v0.12
|
||||||
|
|
||||||
v0.12.0 introduces a number of breaking changes, throu it should not be hard to
|
v0.12.0 introduces a number of breaking changes, through which it should not be difficult to migrate.
|
||||||
migrate.
|
Just follow this guid and if you still encounter problems, ask for help on discord or feel free to create an issue.
|
||||||
Just follow this guid and if issues still ocure ask for help on discord or
|
|
||||||
feel free to create an issue.
|
|
||||||
|
|
||||||
<!-- toc -->
|
<!-- toc -->
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
# Migration Guide: v0.12 to v0.13
|
# Migration Guide: v0.12 to v0.13
|
||||||
|
|
||||||
v0.13.0 introduces a number of breaking changes, throu it should not be hard to migrate.
|
v0.13.0 introduces a number of breaking changes, through which it should not be difficult to migrate.
|
||||||
Just follow this guid and if issues still ocure ask for help on discord or
|
Just follow this guid and if you still encounter problems, ask for help on discord or feel free to create an issue.
|
||||||
feel free to create an issue.
|
|
||||||
|
|
||||||
<!-- toc -->
|
<!-- toc -->
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
# Migration Guide: v0.13 to v0.14
|
# Migration Guide: v0.13 to v0.14
|
||||||
|
|
||||||
v0.14.0 introduces a number of breaking changes, throu it should not be hard to migrate.
|
v0.14.0 introduces a number of breaking changes, through which it should not be difficult to migrate.
|
||||||
Just follow this guid and if issues still ocure ask for help on discord or
|
Just follow this guid and if you still encounter problems, ask for help on discord or feel free to create an issue.
|
||||||
feel free to create an issue.
|
|
||||||
|
|
||||||
<!-- toc -->
|
<!-- toc -->
|
||||||
|
|
||||||
|
|
18
docs/migrate-v0.14-to-v0.15.md
Normal file
18
docs/migrate-v0.14-to-v0.15.md
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Migration Guide: v0.14 to v0.15
|
||||||
|
|
||||||
|
v0.15.0 introduces a number of api changes, through which it should not be difficult to migrate.
|
||||||
|
Just follow this guid and if you still encounter problems, ask for help on discord or feel free to create an issue.
|
||||||
|
|
||||||
|
<!-- toc -->
|
||||||
|
|
||||||
|
- [Changed Struct Fields (#520)](#changed-struct-fields)
|
||||||
|
|
||||||
|
<!-- tocstop -->
|
||||||
|
|
||||||
|
## Changed Struct Fields
|
||||||
|
|
||||||
|
- the `State` field at **NotificationSubject** changed from **StateType** to **NotifySubjectState**, it also contains `"open"`, `"closed"` and add `"merged"`
|
||||||
|
|
||||||
|
Pulls:
|
||||||
|
- [#520 Introduce NotifySubjectState](https://gitea.com/gitea/go-sdk/pulls/520)
|
||||||
|
|
|
@ -33,7 +33,7 @@ type NotificationSubject struct {
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
LatestCommentURL string `json:"latest_comment_url"`
|
LatestCommentURL string `json:"latest_comment_url"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
State StateType `json:"state"`
|
State NotifySubjectState `json:"state"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotifyStatus notification status type
|
// NotifyStatus notification status type
|
||||||
|
@ -48,6 +48,18 @@ const (
|
||||||
NotifyStatusPinned NotifyStatus = "pinned"
|
NotifyStatusPinned NotifyStatus = "pinned"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// NotifySubjectState reflect state of notification subject
|
||||||
|
type NotifySubjectState string
|
||||||
|
|
||||||
|
const (
|
||||||
|
// NotifySubjectOpen if subject is a pull/issue and is open at the moment
|
||||||
|
NotifySubjectOpen NotifySubjectState = "open"
|
||||||
|
// NotifySubjectClosed if subject is a pull/issue and is closed at the moment
|
||||||
|
NotifySubjectClosed NotifySubjectState = "closed"
|
||||||
|
// NotifySubjectMerged if subject is a pull and got merged
|
||||||
|
NotifySubjectMerged NotifySubjectState = "merged"
|
||||||
|
)
|
||||||
|
|
||||||
// ListNotificationOptions represents the filter options
|
// ListNotificationOptions represents the filter options
|
||||||
type ListNotificationOptions struct {
|
type ListNotificationOptions struct {
|
||||||
ListOptions
|
ListOptions
|
||||||
|
|
|
@ -60,6 +60,8 @@ func TestNotifications(t *testing.T) {
|
||||||
for _, n := range nList {
|
for _, n := range nList {
|
||||||
assert.EqualValues(t, true, n.Unread)
|
assert.EqualValues(t, true, n.Unread)
|
||||||
assert.EqualValues(t, "Issue", n.Subject.Type)
|
assert.EqualValues(t, "Issue", n.Subject.Type)
|
||||||
|
assert.EqualValues(t, NotifySubjectOpen, nList[0].Subject.State)
|
||||||
|
assert.EqualValues(t, NotifySubjectOpen, nList[1].Subject.State)
|
||||||
if n.Subject.Title == "A Issue" {
|
if n.Subject.Title == "A Issue" {
|
||||||
assert.EqualValues(t, repoA.Name, n.Repository.Name)
|
assert.EqualValues(t, repoA.Name, n.Repository.Name)
|
||||||
} else if n.Subject.Title == "B Issue" {
|
} else if n.Subject.Title == "B Issue" {
|
||||||
|
@ -104,8 +106,8 @@ func TestNotifications(t *testing.T) {
|
||||||
count, _, err = c.CheckNotifications()
|
count, _, err = c.CheckNotifications()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, 1, count)
|
assert.EqualValues(t, 1, count)
|
||||||
assert.Len(t, nList, 1)
|
if assert.Len(t, nList, 1) {
|
||||||
if len(nList) > 0 {
|
assert.EqualValues(t, NotifySubjectClosed, nList[0].Subject.State)
|
||||||
_, err = c.ReadNotification(nList[0].ID)
|
_, err = c.ReadNotification(nList[0].ID)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
@ -124,5 +126,8 @@ func TestNotifications(t *testing.T) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
nList, _, err = c.ListNotifications(ListNotificationOptions{Status: []NotifyStatus{NotifyStatusPinned, NotifyStatusUnread}})
|
nList, _, err = c.ListNotifications(ListNotificationOptions{Status: []NotifyStatus{NotifyStatusPinned, NotifyStatusUnread}})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, nList, 2)
|
if assert.Len(t, nList, 2) {
|
||||||
|
assert.EqualValues(t, NotifySubjectClosed, nList[0].Subject.State)
|
||||||
|
assert.EqualValues(t, NotifySubjectClosed, nList[1].Subject.State)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue