-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v3-enterprise' into v3-viewer
- Loading branch information
Showing
42 changed files
with
4,221 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cfg | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/rusq/slackdump/v3" | ||
"github.com/rusq/slackdump/v3/auth" | ||
"github.com/rusq/slackdump/v3/logger" | ||
) | ||
|
||
// SlackdumpSession returns the Slackdump Session initialised with the provider | ||
// from context and a standard set of options initialised from the | ||
// configuration. One can provide additional options to override the | ||
// defaults. | ||
func SlackdumpSession(ctx context.Context, opts ...slackdump.Option) (*slackdump.Session, error) { | ||
lg := logger.FromContext(ctx) | ||
prov, err := auth.FromContext(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var stdOpts = []slackdump.Option{ | ||
slackdump.WithLogger(lg), | ||
slackdump.WithForceEnterprise(ForceEnterprise), | ||
slackdump.WithLimits(Limits), | ||
} | ||
|
||
stdOpts = append(stdOpts, opts...) | ||
return slackdump.New( | ||
ctx, | ||
prov, | ||
stdOpts..., | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
package diag | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"log/slog" | ||
"os" | ||
|
||
"github.com/rusq/slackdump/v3/auth" | ||
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/cfg" | ||
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/golang/base" | ||
"github.com/rusq/slackdump/v3/internal/edge" | ||
"github.com/rusq/slackdump/v3/logger" | ||
) | ||
|
||
var CmdEdge = &base.Command{ | ||
Run: runEdge, | ||
Wizard: func(ctx context.Context, cmd *base.Command, args []string) error { panic("not implemented") }, | ||
UsageLine: "slack tools edge", | ||
Short: "Edge test", | ||
RequireAuth: true, | ||
Long: ` | ||
# Slack Edge API test tool | ||
Edge test attempts to call the Edge API with the provided credentials. | ||
`, | ||
} | ||
|
||
var edgeParams = struct { | ||
channel string | ||
}{} | ||
|
||
func init() { | ||
CmdEdge.Flag.StringVar(&edgeParams.channel, "channel", "CHY5HUESG", "channel to get users from") | ||
} | ||
|
||
func runEdge(ctx context.Context, cmd *base.Command, args []string) error { | ||
if cfg.Verbose { | ||
slog.SetLogLoggerLevel(slog.LevelDebug) | ||
} | ||
lg := logger.FromContext(ctx) | ||
|
||
prov, err := auth.FromContext(ctx) | ||
if err != nil { | ||
base.SetExitStatus(base.SAuthError) | ||
return err | ||
} | ||
|
||
cl, err := edge.New(ctx, prov) | ||
if err != nil { | ||
base.SetExitStatus(base.SApplicationError) | ||
return err | ||
} | ||
defer cl.Close() | ||
lg.Print("connected") | ||
|
||
lg.Printf("*** Search for Channels test ***") | ||
channels, err := cl.SearchChannels(ctx, "") | ||
if err != nil { | ||
return err | ||
} | ||
if err := save("channels.json", channels); err != nil { | ||
return err | ||
} | ||
|
||
// lg.Printf("*** IMs test ***") | ||
// ims, err := cl.IMList(ctx) | ||
// if err != nil { | ||
// return err | ||
// } | ||
// if err := save("ims.json", ims); err != nil { | ||
// return err | ||
// } | ||
|
||
// lg.Printf("*** Counts ***") | ||
// counts, err := cl.ClientCounts(ctx) | ||
// if err != nil { | ||
// return err | ||
// } | ||
// if err := save("counts.json", counts); err != nil { | ||
// return err | ||
// } | ||
|
||
// lg.Print("*** GetConversationsContext ***") | ||
// gcc, _, err := cl.GetConversationsContext(ctx, nil) | ||
// if err != nil { | ||
// return err | ||
// } | ||
// if err := save("get_conversations_context.json", gcc); err != nil { | ||
// return err | ||
// } | ||
|
||
// lg.Print("*** GetUsersInConversationContext ***") | ||
// if len(gcc) > 0 { | ||
// lg.Printf("using: %s", gcc[0].Name) | ||
// guic, _, err := cl.GetUsersInConversationContext(ctx, &slack.GetUsersInConversationParameters{ChannelID: gcc[0].ID}) | ||
// if err != nil { | ||
// return err | ||
// } | ||
// if err := save("get_users_in_conversation_context.json", guic); err != nil { | ||
// return err | ||
// } | ||
// if len(guic) > 0 { | ||
// lg.Print("*** GetUsers ***") | ||
// users, err := cl.GetUsers(ctx, guic...) | ||
// if err != nil { | ||
// return err | ||
// } | ||
// if err := save("get_users.json", users); err != nil { | ||
// return err | ||
// } | ||
// } | ||
// lg.Print("*** Conversations Generic Info ***") | ||
// ci, err := cl.ConversationsGenericInfo(ctx, gcc[0].ID) | ||
// if err != nil { | ||
// return err | ||
// } | ||
// if err := save("conversations_generic_info.json", ci); err != nil { | ||
// return err | ||
// } | ||
// } | ||
|
||
lg.Print("OK") | ||
return nil | ||
} | ||
|
||
func save(filename string, r any) error { | ||
f, err := os.Create(filename) | ||
if err != nil { | ||
return err | ||
} | ||
defer f.Close() | ||
enc := json.NewEncoder(f) | ||
enc.SetIndent("", " ") | ||
enc.Encode(r) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.