Commit 2534fff7 authored by Lukas Matt's avatar Lukas Matt

Add contact dispatcher

parent 3f7005a4
......@@ -14,3 +14,4 @@ app/assets/vendor
node_modules
public/assets
.js$:.js
.css$:.css
package jobs
//
// GangGo Application Server
// 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 (
"encoding/xml"
"github.com/revel/revel"
"gopkg.in/ganggo/ganggo.v0/app/models"
"gopkg.in/ganggo/ganggo.v0/app/helpers"
federation "gopkg.in/ganggo/federation.v0"
)
func (d *Dispatcher) Contact(contact federation.EntityContact) {
_, host, err := helpers.ParseAuthor(contact.Recipient)
if err != nil {
revel.AppLog.Error(err.Error())
return
}
var person models.Person
err = person.FindByAuthor(contact.Recipient)
if err != nil {
revel.AppLog.Error(err.Error())
return
}
entityXml, err := xml.Marshal(contact)
if err != nil {
revel.AppLog.Error(err.Error())
return
}
payload, err := federation.EncryptedMagicEnvelope(
d.User.SerializedPrivateKey,
person.SerializedPublicKey,
contact.Author, entityXml,
); if err != nil {
revel.AppLog.Error(err.Error())
return
}
send(nil, host, person.Guid, payload)
}
......@@ -42,6 +42,8 @@ func (d *Dispatcher) Run() {
d.Comment(&entity)
case federation.EntityLike:
d.Like(entity)
case federation.EntityContact:
d.Contact(entity)
default:
revel.ERROR.Println("Unknown entity type in dispatcher!")
}
......
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