Commit 3170b034 authored by zauberstuhl's avatar zauberstuhl

Implement ApiNotification

parent 6ee1eb3a
package controllers
//
// GangGo API Library
// Copyright (C) 2017 Lukas Matt <lukas@zauberstuhl.de>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
import (
"github.com/revel/revel"
"gopkg.in/ganggo/ganggo.v0/app/models"
)
type ApiNotification struct {
*revel.Controller
}
func (n ApiNotification) Index() revel.Result {
user, err := models.GetCurrentUser(n.Session["TOKEN"])
if err != nil {
revel.AppLog.Error(err.Error())
return n.RenderError(err)
}
var notify models.Notifications
err = notify.FindUnreadByUserID(user.ID)
if err != nil {
revel.AppLog.Error(err.Error())
return n.RenderError(err)
}
return n.RenderJSON(notify)
}
func (n ApiNotification) Create() revel.Result {
return n.NotFound("Not implemented yet")
}
func (n ApiNotification) Show() revel.Result {
return n.NotFound("Not implemented yet")
}
func (n ApiNotification) Delete() revel.Result {
return n.NotFound("Not implemented yet")
}
......@@ -5,6 +5,11 @@ POST /api/v0/posts ApiPost.Create
GET /api/v0/posts/:id ApiPost.Show
DELETE /api/v0/posts/:id ApiPost.Delete
GET /api/v0/notifications ApiNotification.Index
POST /api/v0/notifications ApiNotification.Create
GET /api/v0/notifications/:id ApiNotification.Show
DELETE /api/v0/notifications/:id ApiNotification.Delete
GET /api/v0/posts/:id/likes ApiLike.Index
POST /api/v0/posts/:id/likes/:positive ApiLike.Create
GET /api/v0/posts/:id/likes/:like_id ApiLike.Show
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment