diff --git a/go.mod b/go.mod index 5b62b9b..fb0f8be 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/ahmdrz/goinsta/v2 v2.4.5 github.com/aws/aws-lambda-go v1.13.3 github.com/dghubble/go-twitter v0.0.0-20190719072343-39e5462e111f + github.com/gorilla/handlers v1.4.2 github.com/gorilla/mux v1.7.3 github.com/joho/godotenv v1.3.0 github.com/kelseyhightower/envconfig v1.4.0 diff --git a/go.sum b/go.sum index fd02c54..4e68e22 100644 --- a/go.sum +++ b/go.sum @@ -24,6 +24,8 @@ github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/gorilla/handlers v1.4.2 h1:0QniY0USkHQ1RGCLfKxeNHK9bkDHGRYGNDFBCS+YARg= +github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= diff --git a/pkg/fetcher/api_default_service.go b/pkg/fetcher/api_default_service.go index fdb8738..f479a5b 100644 --- a/pkg/fetcher/api_default_service.go +++ b/pkg/fetcher/api_default_service.go @@ -1,12 +1,3 @@ -/* - * jessemichael.me internal - * - * Internal workings of Jesse Michael - * - * API version: v1 - * Generated by: OpenAPI Generator (https://openapi-generator.tech) - */ - package fetcher import ( @@ -15,6 +6,7 @@ import ( "log" "net/http" "net/url" + "regexp" "sort" "sync" "time" @@ -168,6 +160,8 @@ func (s *DefaultApiService) getTwitter(twitterID int64) ([]FeedItem, error) { items := []FeedItem{} for _, tweet := range tweets { + fmt.Printf("tweet: %+v", tweet) + fmt.Printf("\n\n\n\n") tweetURL := fmt.Sprintf("https://twitter.com/%s/status/%s", tweet.User.ScreenName, tweet.IDStr) author := fmt.Sprintf(" %s: ", tweetURL, tweet.User.ProfileImageURL, tweet.User.ScreenName) media := "" @@ -185,13 +179,20 @@ func (s *DefaultApiService) getTwitter(twitterID int64) ([]FeedItem, error) { Source: "twitter", Url: tweetURL, Media: []FeedItemMedia{}, - Content: author + tweet.FullText + media, + Content: author + replaceTextWithHyperlink(tweet.FullText) + media, } items = append(items, item) } return items, nil } +func replaceTextWithHyperlink(text string) string { + var re = regexp.MustCompile(`\bhttp\S*`) + return re.ReplaceAllStringFunc(text, func(s string) string { + return fmt.Sprintf(`%s`, s, s) + }) +} + func (s *DefaultApiService) getInstagram(instagramID int64) ([]FeedItem, error) { if s.iClient == nil || instagramID == 0 { return nil, nil