Add mod flag for /modpost, improve error return and handling slightly, add manage/recent.json and example
parent
8fb5f2e3a9
commit
71f2ff6f87
6 changed files with 175 additions and 16 deletions
@ -0,0 +1,78 @@ |
|||||||
|
package jschan |
||||||
|
|
||||||
|
import ( |
||||||
|
"context" |
||||||
|
"fmt" |
||||||
|
// "jschan/app/models"
|
||||||
|
"net/http" |
||||||
|
"time" |
||||||
|
) |
||||||
|
|
||||||
|
type GetManageRecentOptions struct { |
||||||
|
Board string |
||||||
|
Global bool |
||||||
|
} |
||||||
|
|
||||||
|
type AutoGenerated struct { |
||||||
|
ID string `json:"_id"` |
||||||
|
Date time.Time `json:"date"` |
||||||
|
U int64 `json:"u"` |
||||||
|
Name string `json:"name"` |
||||||
|
Country interface{} `json:"country"` |
||||||
|
Board string `json:"board"` |
||||||
|
Tripcode interface{} `json:"tripcode"` |
||||||
|
Capcode interface{} `json:"capcode"` |
||||||
|
Subject string `json:"subject"` |
||||||
|
Message string `json:"message"` |
||||||
|
Messagehash string `json:"messagehash"` |
||||||
|
Nomarkup string `json:"nomarkup"` |
||||||
|
Thread int `json:"thread"` |
||||||
|
Email string `json:"email"` |
||||||
|
Spoiler bool `json:"spoiler"` |
||||||
|
Banmessage interface{} `json:"banmessage"` |
||||||
|
UserID string `json:"userId"` |
||||||
|
IP struct { |
||||||
|
Raw string `json:"raw"` |
||||||
|
Cloak string `json:"cloak"` |
||||||
|
Pruned bool `json:"pruned,omitempty"` |
||||||
|
} `json:"ip,omitempty"` |
||||||
|
Files []interface{} `json:"files"` |
||||||
|
Reports []interface{} `json:"reports"` |
||||||
|
Quotes []struct { |
||||||
|
ID string `json:"_id"` |
||||||
|
Thread int `json:"thread"` |
||||||
|
PostID int `json:"postId"` |
||||||
|
} `json:"quotes"` |
||||||
|
Crossquotes []interface{} `json:"crossquotes"` |
||||||
|
Backlinks []interface{} `json:"backlinks"` |
||||||
|
PostID int `json:"postId"` |
||||||
|
Bumped time.Time `json:"bumped,omitempty"` |
||||||
|
Replyfiles int `json:"replyfiles,omitempty"` |
||||||
|
Replyposts int `json:"replyposts,omitempty"` |
||||||
|
Sticky int `json:"sticky,omitempty"` |
||||||
|
Locked int `json:"locked,omitempty"` |
||||||
|
Bumplocked int `json:"bumplocked,omitempty"` |
||||||
|
Cyclic int `json:"cyclic,omitempty"` |
||||||
|
} |
||||||
|
|
||||||
|
type GetManageRecentResponse []AutoGenerated |
||||||
|
|
||||||
|
func (c *Client) GetManageRecent(ctx context.Context, options *GetManageRecentOptions) (GetManageRecentResponse, error) { |
||||||
|
|
||||||
|
url := fmt.Sprintf("%s/%s/manage/recent.json", c.BaseURL, options.Board) |
||||||
|
|
||||||
|
req, err := http.NewRequest(http.MethodGet, url, nil) |
||||||
|
if err != nil { |
||||||
|
return nil, err |
||||||
|
} |
||||||
|
|
||||||
|
req = req.WithContext(ctx) |
||||||
|
|
||||||
|
res := GetManageRecentResponse{} |
||||||
|
if err := c.sendRequest(req, &res, nil); err != nil { |
||||||
|
return nil, err |
||||||
|
} |
||||||
|
|
||||||
|
return res, nil |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue