-
-
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.
about fucking time this shit finally does something
- Loading branch information
Showing
5 changed files
with
66 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,3 +48,6 @@ dist/ | |
!schema.json | ||
*.jsonl | ||
*.state | ||
|
||
# sundry junk used for testing and other fuckery | ||
/tmp |
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 |
---|---|---|
@@ -1,38 +1,50 @@ | ||
package processor | ||
|
||
import ( | ||
"os" | ||
"context" | ||
"io" | ||
|
||
"github.com/rusq/fsadapter" | ||
"github.com/rusq/slackdump/v2/downloader" | ||
"github.com/rusq/slackdump/v2/internal/event" | ||
"github.com/slack-go/slack" | ||
) | ||
|
||
type Standard struct { | ||
*event.Recorder | ||
channelID string | ||
fs fsadapter.FS | ||
dl *downloader.Client | ||
} | ||
|
||
func NewStandard(channelID string, fs fsadapter.FS) (*Standard, error) { | ||
f, err := os.CreateTemp("", "slackdump-"+channelID+"-*.jsonl") | ||
if err != nil { | ||
return nil, err | ||
} | ||
r := event.NewRecorder(f) | ||
func NewStandard(w io.Writer, sess downloader.Downloader, dir string) (*Standard, error) { | ||
r := event.NewRecorder(w) | ||
dl := downloader.New(sess, fsadapter.NewDirectory(dir)) | ||
dl.Start(context.Background()) | ||
return &Standard{ | ||
Recorder: r, | ||
channelID: channelID, | ||
fs: fs, | ||
Recorder: r, | ||
dl: dl, | ||
}, nil | ||
} | ||
|
||
func (s *Standard) Files(par *slack.Message, f []slack.File) error { | ||
func (s *Standard) Files(channelID string, parent slack.Message, isThread bool, m []slack.File) error { | ||
// custom file processor, because we need to donwload those files | ||
panic("implement me") | ||
for i := range m { | ||
if _, err := s.dl.DownloadFile(channelID, m[i]); err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func fileUrls(ff []slack.File) []string { | ||
var urls = make([]string, 0, len(ff)) | ||
for i := range ff { | ||
urls = append(urls, ff[i].URLPrivate) | ||
} | ||
return urls | ||
} | ||
|
||
func (s *Standard) Close() error { | ||
// reconstruct the final json file | ||
panic("implement me") | ||
s.dl.Stop() | ||
return nil | ||
} |