Working on Posting
This commit is contained in:
@@ -22,7 +22,6 @@ THE SOFTWARE.
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
@@ -311,6 +310,7 @@ func (s *ScreenHome) initCli() {
|
||||
s.cli.AddCommand(w.NewCliCommand("getpds", s.cliGetPds))
|
||||
s.cli.AddCommand(w.NewCliCommand("authpds", s.cliAuthPds))
|
||||
s.cli.AddCommand(w.NewCliCommand("backuppds", s.cliBackupPds))
|
||||
s.cli.AddCommand(w.NewCliCommand("sendstatus", s.cliSendStatus))
|
||||
}
|
||||
|
||||
func (s *ScreenHome) toggleCli() {
|
||||
@@ -373,19 +373,18 @@ func (s *ScreenHome) cliAuthPds(args ...string) bool {
|
||||
return true
|
||||
}
|
||||
s.isLoading = true
|
||||
ctx := context.Background()
|
||||
go func() {
|
||||
defer func() { s.isLoading = false }()
|
||||
atid := s.activePds.AtId.String()
|
||||
callbackRes := make(chan url.Values, 1)
|
||||
listenPort, err := s.r.Auth.ListenForCallback(ctx, callbackRes)
|
||||
listenPort, err := s.r.Auth.ListenForCallback(callbackRes)
|
||||
if err != nil {
|
||||
s.Log("Error Instantiating HTTP Server for Callback: %w", err)
|
||||
return
|
||||
}
|
||||
s.Log("Listening on %d", listenPort)
|
||||
var authUrl string
|
||||
authUrl, err = s.r.Auth.StartAuthFlow(listenPort, ctx, atid, callbackRes)
|
||||
authUrl, err = s.r.Auth.StartAuthFlow(listenPort, atid, callbackRes)
|
||||
if err != nil {
|
||||
s.Log("Error starting auth flow: %w", err)
|
||||
}
|
||||
@@ -414,6 +413,23 @@ func (s *ScreenHome) cliBackupPds(args ...string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (s *ScreenHome) cliSendStatus(args ...string) bool {
|
||||
if s.activePds == nil {
|
||||
s.Log("No active PDS.")
|
||||
return true
|
||||
}
|
||||
s.isLoading = true
|
||||
go func() {
|
||||
defer func() { s.isLoading = false }()
|
||||
if !s.r.Auth.HasAuth() {
|
||||
s.Log("Not authorized. Run `authpds`")
|
||||
return
|
||||
}
|
||||
s.r.SendToPDS()
|
||||
}()
|
||||
return true
|
||||
}
|
||||
|
||||
func (s *ScreenHome) updatePdsListing() {
|
||||
s.pdsListing.SetTitle(fmt.Sprintf("─ %s (%s)", s.activePds.AtId.String(), s.activePds.Did.String()))
|
||||
s.pdsListing.Clear()
|
||||
|
||||
Reference in New Issue
Block a user