Commit 5b6116bf authored by zauberstuhl's avatar zauberstuhl

Add contact dispatcher to aspect controller

related to ganggo@2534fff7
parent 2b91ba70
......@@ -20,6 +20,8 @@ package controllers
import (
"github.com/revel/revel"
"gopkg.in/ganggo/api.v0/app/helpers"
"gopkg.in/ganggo/ganggo.v0/app/jobs"
federation "gopkg.in/ganggo/federation.v0"
"gopkg.in/ganggo/ganggo.v0/app/models"
"net/http"
)
......@@ -132,6 +134,12 @@ func (a ApiAspect) ShowPerson() revel.Result {
* "error": "[...]"
* }
*
* @apiErrorExample {json} NotFound
* HTTP/1.1 404 Not Found
* {
* "error": "[...]"
* }
*
* @apiErrorExample {json} ServerError
* HTTP/1.1 500 Internal Server Error
* {
......@@ -156,6 +164,24 @@ func (a ApiAspect) CreatePerson() revel.Result {
return a.ApiError(http.StatusInternalServerError, ERR_SERVER)
}
var person models.Person
err = person.FindByID(personID)
if err != nil {
a.Log.Error(TAG, "db", err, "api", ERR_NOT_FOUND)
return a.ApiError(http.StatusNotFound, ERR_NOT_FOUND)
}
dispatcher := jobs.Dispatcher{
User: a.CurrentUser,
Message: federation.EntityContact{
Author: a.CurrentUser.Person.Author,
Recipient: person.Author,
Sharing: true,
Following: true,
},
}
go dispatcher.Run()
return a.RenderJSON(membership)
}
......@@ -194,6 +220,12 @@ func (a ApiAspect) CreatePerson() revel.Result {
* "error": "[...]"
* }
*
* @apiErrorExample {json} NotFound
* HTTP/1.1 404 Not Found
* {
* "error": "[...]"
* }
*
* @apiErrorExample {json} ServerError
* HTTP/1.1 500 Internal Server Error
* {
......@@ -218,6 +250,24 @@ func (a ApiAspect) DeletePerson() revel.Result {
return a.ApiError(http.StatusInternalServerError, ERR_SERVER)
}
var person models.Person
err = person.FindByID(personID)
if err != nil {
a.Log.Error(TAG, "db", err, "api", ERR_NOT_FOUND)
return a.ApiError(http.StatusNotFound, ERR_NOT_FOUND)
}
dispatcher := jobs.Dispatcher{
User: a.CurrentUser,
Message: federation.EntityContact{
Author: a.CurrentUser.Person.Author,
Recipient: person.Author,
Sharing: false,
Following: false,
},
}
go dispatcher.Run()
return a.RenderJSON(membership)
}
......
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