mirror of
https://gitea.com/gitea/gitea-mcp.git
synced 2026-04-02 12:35:56 +00:00
Add notification management via two new MCP tools using the method-dispatch pattern: - `notification_read`: list notifications (global or repo-scoped, with status/subject_type/since/before filters) and get single notification thread by ID - `notification_write`: mark single notification as read, mark all notifications as read (global or repo-scoped) Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
67 lines
1.3 KiB
Go
67 lines
1.3 KiB
Go
package notification
|
|
|
|
import (
|
|
gitea_sdk "code.gitea.io/sdk/gitea"
|
|
)
|
|
|
|
func slimThread(t *gitea_sdk.NotificationThread) map[string]any {
|
|
if t == nil {
|
|
return nil
|
|
}
|
|
m := map[string]any{
|
|
"id": t.ID,
|
|
"unread": t.Unread,
|
|
"updated_at": t.UpdatedAt,
|
|
}
|
|
if t.Pinned {
|
|
m["pinned"] = true
|
|
}
|
|
if t.Repository != nil {
|
|
m["repository"] = t.Repository.FullName
|
|
}
|
|
if t.Subject != nil {
|
|
subject := map[string]any{
|
|
"title": t.Subject.Title,
|
|
"type": t.Subject.Type,
|
|
"state": t.Subject.State,
|
|
}
|
|
if t.Subject.HTMLURL != "" {
|
|
subject["html_url"] = t.Subject.HTMLURL
|
|
}
|
|
if t.Subject.LatestCommentHTMLURL != "" {
|
|
subject["latest_comment_html_url"] = t.Subject.LatestCommentHTMLURL
|
|
}
|
|
m["subject"] = subject
|
|
}
|
|
return m
|
|
}
|
|
|
|
func slimThreads(threads []*gitea_sdk.NotificationThread) []map[string]any {
|
|
out := make([]map[string]any, 0, len(threads))
|
|
for _, t := range threads {
|
|
if t == nil {
|
|
continue
|
|
}
|
|
m := map[string]any{
|
|
"id": t.ID,
|
|
"unread": t.Unread,
|
|
"updated_at": t.UpdatedAt,
|
|
}
|
|
if t.Pinned {
|
|
m["pinned"] = true
|
|
}
|
|
if t.Repository != nil {
|
|
m["repository"] = t.Repository.FullName
|
|
}
|
|
if t.Subject != nil {
|
|
m["subject"] = map[string]any{
|
|
"title": t.Subject.Title,
|
|
"type": t.Subject.Type,
|
|
"state": t.Subject.State,
|
|
}
|
|
}
|
|
out = append(out, m)
|
|
}
|
|
return out
|
|
}
|