Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Federation Library
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ganggo
Federation Library
Commits
a3784891
Commit
a3784891
authored
Jul 20, 2017
by
zauberstuhl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Append author signatures directly via a struct func
parent
45bd3737
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
2 deletions
+44
-2
const.go
const.go
+4
-0
entity_comment.go
entity_comment.go
+20
-1
entity_like.go
entity_like.go
+20
-1
No files found.
const.go
View file @
a3784891
...
...
@@ -36,4 +36,8 @@ const (
// webfinger
WebFingerOstatus
=
"http://ostatus.org/schema/1.0/subscribe"
WebFingerHcard
=
"http://microformats.org/profile/hcard"
// signature types
AuthorSignatureType
=
iota
ParentAuthorSignatureType
)
entity_comment.go
View file @
a3784891
...
...
@@ -17,7 +17,10 @@ package federation
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
import
"encoding/xml"
import
(
"encoding/xml"
"errors"
)
type
EntityComment
struct
{
XMLName
xml
.
Name
`xml:"comment"`
...
...
@@ -33,3 +36,19 @@ type EntityComment struct {
func
(
e
*
EntityComment
)
SignatureOrder
()
string
{
return
"author created_at guid parent_guid text"
}
func
(
e
*
EntityComment
)
AppendSignature
(
privKey
,
order
string
,
typ
int
)
error
{
signature
,
err
:=
AuthorSignature
(
*
e
,
order
,
privKey
)
if
err
!=
nil
{
return
err
}
if
AuthorSignatureType
==
typ
{
(
*
e
)
.
AuthorSignature
=
signature
}
else
if
ParentAuthorSignatureType
==
typ
{
(
*
e
)
.
ParentAuthorSignature
=
signature
}
else
{
return
errors
.
New
(
"Unsupported author signature type!"
)
}
return
nil
}
entity_like.go
View file @
a3784891
...
...
@@ -17,7 +17,10 @@ package federation
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
import
"encoding/xml"
import
(
"encoding/xml"
"errors"
)
type
EntityLike
struct
{
XMLName
xml
.
Name
`xml:"like"`
...
...
@@ -33,3 +36,19 @@ type EntityLike struct {
func
(
e
*
EntityLike
)
SignatureOrder
()
string
{
return
"positive guid parent_guid target_type author"
}
func
(
e
*
EntityLike
)
AppendSignature
(
privKey
,
order
string
,
typ
int
)
error
{
signature
,
err
:=
AuthorSignature
(
*
e
,
privKey
,
order
)
if
err
!=
nil
{
return
err
}
if
AuthorSignatureType
==
typ
{
(
*
e
)
.
AuthorSignature
=
signature
}
else
if
ParentAuthorSignatureType
==
typ
{
(
*
e
)
.
ParentAuthorSignature
=
signature
}
else
{
return
errors
.
New
(
"Unsupported author signature type!"
)
}
return
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment