Skip to content

Commit

Permalink
žblj
Browse files Browse the repository at this point in the history
  • Loading branch information
mytja authored Nov 13, 2024
1 parent 8df10b6 commit 151afe2
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions sharepoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,17 @@ func (server *httpImpl) SendNotificationToWebhook(webhook string, editing bool,
Fields: []EmbedField{
{
Name: "Ustvarjeno",
Value: created,
Value: fmt.Sprintf("`%s`", created),
Inline: true,
},
{
Name: "Nazadnje spremenjeno",
Value: modified,
Value: fmt.Sprintf("`%s`", modified),
Inline: true,
},
{
Name: "Nazadnje spremenil",
Value: notification.ModifiedBy,
Value: fmt.Sprintf("`%s`", notification.ModifiedBy),
Inline: true,
},
},
Expand Down Expand Up @@ -345,15 +345,29 @@ func (server *httpImpl) GetSharepointNotificationsGoroutine(accessToken string)
break
}

opt := &md.Options{
LinkStyle: "referenced",
// ne posodabljaj za vsak drek
if noterr != nil || int(notificationResponse.Fields.Modified.Unix()) != notificationDb.ModifiedOn {
continue
}

opt := &md.Options{}
converter := md.NewConverter("", true, opt)
markdown, err := converter.ConvertString(notificationResponse.Fields.Body)
if err != nil {
server.logger.Errorw("error parsing Sharepoint HTML", "err", err)
break
}

// ker discord je pač retarded
r := regexp.MustCompile(`\[(?P<URL>.*)\]\(.*\)`, -1)
res := r.FindAllStringSubmatch(markdown)
for _, l := range res {
if len(l) < 2 {
continue
}
markdown = strings.ReplaceAll(markdown, l[0], l[1])
}

notificationResponse.Fields.Body = markdown

expires := int(notificationResponse.Fields.Expires.Unix())
Expand Down

0 comments on commit 151afe2

Please sign in to comment.