mirror of
https://github.com/mrusme/neonmodem.git
synced 2024-12-04 14:46:37 -05:00
Fixed Lemmy replies issue, re-enabled replies list
https://github.com/Arsen6331/go-lemmy/issues/1
This commit is contained in:
parent
0446d0db1e
commit
5989b37d83
32
go.mod
32
go.mod
@ -3,26 +3,36 @@ module github.com/mrusme/gobbs
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/JohannesKaufmann/html-to-markdown v1.3.6
|
||||
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
|
||||
github.com/charmbracelet/bubbles v0.14.0
|
||||
github.com/charmbracelet/bubbletea v0.23.1
|
||||
github.com/charmbracelet/glamour v0.6.0
|
||||
github.com/charmbracelet/lipgloss v0.6.0
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/hashicorp/go-retryablehttp v0.7.2
|
||||
github.com/hermanschaaf/hackernews v1.0.1
|
||||
github.com/mattn/go-runewidth v0.0.14
|
||||
github.com/muesli/ansi v0.0.0-20221106050444-61f0cd9a192a
|
||||
github.com/muesli/reflow v0.3.0
|
||||
github.com/muesli/termenv v0.13.0
|
||||
github.com/pelletier/go-toml/v2 v2.0.6
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
|
||||
github.com/spf13/cobra v1.6.1
|
||||
github.com/spf13/viper v1.14.0
|
||||
go.arsenm.dev/go-lemmy v0.0.0-20230105214607-754cfa602c10
|
||||
go.uber.org/zap v1.24.0
|
||||
golang.org/x/term v0.4.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.2.1 // indirect
|
||||
github.com/JohannesKaufmann/html-to-markdown v1.3.6 // indirect
|
||||
github.com/PuerkitoBio/goquery v1.8.0 // indirect
|
||||
github.com/alecthomas/chroma v0.10.0 // indirect
|
||||
github.com/andybalholm/cascadia v1.3.1 // indirect
|
||||
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de // indirect
|
||||
github.com/atotto/clipboard v0.1.4 // indirect
|
||||
github.com/aymanbagabas/go-osc52 v1.2.1 // indirect
|
||||
github.com/aymerick/douceur v0.2.0 // indirect
|
||||
github.com/charmbracelet/glamour v0.6.0 // indirect
|
||||
github.com/containerd/console v1.0.3 // indirect
|
||||
github.com/dlclark/regexp2 v1.7.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
@ -30,41 +40,31 @@ require (
|
||||
github.com/gorilla/css v1.0.0 // indirect
|
||||
github.com/gorilla/websocket v1.5.0 // indirect
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||
github.com/hashicorp/go-retryablehttp v0.7.1 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/hermanschaaf/hackernews v1.0.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||
github.com/mattn/go-localereader v0.0.1 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.14 // indirect
|
||||
github.com/microcosm-cc/bluemonday v1.0.21 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/muesli/ansi v0.0.0-20221106050444-61f0cd9a192a // indirect
|
||||
github.com/muesli/cancelreader v0.2.2 // indirect
|
||||
github.com/muesli/reflow v0.3.0 // indirect
|
||||
github.com/muesli/termenv v0.13.0 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
|
||||
github.com/rivo/uniseg v0.4.3 // indirect
|
||||
github.com/sahilm/fuzzy v0.1.0 // indirect
|
||||
github.com/spf13/afero v1.9.3 // indirect
|
||||
github.com/spf13/cast v1.5.0 // indirect
|
||||
github.com/spf13/cobra v1.6.1 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/subosito/gotenv v1.4.1 // indirect
|
||||
github.com/yuin/goldmark v1.5.3 // indirect
|
||||
github.com/yuin/goldmark-emoji v1.0.1 // indirect
|
||||
go.arsenm.dev/go-lemmy v0.0.0-20221213184958-e097e6c8b5be // indirect
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
go.uber.org/multierr v1.9.0 // indirect
|
||||
golang.org/x/net v0.4.0 // indirect
|
||||
golang.org/x/sys v0.3.0 // indirect
|
||||
golang.org/x/term v0.3.0 // indirect
|
||||
golang.org/x/text v0.5.0 // indirect
|
||||
golang.org/x/net v0.5.0 // indirect
|
||||
golang.org/x/sys v0.4.0 // indirect
|
||||
golang.org/x/text v0.6.0 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
|
20
go.sum
20
go.sum
@ -164,12 +164,16 @@ github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/S
|
||||
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.1 h1:sUiuQAnLlbvmExtFQs72iFW/HXeUn8Z1aJLQ4LJJbTQ=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.1/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.2 h1:AcYqCvkpalPnPF2pn0KamgwamS42TqUDDYFRKq/RAd0=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.2/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hermanschaaf/hackernews v1.0.0 h1:e+8TzV3g+Oz/1MHrYtHGgiQm58eH7POHkEEn9NPDLk0=
|
||||
github.com/hermanschaaf/hackernews v1.0.0/go.mod h1:JXB+ebskWYU7bv//Eri38p5IU14dcTqKXpJQh5jwsdc=
|
||||
github.com/hermanschaaf/hackernews v1.0.1 h1:n6dT7LPkFA4Ke4UrIzOa80YjwSXqF5sMKmUbIYtqMDY=
|
||||
github.com/hermanschaaf/hackernews v1.0.1/go.mod h1:JXB+ebskWYU7bv//Eri38p5IU14dcTqKXpJQh5jwsdc=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
@ -281,6 +285,14 @@ github.com/yuin/goldmark-emoji v1.0.1 h1:ctuWEyzGBwiucEqxzwe0SOYDXPAucOrE9NQC18W
|
||||
github.com/yuin/goldmark-emoji v1.0.1/go.mod h1:2w1E6FEWLcDQkoTE+7HU6QF1F6SLlNGjRIBbIZQFqkQ=
|
||||
go.arsenm.dev/go-lemmy v0.0.0-20221213184958-e097e6c8b5be h1:BZieH3Bp5rSercEMdXz56t0UdaxUipGBCAC6U9tqQwk=
|
||||
go.arsenm.dev/go-lemmy v0.0.0-20221213184958-e097e6c8b5be/go.mod h1:q7CIDksHIqltFNugJAixGTqk1Gp+a9emZMlILhU7Uh0=
|
||||
go.arsenm.dev/go-lemmy v0.0.0-20230105203020-27ef17a00e22 h1:k2M6qvMUpYFR7YbmPIld1s3+zBawUloYGtBXrPXdBek=
|
||||
go.arsenm.dev/go-lemmy v0.0.0-20230105203020-27ef17a00e22/go.mod h1:Br91zaVgauLWmj4sgk600XiD8297NpBTESULvGwMTdU=
|
||||
go.arsenm.dev/go-lemmy v0.0.0-20230105210211-cdd67e35a30b h1:ez4E3+u3ERmn4zTVOLEnAvLBdfQ3DGON0R0swY4yvjo=
|
||||
go.arsenm.dev/go-lemmy v0.0.0-20230105210211-cdd67e35a30b/go.mod h1:Br91zaVgauLWmj4sgk600XiD8297NpBTESULvGwMTdU=
|
||||
go.arsenm.dev/go-lemmy v0.0.0-20230105211710-4ecce09b7360 h1:illQayijKbN38L/2F/LynQucdC+eXkv2+LUWOTGhLm0=
|
||||
go.arsenm.dev/go-lemmy v0.0.0-20230105211710-4ecce09b7360/go.mod h1:Br91zaVgauLWmj4sgk600XiD8297NpBTESULvGwMTdU=
|
||||
go.arsenm.dev/go-lemmy v0.0.0-20230105214607-754cfa602c10 h1:aQYXs2KVWztLLZ3i9tIH/rS3X4TllS0jXI8twJhJMtk=
|
||||
go.arsenm.dev/go-lemmy v0.0.0-20230105214607-754cfa602c10/go.mod h1:Br91zaVgauLWmj4sgk600XiD8297NpBTESULvGwMTdU=
|
||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
@ -369,6 +381,8 @@ golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfS
|
||||
golang.org/x/net v0.0.0-20221002022538-bcab6841153b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||
golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU=
|
||||
golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
|
||||
golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
|
||||
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@ -434,11 +448,15 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
|
||||
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
|
||||
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.3.0 h1:qoo4akIqOcDME5bhc/NgxUdovd6BSS2uMsVjB56q1xI=
|
||||
golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA=
|
||||
golang.org/x/term v0.4.0 h1:O7UWfv5+A2qiuulQk30kVinPoMtoIPeVaKLEgLpVkvg=
|
||||
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
@ -450,6 +468,8 @@ golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
|
||||
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
|
||||
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
|
@ -6,9 +6,7 @@ import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/araddon/dateparse"
|
||||
"github.com/mrusme/gobbs/models/author"
|
||||
"github.com/mrusme/gobbs/models/forum"
|
||||
"github.com/mrusme/gobbs/models/post"
|
||||
@ -65,10 +63,10 @@ func (sys *System) GetCapabilities() adapter.Capabilities {
|
||||
// Name: "Create Post",
|
||||
// },
|
||||
// TODO: https://github.com/Arsen6331/go-lemmy/issues/1
|
||||
// adapter.Capability{
|
||||
// ID: "list:replies",
|
||||
// Name: "List Replies",
|
||||
// },
|
||||
adapter.Capability{
|
||||
ID: "list:replies",
|
||||
Name: "List Replies",
|
||||
},
|
||||
// TODO: Maybe possible but kind of pointless without list:replies
|
||||
// adapter.Capability{
|
||||
// ID: "create:reply",
|
||||
@ -120,7 +118,7 @@ func (sys *System) Load() error {
|
||||
credentials[k] = v.(string)
|
||||
}
|
||||
|
||||
err = sys.client.Login(context.Background(), types.Login{
|
||||
err = sys.client.ClientLogin(context.Background(), types.Login{
|
||||
UsernameOrEmail: credentials["username"],
|
||||
Password: credentials["password"],
|
||||
})
|
||||
@ -134,8 +132,8 @@ func (sys *System) ListForums() ([]forum.Forum, error) {
|
||||
return []forum.Forum{}, nil
|
||||
// Not possible to list forums atm
|
||||
|
||||
resp, err := sys.client.Communities(context.Background(), types.ListCommunities{
|
||||
Type: types.NewOptional(types.ListingSubscribed),
|
||||
resp, err := sys.client.ListCommunities(context.Background(), types.ListCommunities{
|
||||
Type: types.NewOptional(types.ListingTypeSubscribed),
|
||||
})
|
||||
if err != nil {
|
||||
return []forum.Forum{}, err
|
||||
@ -147,8 +145,8 @@ func (sys *System) ListForums() ([]forum.Forum, error) {
|
||||
b, _ := json.Marshal(i)
|
||||
sys.logger.Debug(string(b))
|
||||
models = append(models, forum.Forum{
|
||||
ID: strconv.Itoa(i.CommunitySafe.ID),
|
||||
Name: i.CommunitySafe.Name,
|
||||
ID: strconv.Itoa(i.Community.ID),
|
||||
Name: i.Community.Name,
|
||||
|
||||
SysIDX: sys.ID,
|
||||
})
|
||||
@ -159,10 +157,11 @@ func (sys *System) ListForums() ([]forum.Forum, error) {
|
||||
|
||||
func (sys *System) ListPosts(forumID string) ([]post.Post, error) {
|
||||
resp, err := sys.client.Posts(context.Background(), types.GetPosts{
|
||||
Type: types.NewOptional(types.ListingSubscribed),
|
||||
Sort: types.NewOptional(types.New),
|
||||
Type: types.NewOptional(types.ListingTypeSubscribed),
|
||||
Sort: types.NewOptional(types.SortTypeNew),
|
||||
Limit: types.NewOptional(int64(50)),
|
||||
})
|
||||
sys.logger.Debug("DEEEEBUUUUUUUGGGGGGGG")
|
||||
if err != nil {
|
||||
return []post.Post{}, err
|
||||
}
|
||||
@ -172,6 +171,8 @@ func (sys *System) ListPosts(forumID string) ([]post.Post, error) {
|
||||
|
||||
var models []post.Post
|
||||
for _, i := range resp.Posts {
|
||||
b, _ := json.Marshal(i)
|
||||
sys.logger.Debug(string(b))
|
||||
t := "post"
|
||||
body := i.Post.Body.ValueOr("")
|
||||
if i.Post.URL.IsValid() {
|
||||
@ -179,14 +180,8 @@ func (sys *System) ListPosts(forumID string) ([]post.Post, error) {
|
||||
body = i.Post.URL.ValueOr("")
|
||||
}
|
||||
|
||||
createdAt, err := dateparse.ParseAny(i.Post.Published)
|
||||
if err != nil {
|
||||
createdAt = time.Now() // TODO: Errrr
|
||||
}
|
||||
lastCommentedAt, err := dateparse.ParseAny(i.Counts.NewestCommentTime)
|
||||
if err != nil {
|
||||
lastCommentedAt = time.Now() // TODO: Errrrr
|
||||
}
|
||||
createdAt := i.Post.Published.Time
|
||||
lastCommentedAt := i.Counts.NewestCommentTime.Time
|
||||
|
||||
models = append(models, post.Post{
|
||||
ID: strconv.Itoa(i.Post.ID),
|
||||
@ -233,21 +228,15 @@ func (sys *System) LoadPost(p *post.Post) error {
|
||||
// return err
|
||||
// }
|
||||
|
||||
resp, err := sys.client.Comments(context.Background(), types.GetComments{
|
||||
Type: types.NewOptional(types.ListingLocal),
|
||||
Sort: types.NewOptional(types.CommentSortHot),
|
||||
// CommunityID: types.NewOptional(cid),
|
||||
PostID: types.NewOptional(pid),
|
||||
resp, err := sys.client.Post(context.Background(), types.GetPost{
|
||||
ID: pid,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, i := range resp.Comments {
|
||||
createdAt, err := dateparse.ParseAny(i.Comment.Published)
|
||||
if err != nil {
|
||||
createdAt = time.Now() // TODO: Errrrr
|
||||
}
|
||||
createdAt := i.Comment.Published.Time
|
||||
|
||||
p.Replies = append(p.Replies, reply.Reply{
|
||||
ID: strconv.Itoa(i.Comment.ID),
|
||||
|
Loading…
Reference in New Issue
Block a user