summaryrefslogtreecommitdiff
path: root/internal/typeutils/util.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-01-25 11:12:27 +0100
committerLibravatar GitHub <noreply@github.com>2023-01-25 11:12:27 +0100
commit993aae5e48a5a3b47a7c7bb3cb66e2d8abda17b2 (patch)
treea64ad3edaf2a29f457bd050b24609fe4f1abdf02 /internal/typeutils/util.go
parent[feature] Implement reports admin API so admins can view + close reports (#1378) (diff)
downloadgotosocial-993aae5e48a5a3b47a7c7bb3cb66e2d8abda17b2.tar.xz
[feature] Accept incoming federated Flag activity (#1382)
* start working on handling incoming Flag activity * interim commit * federate Flag in successfully
Diffstat (limited to 'internal/typeutils/util.go')
-rw-r--r--internal/typeutils/util.go43
1 files changed, 37 insertions, 6 deletions
diff --git a/internal/typeutils/util.go b/internal/typeutils/util.go
index 1d1903afc..40001e913 100644
--- a/internal/typeutils/util.go
+++ b/internal/typeutils/util.go
@@ -1,12 +1,39 @@
+/*
+ GoToSocial
+ Copyright (C) 2021-2023 GoToSocial Authors admin@gotosocial.org
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
package typeutils
import (
"context"
"fmt"
+ "net/url"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/regexes"
)
+type statusInteractions struct {
+ Faved bool
+ Muted bool
+ Bookmarked bool
+ Reblogged bool
+}
+
func (c *converter) interactionsWithStatusForAccount(ctx context.Context, s *gtsmodel.Status, requestingAccount *gtsmodel.Account) (*statusInteractions, error) {
si := &statusInteractions{}
@@ -38,10 +65,14 @@ func (c *converter) interactionsWithStatusForAccount(ctx context.Context, s *gts
return si, nil
}
-// StatusInteractions denotes interactions with a status on behalf of an account.
-type statusInteractions struct {
- Faved bool
- Muted bool
- Bookmarked bool
- Reblogged bool
+func misskeyReportInlineURLs(content string) []*url.URL {
+ m := regexes.MisskeyReportNotes.FindAllStringSubmatch(content, -1)
+ urls := make([]*url.URL, 0, len(m))
+ for _, sm := range m {
+ url, err := url.Parse(sm[1])
+ if err == nil && url != nil {
+ urls = append(urls, url)
+ }
+ }
+ return urls
}