get ready for more implementation work

This commit is contained in:
Iris Lightshard 2024-10-02 18:54:14 -06:00
parent a7e5c99cec
commit 9195bba7ed
Signed by: nilix
GPG key ID: 688407174966CAF3
5 changed files with 24 additions and 8 deletions

View file

@ -9,6 +9,6 @@ type Adapter interface {
Name() string
Subscribe(string) []error
Fetch(string, []string) error
Do(string) error
Do(string, []string) error
DefaultSubscriptionFilter() string
}

View file

@ -104,7 +104,7 @@ func (self *MastoAdapter) Fetch(etype string, ids []string) error {
return nil
}
func (self *MastoAdapter) Do(action string) error {
func (self *MastoAdapter) Do(action string, data []string) error {
return nil
}

View file

@ -294,6 +294,8 @@ func (self *MisskeyAdapter) toAuthor(usr mkm.User, bustCache bool) *Author {
func (self *MisskeyAdapter) Fetch(etype string, ids []string) error {
for _, id := range ids {
switch etype {
case "byAuthor":
// fetch notes by this author
case "message":
data, err := self.mk.Notes().Show(id)
if err != nil {
@ -360,13 +362,13 @@ func (self *MisskeyAdapter) Fetch(etype string, ids []string) error {
self.send(a)
}
}
}
}
return nil
}
func (self *MisskeyAdapter) Do(action string) error {
func (self *MisskeyAdapter) Do(action string, data []string) error {
return nil
}

View file

@ -90,7 +90,7 @@ func (self *NostrAdapter) Fetch(etype string, ids []string) error {
return nil
}
func (self *NostrAdapter) Do(action string) error {
func (self *NostrAdapter) Do(action string, data []string) error {
return nil
}

View file

@ -2,6 +2,7 @@ package cli
import (
"encoding/json"
"errors"
"io/ioutil"
"log"
@ -12,7 +13,11 @@ import (
func Process(args ...string) error {
// allocate storage for the settings array
var settings []models.Settings
var s models.Settings
var s *models.Settings
if len(args) < 3 {
return errors.New("CLI requires at least 3 args: ADAPTER ACTION DATA...")
}
// get adapter from first arg
adapterName := args[0]
@ -30,10 +35,15 @@ func Process(args ...string) error {
}
for _, x := range settings {
if x.Nickname == adapterName {
s = x
s = &x
break
}
}
if s == nil {
return errors.New("given adapter " + adapterName + " is not in the config file")
}
// instantiate adapter with config
var a adapter.Adapter
switch s.Protocol {
@ -46,10 +56,14 @@ func Process(args ...string) error {
default:
break
}
a.Init(s, nil)
a.Init(*s, nil)
// process remaining args and execute
switch args[0] {
case "fetch":
a.Fetch(args[1], args[2:])
case "do":
a.Do(args[1], args[2:])
default:
log.Print(args)
}