Mono-binarify for api server.
This commit is contained in:
13
cli/cli.go
13
cli/cli.go
@ -10,20 +10,19 @@ import (
|
||||
"github.com/go-redis/redis"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
activitypub "github.com/yukimochi/Activity-Relay/ActivityPub"
|
||||
keyloader "github.com/yukimochi/Activity-Relay/KeyLoader"
|
||||
state "github.com/yukimochi/Activity-Relay/State"
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
)
|
||||
|
||||
var (
|
||||
version string
|
||||
|
||||
// Actor : Relay's Actor
|
||||
Actor activitypub.Actor
|
||||
Actor models.Actor
|
||||
|
||||
hostname *url.URL
|
||||
hostkey *rsa.PrivateKey
|
||||
relayState state.RelayState
|
||||
relayState models.RelayState
|
||||
machineryServer *machinery.Server
|
||||
)
|
||||
|
||||
@ -40,8 +39,8 @@ func initConfig() {
|
||||
viper.BindEnv("relay_servicename")
|
||||
} else {
|
||||
Actor.Summary = viper.GetString("relay_summary")
|
||||
Actor.Icon = activitypub.Image{URL: viper.GetString("relay_icon")}
|
||||
Actor.Image = activitypub.Image{URL: viper.GetString("relay_image")}
|
||||
Actor.Icon = &models.Image{URL: viper.GetString("relay_icon")}
|
||||
Actor.Image = &models.Image{URL: viper.GetString("relay_image")}
|
||||
}
|
||||
Actor.Name = viper.GetString("relay_servicename")
|
||||
|
||||
@ -58,7 +57,7 @@ func initConfig() {
|
||||
panic(err)
|
||||
}
|
||||
redisClient := redis.NewClient(redisOption)
|
||||
relayState = state.NewState(redisClient, true)
|
||||
relayState = models.NewState(redisClient, true)
|
||||
var machineryConfig = &config.Config{
|
||||
Broker: viper.GetString("redis_url"),
|
||||
DefaultQueue: "relay",
|
||||
|
@ -5,14 +5,14 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
state "github.com/yukimochi/Activity-Relay/State"
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
viper.Set("actor_pem", "../misc/testKey.pem")
|
||||
viper.Set("relay_domain", "relay.yukimochi.example.org")
|
||||
initConfig()
|
||||
relayState = state.NewState(relayState.RedisClient, false)
|
||||
relayState = models.NewState(relayState.RedisClient, false)
|
||||
relayState.RedisClient.FlushAll().Result()
|
||||
|
||||
code := m.Run()
|
||||
|
@ -7,11 +7,11 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
state "github.com/yukimochi/Activity-Relay/State"
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
)
|
||||
|
||||
const (
|
||||
BlockService state.Config = iota
|
||||
BlockService models.Config = iota
|
||||
ManuallyAccept
|
||||
CreateAsAnnounce
|
||||
)
|
||||
@ -126,7 +126,7 @@ func importConfig(cmd *cobra.Command, args []string) {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
return
|
||||
}
|
||||
var data state.RelayState
|
||||
var data models.RelayState
|
||||
err = json.Unmarshal(jsonData, &data)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
@ -154,7 +154,7 @@ func importConfig(cmd *cobra.Command, args []string) {
|
||||
cmd.Println("Set [" + BlockedDomain + "] as blocked domain")
|
||||
}
|
||||
for _, Subscription := range data.Subscriptions {
|
||||
relayState.AddSubscription(state.Subscription{
|
||||
relayState.AddSubscription(models.Subscription{
|
||||
Domain: Subscription.Domain,
|
||||
InboxURL: Subscription.InboxURL,
|
||||
ActivityID: Subscription.ActivityID,
|
||||
|
@ -1,6 +1,6 @@
|
||||
package main
|
||||
|
||||
import state "github.com/yukimochi/Activity-Relay/State"
|
||||
import "github.com/yukimochi/Activity-Relay/models"
|
||||
|
||||
func contains(entries interface{}, finder string) bool {
|
||||
switch entry := entries.(type) {
|
||||
@ -12,7 +12,7 @@ func contains(entries interface{}, finder string) bool {
|
||||
return true
|
||||
}
|
||||
}
|
||||
case []state.Subscription:
|
||||
case []models.Subscription:
|
||||
for i := 0; i < len(entry); i++ {
|
||||
if entry[i].Domain == finder {
|
||||
return true
|
||||
|
@ -5,8 +5,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
activitypub "github.com/yukimochi/Activity-Relay/ActivityPub"
|
||||
state "github.com/yukimochi/Activity-Relay/State"
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
)
|
||||
|
||||
func domainCmdInit() *cobra.Command {
|
||||
@ -48,8 +47,8 @@ func domainCmdInit() *cobra.Command {
|
||||
return domain
|
||||
}
|
||||
|
||||
func createUnfollowRequestResponse(subscription state.Subscription) error {
|
||||
activity := activitypub.Activity{
|
||||
func createUnfollowRequestResponse(subscription models.Subscription) error {
|
||||
activity := models.Activity{
|
||||
Context: []string{"https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"},
|
||||
ID: subscription.ActivityID,
|
||||
Actor: subscription.ActorID,
|
||||
|
@ -9,8 +9,7 @@ import (
|
||||
"github.com/RichardKnop/machinery/v1/tasks"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
"github.com/spf13/cobra"
|
||||
activitypub "github.com/yukimochi/Activity-Relay/ActivityPub"
|
||||
state "github.com/yukimochi/Activity-Relay/State"
|
||||
"github.com/yukimochi/Activity-Relay/models"
|
||||
)
|
||||
|
||||
func followCmdInit() *cobra.Command {
|
||||
@ -85,7 +84,7 @@ func createFollowRequestResponse(domain string, response string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
activity := activitypub.Activity{
|
||||
activity := models.Activity{
|
||||
Context: []string{"https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"},
|
||||
ID: data["activity_id"],
|
||||
Actor: data["actor"],
|
||||
@ -101,7 +100,7 @@ func createFollowRequestResponse(domain string, response string) error {
|
||||
pushRegistorJob(data["inbox_url"], jsonData)
|
||||
relayState.RedisClient.Del("relay:pending:" + domain)
|
||||
if response == "Accept" {
|
||||
relayState.AddSubscription(state.Subscription{
|
||||
relayState.AddSubscription(models.Subscription{
|
||||
Domain: domain,
|
||||
InboxURL: data["inbox_url"],
|
||||
ActivityID: data["activity_id"],
|
||||
@ -112,8 +111,8 @@ func createFollowRequestResponse(domain string, response string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func createUpdateActorActivity(subscription state.Subscription) error {
|
||||
activity := activitypub.Activity{
|
||||
func createUpdateActorActivity(subscription models.Subscription) error {
|
||||
activity := models.Activity{
|
||||
Context: []string{"https://www.w3.org/ns/activitystreams"},
|
||||
ID: hostname.String() + "/activities/" + uuid.NewV4().String(),
|
||||
Actor: hostname.String() + "/actor",
|
||||
|
Reference in New Issue
Block a user