mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-25 06:09:22 +02:00
Merge branch 'master' into absolute_fluoride
This commit is contained in:
commit
9f34b60749
1
Makefile
1
Makefile
|
@ -7,7 +7,6 @@ SHAREPATH=$(PREFIX)/share/bloat
|
||||||
TMPL=templates/*.tmpl
|
TMPL=templates/*.tmpl
|
||||||
SRC=main.go \
|
SRC=main.go \
|
||||||
config/*.go \
|
config/*.go \
|
||||||
kv/*.go \
|
|
||||||
mastodon/*.go \
|
mastodon/*.go \
|
||||||
model/*.go \
|
model/*.go \
|
||||||
renderer/*.go \
|
renderer/*.go \
|
||||||
|
|
|
@ -101,7 +101,7 @@ func Parse(r io.Reader) (c *config, err error) {
|
||||||
case "log_file":
|
case "log_file":
|
||||||
c.LogFile = val
|
c.LogFile = val
|
||||||
default:
|
default:
|
||||||
return nil, errors.New("invliad config key " + key)
|
return nil, errors.New("invalid config key " + key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
9
main.go
9
main.go
|
@ -12,7 +12,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"bloat/config"
|
"bloat/config"
|
||||||
"bloat/kv"
|
|
||||||
"bloat/renderer"
|
"bloat/renderer"
|
||||||
"bloat/repo"
|
"bloat/repo"
|
||||||
"bloat/service"
|
"bloat/service"
|
||||||
|
@ -76,13 +75,13 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
sessionDBPath := filepath.Join(config.DatabasePath, "session")
|
sessionDBPath := filepath.Join(config.DatabasePath, "session")
|
||||||
sessionDB, err := kv.NewDatabse(sessionDBPath)
|
sessionDB, err := util.NewDatabse(sessionDBPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errExit(err)
|
errExit(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
appDBPath := filepath.Join(config.DatabasePath, "app")
|
appDBPath := filepath.Join(config.DatabasePath, "app")
|
||||||
appDB, err := kv.NewDatabse(appDBPath)
|
appDB, err := util.NewDatabse(appDBPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errExit(err)
|
errExit(err)
|
||||||
}
|
}
|
||||||
|
@ -114,9 +113,7 @@ func main() {
|
||||||
s := service.NewService(config.ClientName, config.ClientScope,
|
s := service.NewService(config.ClientName, config.ClientScope,
|
||||||
config.ClientWebsite, customCSS, config.PostFormats, renderer,
|
config.ClientWebsite, customCSS, config.PostFormats, renderer,
|
||||||
sessionRepo, appRepo, config.SingleInstance)
|
sessionRepo, appRepo, config.SingleInstance)
|
||||||
s = service.NewAuthService(sessionRepo, appRepo, s)
|
handler := service.NewHandler(s, logger, config.StaticDirectory)
|
||||||
s = service.NewLoggingService(logger, s)
|
|
||||||
handler := service.NewHandler(s, config.StaticDirectory)
|
|
||||||
|
|
||||||
logger.Println("listening on", config.ListenAddress)
|
logger.Println("listening on", config.ListenAddress)
|
||||||
err = http.ListenAndServe(config.ListenAddress, handler)
|
err = http.ListenAndServe(config.ListenAddress, handler)
|
||||||
|
|
|
@ -60,7 +60,7 @@ func (c *Client) GetAccount(ctx context.Context, id string) (*Account, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if account.Pleroma == nil {
|
if account.Pleroma == nil || len(account.Pleroma.Relationship.ID) < 1 {
|
||||||
rs, err := c.GetAccountRelationships(ctx, []string{id})
|
rs, err := c.GetAccountRelationships(ctx, []string{id})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -91,7 +91,12 @@ func (c *Client) doAPI(ctx context.Context, method string, uri string, params in
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
mw := multipart.NewWriter(&buf)
|
mw := multipart.NewWriter(&buf)
|
||||||
part, err := mw.CreateFormFile("file", filepath.Base(file.Filename))
|
fname := filepath.Base(file.Filename)
|
||||||
|
err = mw.WriteField("description", fname)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
part, err := mw.CreateFormFile("file", fname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,9 +191,11 @@ func (c *Client) GetTimelineHome(ctx context.Context, pg *Pagination) ([]*Status
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTimelinePublic return statuses from public timeline.
|
// GetTimelinePublic return statuses from public timeline.
|
||||||
func (c *Client) GetTimelinePublic(ctx context.Context, isLocal bool, pg *Pagination) ([]*Status, error) {
|
func (c *Client) GetTimelinePublic(ctx context.Context, isLocal bool, instance string, pg *Pagination) ([]*Status, error) {
|
||||||
params := url.Values{}
|
params := url.Values{}
|
||||||
if isLocal {
|
if len(instance) > 0 {
|
||||||
|
params.Set("instance", instance)
|
||||||
|
} else if isLocal {
|
||||||
params.Set("local", "true")
|
params.Set("local", "true")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
package model
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
|
|
||||||
"bloat/mastodon"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ClientCtx struct {
|
|
||||||
SessionID string
|
|
||||||
CSRFToken string
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
|
||||||
*mastodon.Client
|
|
||||||
Writer io.Writer
|
|
||||||
Ctx ClientCtx
|
|
||||||
Session Session
|
|
||||||
}
|
|
|
@ -10,7 +10,6 @@ type PostContext struct {
|
||||||
DefaultFormat string
|
DefaultFormat string
|
||||||
ReplyContext *ReplyContext
|
ReplyContext *ReplyContext
|
||||||
Formats []PostFormat
|
Formats []PostFormat
|
||||||
DarkMode bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReplyContext struct {
|
type ReplyContext struct {
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
package model
|
package model
|
||||||
|
|
||||||
type Settings struct {
|
type Settings struct {
|
||||||
DefaultVisibility string `json:"default_visibility"`
|
DefaultVisibility string `json:"default_visibility"`
|
||||||
DefaultFormat string `json:"default_format"`
|
DefaultFormat string `json:"default_format"`
|
||||||
CopyScope bool `json:"copy_scope"`
|
CopyScope bool `json:"copy_scope"`
|
||||||
ThreadInNewTab bool `json:"thread_in_new_tab"`
|
ThreadInNewTab bool `json:"thread_in_new_tab"`
|
||||||
HideAttachments bool `json:"hide_attachments"`
|
HideAttachments bool `json:"hide_attachments"`
|
||||||
MaskNSFW bool `json:"mask_nfsw"`
|
MaskNSFW bool `json:"mask_nfsw"`
|
||||||
AutoRefreshNotifications bool `json:"auto_refresh_notifications"`
|
NotificationInterval int `json:"notifications_interval"`
|
||||||
FluorideMode bool `json:"fluoride_mode"`
|
FluorideMode bool `json:"fluoride_mode"`
|
||||||
DarkMode bool `json:"dark_mode"`
|
DarkMode bool `json:"dark_mode"`
|
||||||
AntiDopamineMode bool `json:"anti_dopamine_mode"`
|
AntiDopamineMode bool `json:"anti_dopamine_mode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSettings() *Settings {
|
func NewSettings() *Settings {
|
||||||
return &Settings{
|
return &Settings{
|
||||||
DefaultVisibility: "public",
|
DefaultVisibility: "public",
|
||||||
DefaultFormat: "",
|
DefaultFormat: "",
|
||||||
CopyScope: true,
|
CopyScope: true,
|
||||||
ThreadInNewTab: false,
|
ThreadInNewTab: false,
|
||||||
HideAttachments: false,
|
HideAttachments: false,
|
||||||
MaskNSFW: true,
|
MaskNSFW: true,
|
||||||
AutoRefreshNotifications: false,
|
NotificationInterval: 0,
|
||||||
FluorideMode: false,
|
FluorideMode: false,
|
||||||
DarkMode: false,
|
DarkMode: false,
|
||||||
AntiDopamineMode: false,
|
AntiDopamineMode: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ type Context struct {
|
||||||
CSRFToken string
|
CSRFToken string
|
||||||
UserID string
|
UserID string
|
||||||
AntiDopamineMode bool
|
AntiDopamineMode bool
|
||||||
|
Referrer string
|
||||||
}
|
}
|
||||||
|
|
||||||
type NavData struct {
|
type NavData struct {
|
||||||
|
@ -23,12 +24,12 @@ type NavData struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type CommonData struct {
|
type CommonData struct {
|
||||||
Title string
|
Title string
|
||||||
CustomCSS string
|
CustomCSS string
|
||||||
CSRFToken string
|
CSRFToken string
|
||||||
Count int
|
Count int
|
||||||
AutoRefresh bool
|
RefreshInterval int
|
||||||
Target string
|
Target string
|
||||||
}
|
}
|
||||||
|
|
||||||
type ErrorData struct {
|
type ErrorData struct {
|
||||||
|
@ -51,6 +52,8 @@ type RootData struct {
|
||||||
type TimelineData struct {
|
type TimelineData struct {
|
||||||
*CommonData
|
*CommonData
|
||||||
Title string
|
Title string
|
||||||
|
Type string
|
||||||
|
Instance string
|
||||||
Statuses []*mastodon.Status
|
Statuses []*mastodon.Status
|
||||||
NextLink string
|
NextLink string
|
||||||
PrevLink string
|
PrevLink string
|
||||||
|
|
|
@ -3,15 +3,15 @@ package repo
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"bloat/kv"
|
"bloat/util"
|
||||||
"bloat/model"
|
"bloat/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
type appRepo struct {
|
type appRepo struct {
|
||||||
db *kv.Database
|
db *util.Database
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAppRepo(db *kv.Database) *appRepo {
|
func NewAppRepo(db *util.Database) *appRepo {
|
||||||
return &appRepo{
|
return &appRepo{
|
||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,15 +3,15 @@ package repo
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"bloat/kv"
|
"bloat/util"
|
||||||
"bloat/model"
|
"bloat/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
type sessionRepo struct {
|
type sessionRepo struct {
|
||||||
db *kv.Database
|
db *util.Database
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSessionRepo(db *kv.Database) *sessionRepo {
|
func NewSessionRepo(db *util.Database) *sessionRepo {
|
||||||
return &sessionRepo{
|
return &sessionRepo{
|
||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
|
|
488
service/auth.go
488
service/auth.go
|
@ -1,488 +0,0 @@
|
||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"mime/multipart"
|
|
||||||
|
|
||||||
"bloat/mastodon"
|
|
||||||
"bloat/model"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
errInvalidSession = errors.New("invalid session")
|
|
||||||
errInvalidAccessToken = errors.New("invalid access token")
|
|
||||||
errInvalidCSRFToken = errors.New("invalid csrf token")
|
|
||||||
)
|
|
||||||
|
|
||||||
type as struct {
|
|
||||||
sessionRepo model.SessionRepo
|
|
||||||
appRepo model.AppRepo
|
|
||||||
Service
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewAuthService(sessionRepo model.SessionRepo, appRepo model.AppRepo, s Service) Service {
|
|
||||||
return &as{sessionRepo, appRepo, s}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) initClient(c *model.Client) (err error) {
|
|
||||||
if len(c.Ctx.SessionID) < 1 {
|
|
||||||
return errInvalidSession
|
|
||||||
}
|
|
||||||
session, err := s.sessionRepo.Get(c.Ctx.SessionID)
|
|
||||||
if err != nil {
|
|
||||||
return errInvalidSession
|
|
||||||
}
|
|
||||||
app, err := s.appRepo.Get(session.InstanceDomain)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
mc := mastodon.NewClient(&mastodon.Config{
|
|
||||||
Server: app.InstanceURL,
|
|
||||||
ClientID: app.ClientID,
|
|
||||||
ClientSecret: app.ClientSecret,
|
|
||||||
AccessToken: session.AccessToken,
|
|
||||||
})
|
|
||||||
c.Client = mc
|
|
||||||
c.Session = session
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) authenticateClient(c *model.Client) (err error) {
|
|
||||||
err = s.initClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(c.Session.AccessToken) < 1 {
|
|
||||||
return errInvalidAccessToken
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func checkCSRF(c *model.Client) (err error) {
|
|
||||||
if c.Ctx.CSRFToken != c.Session.CSRFToken {
|
|
||||||
return errInvalidCSRFToken
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) ServeErrorPage(c *model.Client, err error) {
|
|
||||||
s.authenticateClient(c)
|
|
||||||
s.Service.ServeErrorPage(c, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) ServeSigninPage(c *model.Client) (err error) {
|
|
||||||
return s.Service.ServeSigninPage(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) ServeRootPage(c *model.Client) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.ServeRootPage(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) ServeNavPage(c *model.Client) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.ServeNavPage(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) ServeTimelinePage(c *model.Client, tType string,
|
|
||||||
maxID string, minID string) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.ServeTimelinePage(c, tType, maxID, minID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) ServeThreadPage(c *model.Client, id string, reply bool) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.ServeThreadPage(c, id, reply)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) ServeStatusPopup(c *model.Client, id string) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.ServeStatusPopup(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) ServeLikedByPage(c *model.Client, id string) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.ServeLikedByPage(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) ServeRetweetedByPage(c *model.Client, id string) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.ServeRetweetedByPage(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) ServeNotificationPage(c *model.Client,
|
|
||||||
maxID string, minID string) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.ServeNotificationPage(c, maxID, minID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) ServeUserPage(c *model.Client, id string,
|
|
||||||
pageType string, maxID string, minID string) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.ServeUserPage(c, id, pageType, maxID, minID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) ServeAboutPage(c *model.Client) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.ServeAboutPage(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) ServeEmojiPage(c *model.Client) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.ServeEmojiPage(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) ServeSearchPage(c *model.Client, q string,
|
|
||||||
qType string, offset int) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.ServeSearchPage(c, q, qType, offset)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) ServeUserSearchPage(c *model.Client,
|
|
||||||
id string, q string, offset int) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.ServeUserSearchPage(c, id, q, offset)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) ServeSettingsPage(c *model.Client) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.ServeSettingsPage(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) NewSession(instance string) (redirectUrl string,
|
|
||||||
sessionID string, err error) {
|
|
||||||
return s.Service.NewSession(instance)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) Signin(c *model.Client, sessionID string,
|
|
||||||
code string) (token string, userID string, err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil && err != errInvalidAccessToken {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
token, userID, err = s.Service.Signin(c, c.Session.ID, code)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.Session.AccessToken = token
|
|
||||||
c.Session.UserID = userID
|
|
||||||
|
|
||||||
err = s.sessionRepo.Add(c.Session)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) Signout(c *model.Client) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Service.Signout(c)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) Post(c *model.Client, content string,
|
|
||||||
replyToID string, format string, visibility string, isNSFW bool,
|
|
||||||
files []*multipart.FileHeader) (id string, err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.Post(c, content, replyToID, format, visibility, isNSFW, files)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) Like(c *model.Client, id string) (count int64, err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.Like(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) UnLike(c *model.Client, id string) (count int64, err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.UnLike(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) Retweet(c *model.Client, id string) (count int64, err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.Retweet(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) UnRetweet(c *model.Client, id string) (count int64, err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.UnRetweet(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) Vote(c *model.Client, id string,
|
|
||||||
choices []string) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.Vote(c, id, choices)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) Follow(c *model.Client, id string, reblogs *bool) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.Follow(c, id, reblogs)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) UnFollow(c *model.Client, id string) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.UnFollow(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) Mute(c *model.Client, id string) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.Mute(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) UnMute(c *model.Client, id string) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.UnMute(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) Block(c *model.Client, id string) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.Block(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) UnBlock(c *model.Client, id string) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.UnBlock(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) Subscribe(c *model.Client, id string) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.Subscribe(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) UnSubscribe(c *model.Client, id string) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.UnSubscribe(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) SaveSettings(c *model.Client, settings *model.Settings) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.SaveSettings(c, settings)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) MuteConversation(c *model.Client, id string) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.MuteConversation(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) UnMuteConversation(c *model.Client, id string) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.UnMuteConversation(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) Delete(c *model.Client, id string) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.Delete(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) ReadNotifications(c *model.Client, maxID string) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.ReadNotifications(c, maxID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) Bookmark(c *model.Client, id string) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.Bookmark(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *as) UnBookmark(c *model.Client, id string) (err error) {
|
|
||||||
err = s.authenticateClient(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = checkCSRF(c)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return s.Service.UnBookmark(c, id)
|
|
||||||
}
|
|
|
@ -1,349 +0,0 @@
|
||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"log"
|
|
||||||
"mime/multipart"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"bloat/model"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ls struct {
|
|
||||||
logger *log.Logger
|
|
||||||
Service
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewLoggingService(logger *log.Logger, s Service) Service {
|
|
||||||
return &ls{logger, s}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) ServeErrorPage(c *model.Client, err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, err=%v, took=%v\n",
|
|
||||||
"ServeErrorPage", err, time.Since(begin))
|
|
||||||
}(time.Now())
|
|
||||||
s.Service.ServeErrorPage(c, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) ServeSigninPage(c *model.Client) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, took=%v, err=%v\n",
|
|
||||||
"ServeSigninPage", time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.ServeSigninPage(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) ServeRootPage(c *model.Client) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, took=%v, err=%v\n",
|
|
||||||
"ServeRootPage", time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.ServeRootPage(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) ServeNavPage(c *model.Client) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, took=%v, err=%v\n",
|
|
||||||
"ServeNavPage", time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.ServeNavPage(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) ServeTimelinePage(c *model.Client, tType string,
|
|
||||||
maxID string, minID string) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, type=%v, took=%v, err=%v\n",
|
|
||||||
"ServeTimelinePage", tType, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.ServeTimelinePage(c, tType, maxID, minID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) ServeThreadPage(c *model.Client, id string,
|
|
||||||
reply bool) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"ServeThreadPage", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.ServeThreadPage(c, id, reply)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) ServeStatusPopup(c *model.Client, id string) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"ServeStatusPopup", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.ServeStatusPopup(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) ServeLikedByPage(c *model.Client, id string) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"ServeLikedByPage", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.ServeLikedByPage(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) ServeRetweetedByPage(c *model.Client, id string) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"ServeRetweetedByPage", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.ServeRetweetedByPage(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) ServeNotificationPage(c *model.Client,
|
|
||||||
maxID string, minID string) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, took=%v, err=%v\n",
|
|
||||||
"ServeNotificationPage", time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.ServeNotificationPage(c, maxID, minID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) ServeUserPage(c *model.Client, id string,
|
|
||||||
pageType string, maxID string, minID string) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, type=%v, took=%v, err=%v\n",
|
|
||||||
"ServeUserPage", id, pageType, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.ServeUserPage(c, id, pageType, maxID, minID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) ServeAboutPage(c *model.Client) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, took=%v, err=%v\n",
|
|
||||||
"ServeAboutPage", time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.ServeAboutPage(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) ServeEmojiPage(c *model.Client) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, took=%v, err=%v\n",
|
|
||||||
"ServeEmojiPage", time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.ServeEmojiPage(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) ServeSearchPage(c *model.Client, q string,
|
|
||||||
qType string, offset int) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, took=%v, err=%v\n",
|
|
||||||
"ServeSearchPage", time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.ServeSearchPage(c, q, qType, offset)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) ServeUserSearchPage(c *model.Client,
|
|
||||||
id string, q string, offset int) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, took=%v, err=%v\n",
|
|
||||||
"ServeUserSearchPage", time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.ServeUserSearchPage(c, id, q, offset)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) ServeSettingsPage(c *model.Client) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, took=%v, err=%v\n",
|
|
||||||
"ServeSettingsPage", time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.ServeSettingsPage(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) NewSession(instance string) (redirectUrl string,
|
|
||||||
sessionID string, err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, instance=%v, took=%v, err=%v\n",
|
|
||||||
"NewSession", instance, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.NewSession(instance)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) Signin(c *model.Client, sessionID string,
|
|
||||||
code string) (token string, userID string, err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, session_id=%v, took=%v, err=%v\n",
|
|
||||||
"Signin", sessionID, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.Signin(c, sessionID, code)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) Signout(c *model.Client) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, took=%v, err=%v\n",
|
|
||||||
"Signout", time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.Signout(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) Post(c *model.Client, content string,
|
|
||||||
replyToID string, format string, visibility string, isNSFW bool,
|
|
||||||
files []*multipart.FileHeader) (id string, err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, took=%v, err=%v\n",
|
|
||||||
"Post", time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.Post(c, content, replyToID, format,
|
|
||||||
visibility, isNSFW, files)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) Like(c *model.Client, id string) (count int64, err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"Like", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.Like(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) UnLike(c *model.Client, id string) (count int64, err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"UnLike", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.UnLike(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) Retweet(c *model.Client, id string) (count int64, err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"Retweet", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.Retweet(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) UnRetweet(c *model.Client, id string) (count int64, err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"UnRetweet", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.UnRetweet(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) Vote(c *model.Client, id string, choices []string) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"Vote", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.Vote(c, id, choices)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) Follow(c *model.Client, id string, reblogs *bool) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"Follow", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.Follow(c, id, reblogs)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) UnFollow(c *model.Client, id string) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"UnFollow", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.UnFollow(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) Mute(c *model.Client, id string) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"Mute", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.Mute(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) UnMute(c *model.Client, id string) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"UnMute", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.UnMute(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) Block(c *model.Client, id string) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"Block", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.Block(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) UnBlock(c *model.Client, id string) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"UnBlock", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.UnBlock(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) Subscribe(c *model.Client, id string) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"Subscribe", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.Subscribe(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) UnSubscribe(c *model.Client, id string) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"UnSubscribe", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.UnSubscribe(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) SaveSettings(c *model.Client, settings *model.Settings) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, took=%v, err=%v\n",
|
|
||||||
"SaveSettings", time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.SaveSettings(c, settings)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) MuteConversation(c *model.Client, id string) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"MuteConversation", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.MuteConversation(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) UnMuteConversation(c *model.Client, id string) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"UnMuteConversation", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.UnMuteConversation(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) Delete(c *model.Client, id string) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"Delete", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.Delete(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) ReadNotifications(c *model.Client, maxID string) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, max_id=%v, took=%v, err=%v\n",
|
|
||||||
"ReadNotifications", maxID, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.ReadNotifications(c, maxID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) Bookmark(c *model.Client, id string) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"Bookmark", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.Bookmark(c, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ls) UnBookmark(c *model.Client, id string) (err error) {
|
|
||||||
defer func(begin time.Time) {
|
|
||||||
s.logger.Printf("method=%v, id=%v, took=%v, err=%v\n",
|
|
||||||
"UnBookmark", id, time.Since(begin), err)
|
|
||||||
}(time.Now())
|
|
||||||
return s.Service.UnBookmark(c, id)
|
|
||||||
}
|
|
|
@ -20,54 +20,6 @@ var (
|
||||||
errInvalidArgument = errors.New("invalid argument")
|
errInvalidArgument = errors.New("invalid argument")
|
||||||
)
|
)
|
||||||
|
|
||||||
type Service interface {
|
|
||||||
ServeErrorPage(c *model.Client, err error)
|
|
||||||
ServeSigninPage(c *model.Client) (err error)
|
|
||||||
ServeRootPage(c *model.Client) (err error)
|
|
||||||
ServeNavPage(c *model.Client) (err error)
|
|
||||||
ServeTimelinePage(c *model.Client, tType string, maxID string,
|
|
||||||
minID string) (err error)
|
|
||||||
ServeThreadPage(c *model.Client, id string, reply bool) (err error)
|
|
||||||
ServeStatusPopup(c *model.Client, id string) (err error)
|
|
||||||
ServeLikedByPage(c *model.Client, id string) (err error)
|
|
||||||
ServeRetweetedByPage(c *model.Client, id string) (err error)
|
|
||||||
ServeNotificationPage(c *model.Client, maxID string, minID string) (err error)
|
|
||||||
ServeUserPage(c *model.Client, id string, pageType string, maxID string,
|
|
||||||
minID string) (err error)
|
|
||||||
ServeAboutPage(c *model.Client) (err error)
|
|
||||||
ServeEmojiPage(c *model.Client) (err error)
|
|
||||||
ServeSearchPage(c *model.Client, q string, qType string, offset int) (err error)
|
|
||||||
ServeUserSearchPage(c *model.Client, id string, q string, offset int) (err error)
|
|
||||||
ServeSettingsPage(c *model.Client) (err error)
|
|
||||||
SingleInstance() (instance string, ok bool)
|
|
||||||
NewSession(instance string) (redirectUrl string, sessionID string, err error)
|
|
||||||
Signin(c *model.Client, sessionID string, code string) (token string,
|
|
||||||
userID string, err error)
|
|
||||||
Signout(c *model.Client) (err error)
|
|
||||||
Post(c *model.Client, content string, replyToID string, format string, visibility string,
|
|
||||||
isNSFW bool, files []*multipart.FileHeader) (id string, err error)
|
|
||||||
Like(c *model.Client, id string) (count int64, err error)
|
|
||||||
UnLike(c *model.Client, id string) (count int64, err error)
|
|
||||||
Retweet(c *model.Client, id string) (count int64, err error)
|
|
||||||
UnRetweet(c *model.Client, id string) (count int64, err error)
|
|
||||||
Vote(c *model.Client, id string, choices []string) (err error)
|
|
||||||
Follow(c *model.Client, id string, reblogs *bool) (err error)
|
|
||||||
UnFollow(c *model.Client, id string) (err error)
|
|
||||||
Mute(c *model.Client, id string) (err error)
|
|
||||||
UnMute(c *model.Client, id string) (err error)
|
|
||||||
Block(c *model.Client, id string) (err error)
|
|
||||||
UnBlock(c *model.Client, id string) (err error)
|
|
||||||
Subscribe(c *model.Client, id string) (err error)
|
|
||||||
UnSubscribe(c *model.Client, id string) (err error)
|
|
||||||
SaveSettings(c *model.Client, settings *model.Settings) (err error)
|
|
||||||
MuteConversation(c *model.Client, id string) (err error)
|
|
||||||
UnMuteConversation(c *model.Client, id string) (err error)
|
|
||||||
Delete(c *model.Client, id string) (err error)
|
|
||||||
ReadNotifications(c *model.Client, maxID string) (err error)
|
|
||||||
Bookmark(c *model.Client, id string) (err error)
|
|
||||||
UnBookmark(c *model.Client, id string) (err error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type service struct {
|
type service struct {
|
||||||
clientName string
|
clientName string
|
||||||
clientScope string
|
clientScope string
|
||||||
|
@ -89,7 +41,7 @@ func NewService(clientName string,
|
||||||
sessionRepo model.SessionRepo,
|
sessionRepo model.SessionRepo,
|
||||||
appRepo model.AppRepo,
|
appRepo model.AppRepo,
|
||||||
singleInstance string,
|
singleInstance string,
|
||||||
) Service {
|
) *service {
|
||||||
return &service{
|
return &service{
|
||||||
clientName: clientName,
|
clientName: clientName,
|
||||||
clientScope: clientScope,
|
clientScope: clientScope,
|
||||||
|
@ -103,12 +55,14 @@ func NewService(clientName string,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRendererContext(c *model.Client) *renderer.Context {
|
func getRendererContext(c *client) *renderer.Context {
|
||||||
var settings model.Settings
|
var settings model.Settings
|
||||||
var session model.Session
|
var session model.Session
|
||||||
|
var referrer string
|
||||||
if c != nil {
|
if c != nil {
|
||||||
settings = c.Session.Settings
|
settings = c.Session.Settings
|
||||||
session = c.Session
|
session = c.Session
|
||||||
|
referrer = c.url()
|
||||||
} else {
|
} else {
|
||||||
settings = *model.NewSettings()
|
settings = *model.NewSettings()
|
||||||
}
|
}
|
||||||
|
@ -121,6 +75,7 @@ func getRendererContext(c *model.Client) *renderer.Context {
|
||||||
CSRFToken: session.CSRFToken,
|
CSRFToken: session.CSRFToken,
|
||||||
UserID: session.UserID,
|
UserID: session.UserID,
|
||||||
AntiDopamineMode: settings.AntiDopamineMode,
|
AntiDopamineMode: settings.AntiDopamineMode,
|
||||||
|
Referrer: referrer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,26 +84,21 @@ func addToReplyMap(m map[string][]mastodon.ReplyInfo, key interface{},
|
||||||
if key == nil {
|
if key == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
keyStr, ok := key.(string)
|
keyStr, ok := key.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, ok = m[keyStr]
|
_, ok = m[keyStr]
|
||||||
if !ok {
|
if !ok {
|
||||||
m[keyStr] = []mastodon.ReplyInfo{}
|
m[keyStr] = []mastodon.ReplyInfo{}
|
||||||
}
|
}
|
||||||
|
|
||||||
m[keyStr] = append(m[keyStr], mastodon.ReplyInfo{val, number})
|
m[keyStr] = append(m[keyStr], mastodon.ReplyInfo{val, number})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) getCommonData(c *model.Client,
|
func (s *service) getCommonData(c *client, title string) (data *renderer.CommonData) {
|
||||||
title string) (data *renderer.CommonData) {
|
|
||||||
|
|
||||||
data = &renderer.CommonData{
|
data = &renderer.CommonData{
|
||||||
Title: title + " - " + svc.clientName,
|
Title: title + " - " + s.clientName,
|
||||||
CustomCSS: svc.customCSS,
|
CustomCSS: s.customCSS,
|
||||||
}
|
}
|
||||||
if c != nil && c.Session.IsLoggedIn() {
|
if c != nil && c.Session.IsLoggedIn() {
|
||||||
data.CSRFToken = c.Session.CSRFToken
|
data.CSRFToken = c.Session.CSRFToken
|
||||||
|
@ -156,66 +106,59 @@ func (svc *service) getCommonData(c *model.Client,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) ServeErrorPage(c *model.Client, err error) {
|
func (s *service) ErrorPage(c *client, err error) {
|
||||||
var errStr string
|
var errStr string
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errStr = err.Error()
|
errStr = err.Error()
|
||||||
}
|
}
|
||||||
|
commonData := s.getCommonData(nil, "error")
|
||||||
commonData := svc.getCommonData(nil, "error")
|
|
||||||
data := &renderer.ErrorData{
|
data := &renderer.ErrorData{
|
||||||
CommonData: commonData,
|
CommonData: commonData,
|
||||||
Error: errStr,
|
Error: errStr,
|
||||||
}
|
}
|
||||||
|
|
||||||
rCtx := getRendererContext(c)
|
rCtx := getRendererContext(c)
|
||||||
svc.renderer.Render(rCtx, c.Writer, renderer.ErrorPage, data)
|
s.renderer.Render(rCtx, c, renderer.ErrorPage, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) ServeSigninPage(c *model.Client) (err error) {
|
func (s *service) SigninPage(c *client) (err error) {
|
||||||
commonData := svc.getCommonData(nil, "signin")
|
commonData := s.getCommonData(nil, "signin")
|
||||||
data := &renderer.SigninData{
|
data := &renderer.SigninData{
|
||||||
CommonData: commonData,
|
CommonData: commonData,
|
||||||
}
|
}
|
||||||
|
|
||||||
rCtx := getRendererContext(nil)
|
rCtx := getRendererContext(nil)
|
||||||
return svc.renderer.Render(rCtx, c.Writer, renderer.SigninPage, data)
|
return s.renderer.Render(rCtx, c, renderer.SigninPage, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) ServeRootPage(c *model.Client) (err error) {
|
func (s *service) RootPage(c *client) (err error) {
|
||||||
data := &renderer.RootData{
|
data := &renderer.RootData{
|
||||||
Title: svc.clientName,
|
Title: s.clientName,
|
||||||
}
|
}
|
||||||
|
|
||||||
rCtx := getRendererContext(c)
|
rCtx := getRendererContext(c)
|
||||||
return svc.renderer.Render(rCtx, c.Writer, renderer.RootPage, data)
|
return s.renderer.Render(rCtx, c, renderer.RootPage, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) ServeNavPage(c *model.Client) (err error) {
|
func (s *service) NavPage(c *client) (err error) {
|
||||||
u, err := c.GetAccountCurrentUser(ctx)
|
u, err := c.GetAccountCurrentUser(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
postContext := model.PostContext{
|
postContext := model.PostContext{
|
||||||
DefaultVisibility: c.Session.Settings.DefaultVisibility,
|
DefaultVisibility: c.Session.Settings.DefaultVisibility,
|
||||||
DefaultFormat: c.Session.Settings.DefaultFormat,
|
DefaultFormat: c.Session.Settings.DefaultFormat,
|
||||||
Formats: svc.postFormats,
|
Formats: s.postFormats,
|
||||||
}
|
}
|
||||||
|
commonData := s.getCommonData(c, "nav")
|
||||||
commonData := svc.getCommonData(c, "Nav")
|
|
||||||
commonData.Target = "main"
|
commonData.Target = "main"
|
||||||
data := &renderer.NavData{
|
data := &renderer.NavData{
|
||||||
User: u,
|
User: u,
|
||||||
CommonData: commonData,
|
CommonData: commonData,
|
||||||
PostContext: postContext,
|
PostContext: postContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
rCtx := getRendererContext(c)
|
rCtx := getRendererContext(c)
|
||||||
return svc.renderer.Render(rCtx, c.Writer, renderer.NavPage, data)
|
return s.renderer.Render(rCtx, c, renderer.NavPage, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) ServeTimelinePage(c *model.Client, tType string,
|
func (s *service) TimelinePage(c *client, tType string, instance string,
|
||||||
maxID string, minID string) (err error) {
|
maxID string, minID string) (err error) {
|
||||||
|
|
||||||
var nextLink, prevLink, title string
|
var nextLink, prevLink, title string
|
||||||
|
@ -236,10 +179,15 @@ func (svc *service) ServeTimelinePage(c *model.Client, tType string,
|
||||||
statuses, err = c.GetTimelineDirect(ctx, &pg)
|
statuses, err = c.GetTimelineDirect(ctx, &pg)
|
||||||
title = "Direct Timeline"
|
title = "Direct Timeline"
|
||||||
case "local":
|
case "local":
|
||||||
statuses, err = c.GetTimelinePublic(ctx, true, &pg)
|
statuses, err = c.GetTimelinePublic(ctx, true, "", &pg)
|
||||||
title = "Local Timeline"
|
title = "Local Timeline"
|
||||||
|
case "remote":
|
||||||
|
if len(instance) > 0 {
|
||||||
|
statuses, err = c.GetTimelinePublic(ctx, false, instance, &pg)
|
||||||
|
}
|
||||||
|
title = "Remote Timeline"
|
||||||
case "twkn":
|
case "twkn":
|
||||||
statuses, err = c.GetTimelinePublic(ctx, false, &pg)
|
statuses, err = c.GetTimelinePublic(ctx, false, "", &pg)
|
||||||
title = "The Whole Known Network"
|
title = "The Whole Known Network"
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -252,37 +200,29 @@ func (svc *service) ServeTimelinePage(c *model.Client, tType string,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(maxID) > 0 && len(statuses) > 0 {
|
if (len(maxID) > 0 || len(minID) > 0) && len(statuses) > 0 {
|
||||||
prevLink = fmt.Sprintf("/timeline/%s?min_id=%s", tType,
|
v := make(url.Values)
|
||||||
statuses[0].ID)
|
v.Set("min_id", statuses[0].ID)
|
||||||
}
|
if len(instance) > 0 {
|
||||||
|
v.Set("instance", instance)
|
||||||
if len(minID) > 0 && len(pg.MinID) > 0 {
|
|
||||||
newPg := &mastodon.Pagination{MinID: pg.MinID, Limit: 20}
|
|
||||||
newStatuses, err := c.GetTimelineHome(ctx, newPg)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
newLen := len(newStatuses)
|
prevLink = "/timeline/" + tType + "?" + v.Encode()
|
||||||
if newLen == 20 {
|
}
|
||||||
prevLink = fmt.Sprintf("/timeline/%s?min_id=%s",
|
|
||||||
tType, pg.MinID)
|
if len(minID) > 0 || (len(pg.MaxID) > 0 && len(statuses) == 20) {
|
||||||
} else {
|
v := make(url.Values)
|
||||||
i := 20 - newLen - 1
|
v.Set("max_id", pg.MaxID)
|
||||||
if len(statuses) > i {
|
if len(instance) > 0 {
|
||||||
prevLink = fmt.Sprintf("/timeline/%s?min_id=%s",
|
v.Set("instance", instance)
|
||||||
tType, statuses[i].ID)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
nextLink = "/timeline/" + tType + "?" + v.Encode()
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(pg.MaxID) > 0 && len(statuses) == 20 {
|
commonData := s.getCommonData(c, tType+" timeline ")
|
||||||
nextLink = fmt.Sprintf("/timeline/%s?max_id=%s", tType, pg.MaxID)
|
|
||||||
}
|
|
||||||
|
|
||||||
commonData := svc.getCommonData(c, tType+" timeline ")
|
|
||||||
data := &renderer.TimelineData{
|
data := &renderer.TimelineData{
|
||||||
Title: title,
|
Title: title,
|
||||||
|
Type: tType,
|
||||||
|
Instance: instance,
|
||||||
Statuses: statuses,
|
Statuses: statuses,
|
||||||
NextLink: nextLink,
|
NextLink: nextLink,
|
||||||
PrevLink: prevLink,
|
PrevLink: prevLink,
|
||||||
|
@ -290,10 +230,10 @@ func (svc *service) ServeTimelinePage(c *model.Client, tType string,
|
||||||
}
|
}
|
||||||
|
|
||||||
rCtx := getRendererContext(c)
|
rCtx := getRendererContext(c)
|
||||||
return svc.renderer.Render(rCtx, c.Writer, renderer.TimelinePage, data)
|
return s.renderer.Render(rCtx, c, renderer.TimelinePage, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) ServeThreadPage(c *model.Client, id string, reply bool) (err error) {
|
func (s *service) ThreadPage(c *client, id string, reply bool) (err error) {
|
||||||
var postContext model.PostContext
|
var postContext model.PostContext
|
||||||
|
|
||||||
status, err := c.GetStatus(ctx, id)
|
status, err := c.GetStatus(ctx, id)
|
||||||
|
@ -324,14 +264,13 @@ func (svc *service) ServeThreadPage(c *model.Client, id string, reply bool) (err
|
||||||
postContext = model.PostContext{
|
postContext = model.PostContext{
|
||||||
DefaultVisibility: visibility,
|
DefaultVisibility: visibility,
|
||||||
DefaultFormat: c.Session.Settings.DefaultFormat,
|
DefaultFormat: c.Session.Settings.DefaultFormat,
|
||||||
Formats: svc.postFormats,
|
Formats: s.postFormats,
|
||||||
ReplyContext: &model.ReplyContext{
|
ReplyContext: &model.ReplyContext{
|
||||||
InReplyToID: id,
|
InReplyToID: id,
|
||||||
InReplyToName: status.Account.Acct,
|
InReplyToName: status.Account.Acct,
|
||||||
ReplyContent: content,
|
ReplyContent: content,
|
||||||
ForceVisibility: isDirect,
|
ForceVisibility: isDirect,
|
||||||
},
|
},
|
||||||
DarkMode: c.Session.Settings.DarkMode,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +293,7 @@ func (svc *service) ServeThreadPage(c *model.Client, id string, reply bool) (err
|
||||||
addToReplyMap(replies, statuses[i].InReplyToID, statuses[i].ID, i+1)
|
addToReplyMap(replies, statuses[i].InReplyToID, statuses[i].ID, i+1)
|
||||||
}
|
}
|
||||||
|
|
||||||
commonData := svc.getCommonData(c, "post by "+status.Account.DisplayName)
|
commonData := s.getCommonData(c, "post by "+status.Account.DisplayName)
|
||||||
data := &renderer.ThreadData{
|
data := &renderer.ThreadData{
|
||||||
Statuses: statuses,
|
Statuses: statuses,
|
||||||
PostContext: postContext,
|
PostContext: postContext,
|
||||||
|
@ -363,51 +302,47 @@ func (svc *service) ServeThreadPage(c *model.Client, id string, reply bool) (err
|
||||||
}
|
}
|
||||||
|
|
||||||
rCtx := getRendererContext(c)
|
rCtx := getRendererContext(c)
|
||||||
return svc.renderer.Render(rCtx, c.Writer, renderer.ThreadPage, data)
|
return s.renderer.Render(rCtx, c, renderer.ThreadPage, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) ServeStatusPopup(c *model.Client, id string) (err error) {
|
func (svc *service) StatusPopup(c *client, id string) (err error) {
|
||||||
status, err := c.GetStatus(ctx, id)
|
status, err := c.GetStatus(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rCtx := getRendererContext(c)
|
rCtx := getRendererContext(c)
|
||||||
return svc.renderer.Render(rCtx, c.Writer, renderer.StatusPopup, status)
|
return svc.renderer.Render(rCtx, c, renderer.StatusPopup, status)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) ServeLikedByPage(c *model.Client, id string) (err error) {
|
func (s *service) LikedByPage(c *client, id string) (err error) {
|
||||||
likers, err := c.GetFavouritedBy(ctx, id, nil)
|
likers, err := c.GetFavouritedBy(ctx, id, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
commonData := s.getCommonData(c, "likes")
|
||||||
commonData := svc.getCommonData(c, "likes")
|
|
||||||
data := &renderer.LikedByData{
|
data := &renderer.LikedByData{
|
||||||
CommonData: commonData,
|
CommonData: commonData,
|
||||||
Users: likers,
|
Users: likers,
|
||||||
}
|
}
|
||||||
|
|
||||||
rCtx := getRendererContext(c)
|
rCtx := getRendererContext(c)
|
||||||
return svc.renderer.Render(rCtx, c.Writer, renderer.LikedByPage, data)
|
return s.renderer.Render(rCtx, c, renderer.LikedByPage, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) ServeRetweetedByPage(c *model.Client, id string) (err error) {
|
func (s *service) RetweetedByPage(c *client, id string) (err error) {
|
||||||
retweeters, err := c.GetRebloggedBy(ctx, id, nil)
|
retweeters, err := c.GetRebloggedBy(ctx, id, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
commonData := s.getCommonData(c, "retweets")
|
||||||
commonData := svc.getCommonData(c, "retweets")
|
|
||||||
data := &renderer.RetweetedByData{
|
data := &renderer.RetweetedByData{
|
||||||
CommonData: commonData,
|
CommonData: commonData,
|
||||||
Users: retweeters,
|
Users: retweeters,
|
||||||
}
|
}
|
||||||
|
|
||||||
rCtx := getRendererContext(c)
|
rCtx := getRendererContext(c)
|
||||||
return svc.renderer.Render(rCtx, c.Writer, renderer.RetweetedByPage, data)
|
return s.renderer.Render(rCtx, c, renderer.RetweetedByPage, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) ServeNotificationPage(c *model.Client, maxID string,
|
func (s *service) NotificationPage(c *client, maxID string,
|
||||||
minID string) (err error) {
|
minID string) (err error) {
|
||||||
|
|
||||||
var nextLink string
|
var nextLink string
|
||||||
|
@ -438,13 +373,12 @@ func (svc *service) ServeNotificationPage(c *model.Client, maxID string,
|
||||||
if unreadCount > 0 {
|
if unreadCount > 0 {
|
||||||
readID = notifications[0].ID
|
readID = notifications[0].ID
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(notifications) == 20 && len(pg.MaxID) > 0 {
|
if len(notifications) == 20 && len(pg.MaxID) > 0 {
|
||||||
nextLink = "/notifications?max_id=" + pg.MaxID
|
nextLink = "/notifications?max_id=" + pg.MaxID
|
||||||
}
|
}
|
||||||
|
|
||||||
commonData := svc.getCommonData(c, "notifications")
|
commonData := s.getCommonData(c, "notifications")
|
||||||
commonData.AutoRefresh = c.Session.Settings.AutoRefreshNotifications
|
commonData.RefreshInterval = c.Session.Settings.NotificationInterval
|
||||||
commonData.Target = "main"
|
commonData.Target = "main"
|
||||||
commonData.Count = unreadCount
|
commonData.Count = unreadCount
|
||||||
data := &renderer.NotificationData{
|
data := &renderer.NotificationData{
|
||||||
|
@ -455,10 +389,10 @@ func (svc *service) ServeNotificationPage(c *model.Client, maxID string,
|
||||||
CommonData: commonData,
|
CommonData: commonData,
|
||||||
}
|
}
|
||||||
rCtx := getRendererContext(c)
|
rCtx := getRendererContext(c)
|
||||||
return svc.renderer.Render(rCtx, c.Writer, renderer.NotificationPage, data)
|
return s.renderer.Render(rCtx, c, renderer.NotificationPage, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) ServeUserPage(c *model.Client, id string, pageType string,
|
func (s *service) UserPage(c *client, id string, pageType string,
|
||||||
maxID string, minID string) (err error) {
|
maxID string, minID string) (err error) {
|
||||||
|
|
||||||
var nextLink string
|
var nextLink string
|
||||||
|
@ -561,6 +495,18 @@ func (svc *service) ServeUserPage(c *model.Client, id string, pageType string,
|
||||||
nextLink = fmt.Sprintf("/user/%s/likes?max_id=%s",
|
nextLink = fmt.Sprintf("/user/%s/likes?max_id=%s",
|
||||||
id, pg.MaxID)
|
id, pg.MaxID)
|
||||||
}
|
}
|
||||||
|
case "requests":
|
||||||
|
if !isCurrent {
|
||||||
|
return errInvalidArgument
|
||||||
|
}
|
||||||
|
users, err = c.GetFollowRequests(ctx, &pg)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(users) == 20 && len(pg.MaxID) > 0 {
|
||||||
|
nextLink = fmt.Sprintf("/user/%s/requests?max_id=%s",
|
||||||
|
id, pg.MaxID)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return errInvalidArgument
|
return errInvalidArgument
|
||||||
}
|
}
|
||||||
|
@ -571,7 +517,7 @@ func (svc *service) ServeUserPage(c *model.Client, id string, pageType string,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
commonData := svc.getCommonData(c, user.DisplayName)
|
commonData := s.getCommonData(c, user.DisplayName)
|
||||||
data := &renderer.UserData{
|
data := &renderer.UserData{
|
||||||
User: user,
|
User: user,
|
||||||
IsCurrent: isCurrent,
|
IsCurrent: isCurrent,
|
||||||
|
@ -582,10 +528,10 @@ func (svc *service) ServeUserPage(c *model.Client, id string, pageType string,
|
||||||
CommonData: commonData,
|
CommonData: commonData,
|
||||||
}
|
}
|
||||||
rCtx := getRendererContext(c)
|
rCtx := getRendererContext(c)
|
||||||
return svc.renderer.Render(rCtx, c.Writer, renderer.UserPage, data)
|
return s.renderer.Render(rCtx, c, renderer.UserPage, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) ServeUserSearchPage(c *model.Client,
|
func (s *service) UserSearchPage(c *client,
|
||||||
id string, q string, offset int) (err error) {
|
id string, q string, offset int) (err error) {
|
||||||
|
|
||||||
var nextLink string
|
var nextLink string
|
||||||
|
@ -608,7 +554,8 @@ func (svc *service) ServeUserSearchPage(c *model.Client,
|
||||||
|
|
||||||
if len(results.Statuses) == 20 {
|
if len(results.Statuses) == 20 {
|
||||||
offset += 20
|
offset += 20
|
||||||
nextLink = fmt.Sprintf("/usersearch/%s?q=%s&offset=%d", id, url.QueryEscape(q), offset)
|
nextLink = fmt.Sprintf("/usersearch/%s?q=%s&offset=%d", id,
|
||||||
|
url.QueryEscape(q), offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
qq := template.HTMLEscapeString(q)
|
qq := template.HTMLEscapeString(q)
|
||||||
|
@ -616,7 +563,7 @@ func (svc *service) ServeUserSearchPage(c *model.Client,
|
||||||
title += " \"" + qq + "\""
|
title += " \"" + qq + "\""
|
||||||
}
|
}
|
||||||
|
|
||||||
commonData := svc.getCommonData(c, title)
|
commonData := s.getCommonData(c, title)
|
||||||
data := &renderer.UserSearchData{
|
data := &renderer.UserSearchData{
|
||||||
CommonData: commonData,
|
CommonData: commonData,
|
||||||
User: user,
|
User: user,
|
||||||
|
@ -624,38 +571,34 @@ func (svc *service) ServeUserSearchPage(c *model.Client,
|
||||||
Statuses: results.Statuses,
|
Statuses: results.Statuses,
|
||||||
NextLink: nextLink,
|
NextLink: nextLink,
|
||||||
}
|
}
|
||||||
|
|
||||||
rCtx := getRendererContext(c)
|
rCtx := getRendererContext(c)
|
||||||
return svc.renderer.Render(rCtx, c.Writer, renderer.UserSearchPage, data)
|
return s.renderer.Render(rCtx, c, renderer.UserSearchPage, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) ServeAboutPage(c *model.Client) (err error) {
|
func (s *service) AboutPage(c *client) (err error) {
|
||||||
commonData := svc.getCommonData(c, "about")
|
commonData := s.getCommonData(c, "about")
|
||||||
data := &renderer.AboutData{
|
data := &renderer.AboutData{
|
||||||
CommonData: commonData,
|
CommonData: commonData,
|
||||||
}
|
}
|
||||||
|
|
||||||
rCtx := getRendererContext(c)
|
rCtx := getRendererContext(c)
|
||||||
return svc.renderer.Render(rCtx, c.Writer, renderer.AboutPage, data)
|
return s.renderer.Render(rCtx, c, renderer.AboutPage, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) ServeEmojiPage(c *model.Client) (err error) {
|
func (s *service) EmojiPage(c *client) (err error) {
|
||||||
emojis, err := c.GetInstanceEmojis(ctx)
|
emojis, err := c.GetInstanceEmojis(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
commonData := s.getCommonData(c, "emojis")
|
||||||
commonData := svc.getCommonData(c, "emojis")
|
|
||||||
data := &renderer.EmojiData{
|
data := &renderer.EmojiData{
|
||||||
Emojis: emojis,
|
Emojis: emojis,
|
||||||
CommonData: commonData,
|
CommonData: commonData,
|
||||||
}
|
}
|
||||||
|
|
||||||
rCtx := getRendererContext(c)
|
rCtx := getRendererContext(c)
|
||||||
return svc.renderer.Render(rCtx, c.Writer, renderer.EmojiPage, data)
|
return s.renderer.Render(rCtx, c, renderer.EmojiPage, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) ServeSearchPage(c *model.Client,
|
func (s *service) SearchPage(c *client,
|
||||||
q string, qType string, offset int) (err error) {
|
q string, qType string, offset int) (err error) {
|
||||||
|
|
||||||
var nextLink string
|
var nextLink string
|
||||||
|
@ -674,7 +617,8 @@ func (svc *service) ServeSearchPage(c *model.Client,
|
||||||
if (qType == "accounts" && len(results.Accounts) == 20) ||
|
if (qType == "accounts" && len(results.Accounts) == 20) ||
|
||||||
(qType == "statuses" && len(results.Statuses) == 20) {
|
(qType == "statuses" && len(results.Statuses) == 20) {
|
||||||
offset += 20
|
offset += 20
|
||||||
nextLink = fmt.Sprintf("/search?q=%s&type=%s&offset=%d", url.QueryEscape(q), qType, offset)
|
nextLink = fmt.Sprintf("/search?q=%s&type=%s&offset=%d",
|
||||||
|
url.QueryEscape(q), qType, offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
qq := template.HTMLEscapeString(q)
|
qq := template.HTMLEscapeString(q)
|
||||||
|
@ -682,7 +626,7 @@ func (svc *service) ServeSearchPage(c *model.Client,
|
||||||
title += " \"" + qq + "\""
|
title += " \"" + qq + "\""
|
||||||
}
|
}
|
||||||
|
|
||||||
commonData := svc.getCommonData(c, title)
|
commonData := s.getCommonData(c, title)
|
||||||
data := &renderer.SearchData{
|
data := &renderer.SearchData{
|
||||||
CommonData: commonData,
|
CommonData: commonData,
|
||||||
Q: qq,
|
Q: qq,
|
||||||
|
@ -691,34 +635,30 @@ func (svc *service) ServeSearchPage(c *model.Client,
|
||||||
Statuses: results.Statuses,
|
Statuses: results.Statuses,
|
||||||
NextLink: nextLink,
|
NextLink: nextLink,
|
||||||
}
|
}
|
||||||
|
|
||||||
rCtx := getRendererContext(c)
|
rCtx := getRendererContext(c)
|
||||||
return svc.renderer.Render(rCtx, c.Writer, renderer.SearchPage, data)
|
return s.renderer.Render(rCtx, c, renderer.SearchPage, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) ServeSettingsPage(c *model.Client) (err error) {
|
func (s *service) SettingsPage(c *client) (err error) {
|
||||||
commonData := svc.getCommonData(c, "settings")
|
commonData := s.getCommonData(c, "settings")
|
||||||
data := &renderer.SettingsData{
|
data := &renderer.SettingsData{
|
||||||
CommonData: commonData,
|
CommonData: commonData,
|
||||||
Settings: &c.Session.Settings,
|
Settings: &c.Session.Settings,
|
||||||
PostFormats: svc.postFormats,
|
PostFormats: s.postFormats,
|
||||||
}
|
}
|
||||||
|
|
||||||
rCtx := getRendererContext(c)
|
rCtx := getRendererContext(c)
|
||||||
return svc.renderer.Render(rCtx, c.Writer, renderer.SettingsPage, data)
|
return s.renderer.Render(rCtx, c, renderer.SettingsPage, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) SingleInstance() (instance string, ok bool) {
|
func (s *service) SingleInstance() (instance string, ok bool) {
|
||||||
if len(svc.singleInstance) > 0 {
|
if len(s.singleInstance) > 0 {
|
||||||
instance = svc.singleInstance
|
instance = s.singleInstance
|
||||||
ok = true
|
ok = true
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) NewSession(instance string) (
|
func (s *service) NewSession(instance string) (rurl string, sid string, err error) {
|
||||||
redirectUrl string, sessionID string, err error) {
|
|
||||||
|
|
||||||
var instanceURL string
|
var instanceURL string
|
||||||
if strings.HasPrefix(instance, "https://") {
|
if strings.HasPrefix(instance, "https://") {
|
||||||
instanceURL = instance
|
instanceURL = instance
|
||||||
|
@ -727,53 +667,48 @@ func (svc *service) NewSession(instance string) (
|
||||||
instanceURL = "https://" + instance
|
instanceURL = "https://" + instance
|
||||||
}
|
}
|
||||||
|
|
||||||
sessionID, err = util.NewSessionID()
|
sid, err = util.NewSessionID()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
csrfToken, err := util.NewCSRFToken()
|
csrfToken, err := util.NewCSRFToken()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
session := model.Session{
|
session := model.Session{
|
||||||
ID: sessionID,
|
ID: sid,
|
||||||
InstanceDomain: instance,
|
InstanceDomain: instance,
|
||||||
CSRFToken: csrfToken,
|
CSRFToken: csrfToken,
|
||||||
Settings: *model.NewSettings(),
|
Settings: *model.NewSettings(),
|
||||||
}
|
}
|
||||||
|
err = s.sessionRepo.Add(session)
|
||||||
err = svc.sessionRepo.Add(session)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
app, err := svc.appRepo.Get(instance)
|
app, err := s.appRepo.Get(instance)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != model.ErrAppNotFound {
|
if err != model.ErrAppNotFound {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
mastoApp, err := mastodon.RegisterApp(ctx, &mastodon.AppConfig{
|
mastoApp, err := mastodon.RegisterApp(ctx, &mastodon.AppConfig{
|
||||||
Server: instanceURL,
|
Server: instanceURL,
|
||||||
ClientName: svc.clientName,
|
ClientName: s.clientName,
|
||||||
Scopes: svc.clientScope,
|
Scopes: s.clientScope,
|
||||||
Website: svc.clientWebsite,
|
Website: s.clientWebsite,
|
||||||
RedirectURIs: svc.clientWebsite + "/oauth_callback",
|
RedirectURIs: s.clientWebsite + "/oauth_callback",
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
app = model.App{
|
app = model.App{
|
||||||
InstanceDomain: instance,
|
InstanceDomain: instance,
|
||||||
InstanceURL: instanceURL,
|
InstanceURL: instanceURL,
|
||||||
ClientID: mastoApp.ClientID,
|
ClientID: mastoApp.ClientID,
|
||||||
ClientSecret: mastoApp.ClientSecret,
|
ClientSecret: mastoApp.ClientSecret,
|
||||||
}
|
}
|
||||||
|
err = s.appRepo.Add(app)
|
||||||
err = svc.appRepo.Add(app)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
@ -788,23 +723,21 @@ func (svc *service) NewSession(instance string) (
|
||||||
q.Set("scope", "read write follow")
|
q.Set("scope", "read write follow")
|
||||||
q.Set("client_id", app.ClientID)
|
q.Set("client_id", app.ClientID)
|
||||||
q.Set("response_type", "code")
|
q.Set("response_type", "code")
|
||||||
q.Set("redirect_uri", svc.clientWebsite+"/oauth_callback")
|
q.Set("redirect_uri", s.clientWebsite+"/oauth_callback")
|
||||||
u.RawQuery = q.Encode()
|
u.RawQuery = q.Encode()
|
||||||
|
|
||||||
redirectUrl = instanceURL + u.String()
|
rurl = instanceURL + u.String()
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) Signin(c *model.Client, sessionID string,
|
func (s *service) Signin(c *client, code string) (token string,
|
||||||
code string) (token string, userID string, err error) {
|
userID string, err error) {
|
||||||
|
|
||||||
if len(code) < 1 {
|
if len(code) < 1 {
|
||||||
err = errInvalidArgument
|
err = errInvalidArgument
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
err = c.AuthenticateToken(ctx, code, s.clientWebsite+"/oauth_callback")
|
||||||
err = c.AuthenticateToken(ctx, code, svc.clientWebsite+"/oauth_callback")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -815,17 +748,16 @@ func (svc *service) Signin(c *model.Client, sessionID string,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
userID = u.ID
|
userID = u.ID
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) Signout(c *model.Client) (err error) {
|
func (s *service) Signout(c *client) (err error) {
|
||||||
svc.sessionRepo.Remove(c.Session.ID)
|
s.sessionRepo.Remove(c.Session.ID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) Post(c *model.Client, content string,
|
func (s *service) Post(c *client, content string, replyToID string,
|
||||||
replyToID string, format string, visibility string, isNSFW bool,
|
format string, visibility string, isNSFW bool,
|
||||||
files []*multipart.FileHeader) (id string, err error) {
|
files []*multipart.FileHeader) (id string, err error) {
|
||||||
|
|
||||||
var mediaIDs []string
|
var mediaIDs []string
|
||||||
|
@ -845,136 +777,143 @@ func (svc *service) Post(c *model.Client, content string,
|
||||||
Visibility: visibility,
|
Visibility: visibility,
|
||||||
Sensitive: isNSFW,
|
Sensitive: isNSFW,
|
||||||
}
|
}
|
||||||
|
st, err := c.PostStatus(ctx, tweet)
|
||||||
s, err := c.PostStatus(ctx, tweet)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
return st.ID, nil
|
||||||
return s.ID, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) Like(c *model.Client, id string) (count int64, err error) {
|
func (s *service) Like(c *client, id string) (count int64, err error) {
|
||||||
s, err := c.Favourite(ctx, id)
|
st, err := c.Favourite(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
count = s.FavouritesCount
|
count = st.FavouritesCount
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) UnLike(c *model.Client, id string) (count int64, err error) {
|
func (s *service) UnLike(c *client, id string) (count int64, err error) {
|
||||||
s, err := c.Unfavourite(ctx, id)
|
st, err := c.Unfavourite(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
count = s.FavouritesCount
|
count = st.FavouritesCount
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) Retweet(c *model.Client, id string) (count int64, err error) {
|
func (s *service) Retweet(c *client, id string) (count int64, err error) {
|
||||||
s, err := c.Reblog(ctx, id)
|
st, err := c.Reblog(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if s.Reblog != nil {
|
if st.Reblog != nil {
|
||||||
count = s.Reblog.ReblogsCount
|
count = st.Reblog.ReblogsCount
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) UnRetweet(c *model.Client, id string) (
|
func (s *service) UnRetweet(c *client, id string) (
|
||||||
count int64, err error) {
|
count int64, err error) {
|
||||||
s, err := c.Unreblog(ctx, id)
|
st, err := c.Unreblog(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
count = s.ReblogsCount
|
count = st.ReblogsCount
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) Vote(c *model.Client, id string, choices []string) (err error) {
|
func (s *service) Vote(c *client, id string, choices []string) (err error) {
|
||||||
_, err = c.Vote(ctx, id, choices)
|
_, err = c.Vote(ctx, id, choices)
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) Follow(c *model.Client, id string, reblogs *bool) (err error) {
|
func (s *service) Follow(c *client, id string, reblogs *bool) (err error) {
|
||||||
_, err = c.AccountFollow(ctx, id, reblogs)
|
_, err = c.AccountFollow(ctx, id, reblogs)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) UnFollow(c *model.Client, id string) (err error) {
|
func (s *service) UnFollow(c *client, id string) (err error) {
|
||||||
_, err = c.AccountUnfollow(ctx, id)
|
_, err = c.AccountUnfollow(ctx, id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) Mute(c *model.Client, id string) (err error) {
|
func (s *service) Accept(c *client, id string) (err error) {
|
||||||
|
return c.FollowRequestAuthorize(ctx, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *service) Reject(c *client, id string) (err error) {
|
||||||
|
return c.FollowRequestReject(ctx, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *service) Mute(c *client, id string) (err error) {
|
||||||
_, err = c.AccountMute(ctx, id)
|
_, err = c.AccountMute(ctx, id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) UnMute(c *model.Client, id string) (err error) {
|
func (s *service) UnMute(c *client, id string) (err error) {
|
||||||
_, err = c.AccountUnmute(ctx, id)
|
_, err = c.AccountUnmute(ctx, id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) Block(c *model.Client, id string) (err error) {
|
func (s *service) Block(c *client, id string) (err error) {
|
||||||
_, err = c.AccountBlock(ctx, id)
|
_, err = c.AccountBlock(ctx, id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) UnBlock(c *model.Client, id string) (err error) {
|
func (s *service) UnBlock(c *client, id string) (err error) {
|
||||||
_, err = c.AccountUnblock(ctx, id)
|
_, err = c.AccountUnblock(ctx, id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) Subscribe(c *model.Client, id string) (err error) {
|
func (s *service) Subscribe(c *client, id string) (err error) {
|
||||||
_, err = c.Subscribe(ctx, id)
|
_, err = c.Subscribe(ctx, id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) UnSubscribe(c *model.Client, id string) (err error) {
|
func (s *service) UnSubscribe(c *client, id string) (err error) {
|
||||||
_, err = c.UnSubscribe(ctx, id)
|
_, err = c.UnSubscribe(ctx, id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) SaveSettings(c *model.Client, s *model.Settings) (err error) {
|
func (s *service) SaveSettings(c *client, settings *model.Settings) (err error) {
|
||||||
session, err := svc.sessionRepo.Get(c.Session.ID)
|
switch settings.NotificationInterval {
|
||||||
|
case 0, 30, 60, 120, 300, 600:
|
||||||
|
default:
|
||||||
|
return errInvalidArgument
|
||||||
|
}
|
||||||
|
session, err := s.sessionRepo.Get(c.Session.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
session.Settings = *settings
|
||||||
session.Settings = *s
|
return s.sessionRepo.Add(session)
|
||||||
return svc.sessionRepo.Add(session)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) MuteConversation(c *model.Client, id string) (err error) {
|
func (s *service) MuteConversation(c *client, id string) (err error) {
|
||||||
_, err = c.MuteConversation(ctx, id)
|
_, err = c.MuteConversation(ctx, id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) UnMuteConversation(c *model.Client, id string) (err error) {
|
func (s *service) UnMuteConversation(c *client, id string) (err error) {
|
||||||
_, err = c.UnmuteConversation(ctx, id)
|
_, err = c.UnmuteConversation(ctx, id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) Delete(c *model.Client, id string) (err error) {
|
func (s *service) Delete(c *client, id string) (err error) {
|
||||||
return c.DeleteStatus(ctx, id)
|
return c.DeleteStatus(ctx, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) ReadNotifications(c *model.Client, maxID string) (err error) {
|
func (s *service) ReadNotifications(c *client, maxID string) (err error) {
|
||||||
return c.ReadNotifications(ctx, maxID)
|
return c.ReadNotifications(ctx, maxID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) Bookmark(c *model.Client, id string) (err error) {
|
func (s *service) Bookmark(c *client, id string) (err error) {
|
||||||
_, err = c.Bookmark(ctx, id)
|
_, err = c.Bookmark(ctx, id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svc *service) UnBookmark(c *model.Client, id string) (err error) {
|
func (s *service) UnBookmark(c *client, id string) (err error) {
|
||||||
_, err = c.Unbookmark(ctx, id)
|
_, err = c.Unbookmark(ctx, id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
1086
service/transport.go
1086
service/transport.go
File diff suppressed because it is too large
Load Diff
|
@ -136,6 +136,11 @@ function isInView(el) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function replyToLinkLocal(a) {
|
function replyToLinkLocal(a) {
|
||||||
|
if (!a)
|
||||||
|
return;
|
||||||
|
var id = a.getAttribute("href");
|
||||||
|
if (!id || id[0] != "#")
|
||||||
|
return;
|
||||||
a.onmouseenter = function(event) {
|
a.onmouseenter = function(event) {
|
||||||
var id = event.target.getAttribute("href");
|
var id = event.target.getAttribute("href");
|
||||||
var status = document.querySelector(id);
|
var status = document.querySelector(id);
|
||||||
|
@ -260,8 +265,9 @@ function handleReplyLink(a) {
|
||||||
|
|
||||||
function handleStatusLink(a) {
|
function handleStatusLink(a) {
|
||||||
if (a.classList.contains("mention"))
|
if (a.classList.contains("mention"))
|
||||||
return;
|
a.removeAttribute("target");
|
||||||
a.target = "_blank";
|
else
|
||||||
|
a.target = "_blank";
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
|
@ -292,6 +298,11 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||||
handleStatusLink(links[j]);
|
handleStatusLink(links[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var links = document.querySelectorAll(".user-profile-decription a");
|
||||||
|
for (var j = 0; j < links.length; j++) {
|
||||||
|
links[j].target = "_blank";
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
|
body {
|
||||||
|
background-color: #d2d2d2;
|
||||||
|
}
|
||||||
|
|
||||||
.status-container-container {
|
.status-container-container {
|
||||||
margin: 0 -4px 12px -4px;
|
margin: 0 -4px 12px -4px;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
border-left: 4px solid transparent;
|
border-left: 4px solid transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-container-container:target,
|
.status-container-container:target {
|
||||||
.status-container-container.unread {
|
|
||||||
border-color: #777777;
|
border-color: #777777;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,6 +176,21 @@
|
||||||
font-size: 13pt;
|
font-size: 13pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.notification-container {
|
||||||
|
margin: 0 -4px 12px -4px;
|
||||||
|
padding: 4px;
|
||||||
|
border-left: 4px solid transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-container.unread {
|
||||||
|
border-color: #777777;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-container.favourite .status-container,
|
||||||
|
.notification-container.reblog .status-container {
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
.notification-info-text span {
|
.notification-info-text span {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +249,7 @@
|
||||||
|
|
||||||
.user-profile-img-container {
|
.user-profile-img-container {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin: 0 4px 0 0;
|
margin: 0 4px 4px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-profile-details-container {
|
.user-profile-details-container {
|
||||||
|
@ -281,7 +299,7 @@ a, .btn-link {
|
||||||
|
|
||||||
a:hover,
|
a:hover,
|
||||||
.btn-link:hover {
|
.btn-link:hover {
|
||||||
color: #9899c4;
|
color: #8387bf;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-visibility {
|
.status-visibility {
|
||||||
|
@ -312,7 +330,6 @@ a:hover,
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
margin-bottom: 5px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.img-link:hover .status-nsfw-overlay {
|
.img-link:hover .status-nsfw-overlay {
|
||||||
|
@ -322,7 +339,7 @@ a:hover,
|
||||||
.status-video-container {
|
.status-video-container {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
position: relative;
|
position: relative;
|
||||||
margin: 2.5px 0;
|
margin-bottom: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-video-container:hover .status-nsfw-overlay {
|
.status-video-container:hover .status-nsfw-overlay {
|
||||||
|
@ -423,7 +440,7 @@ img.emoji {
|
||||||
margin: 4px 0;
|
margin: 4px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.settings-form-field * {
|
.settings-form-field>* {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,7 +450,7 @@ img.emoji {
|
||||||
|
|
||||||
#reply-popup {
|
#reply-popup {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background: #ffffff;
|
background-color: #d2d2d2;
|
||||||
border: 1px solid #aaaaaa;
|
border: 1px solid #aaaaaa;
|
||||||
padding: 4px 8px;
|
padding: 4px 8px;
|
||||||
z-index: 3;
|
z-index: 3;
|
||||||
|
@ -442,7 +459,7 @@ img.emoji {
|
||||||
|
|
||||||
#reply-to-popup {
|
#reply-to-popup {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background: #ffffff;
|
background-color: #d2d2d2;
|
||||||
border: 1px solid #aaaaaa;
|
border: 1px solid #aaaaaa;
|
||||||
padding: 4px 8px;
|
padding: 4px 8px;
|
||||||
z-index: 3;
|
z-index: 3;
|
||||||
|
@ -462,7 +479,7 @@ img.emoji {
|
||||||
.more-content {
|
.more-content {
|
||||||
display: none;
|
display: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background-color: #ffffff;
|
background-color: #d2d2d2;
|
||||||
padding: 2px 4px;
|
padding: 2px 4px;
|
||||||
border: 1px solid #aaaaaa;
|
border: 1px solid #aaaaaa;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
{{if $.Ctx.AntiDopamineMode}}
|
{{if $.Ctx.AntiDopamineMode}}
|
||||||
<meta name="antidopamine_mode" content="{{$.Ctx.AntiDopamineMode}}">
|
<meta name="antidopamine_mode" content="{{$.Ctx.AntiDopamineMode}}">
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if .AutoRefresh}}
|
{{if .RefreshInterval}}
|
||||||
<meta http-equiv="refresh" content="30">
|
<meta http-equiv="refresh" content="{{.RefreshInterval}}">
|
||||||
{{end}}
|
{{end}}
|
||||||
<title> {{if gt .Count 0}}({{.Count}}){{end}} {{.Title}} </title>
|
<title> {{if gt .Count 0}}({{.Count}}){{end}} {{.Title}} </title>
|
||||||
<link rel="stylesheet" href="/static/style.css">
|
<link rel="stylesheet" href="/static/style.css">
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="user-info-details-container">
|
<div class="user-info-details-container">
|
||||||
<div class="user-info-details-name">
|
<div class="user-info-details-name">
|
||||||
<span class="status-dname"> {{EmojiFilter .User.DisplayName .User.Emojis}} </span>
|
<bdi class="status-dname"> {{EmojiFilter .User.DisplayName .User.Emojis}} </bdi>
|
||||||
<a class="nav-link" href="/user/{{.User.ID}}" accesskey="0" title="User profile (0)">
|
<a class="nav-link" href="/user/{{.User.ID}}" accesskey="0" title="User profile (0)">
|
||||||
<span class="status-uname"> @{{.User.Acct}} </span>
|
<span class="status-uname"> @{{.User.Acct}} </span>
|
||||||
</a>
|
</a>
|
||||||
|
@ -17,16 +17,18 @@
|
||||||
<a class="nav-link" href="/timeline/home" accesskey="1" title="Home timeline (1)">home</a>
|
<a class="nav-link" href="/timeline/home" accesskey="1" title="Home timeline (1)">home</a>
|
||||||
<a class="nav-link" href="/timeline/direct" accesskey="2" title="Direct timeline (2)">direct</a>
|
<a class="nav-link" href="/timeline/direct" accesskey="2" title="Direct timeline (2)">direct</a>
|
||||||
<a class="nav-link" href="/timeline/local" accesskey="3" title="Local timeline (3)">local</a>
|
<a class="nav-link" href="/timeline/local" accesskey="3" title="Local timeline (3)">local</a>
|
||||||
<a class="nav-link" href="/timeline/twkn" accesskey="4" title="The Whole Known Netwwork (4)">twkn</a>
|
<a class="nav-link" href="/timeline/remote" accesskey="4" title="Remote timeline (4)">remote</a>
|
||||||
<a class="nav-link" href="/search" accesskey="5" title="Search (5)">search</a>
|
<a class="nav-link" href="/timeline/twkn" accesskey="5" title="The Whole Known Netwwork (5)">twkn</a>
|
||||||
<a class="nav-link" href="/about" accesskey="6" title="About (6)">about</a>
|
<a class="nav-link" href="/search" accesskey="6" title="Search (6)">search</a>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<a class="nav-link" href="/settings" target="_top" accesskey="7" title="Settings (7)">settings</a>
|
<a class="nav-link" href="/settings" target="_top" accesskey="7" title="Settings (7)">settings</a>
|
||||||
<form class="signout" action="/signout" method="post" target="_top">
|
<form class="signout" action="/signout" method="post" target="_top">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="submit" value="signout" class="btn-link nav-link" accesskey="8" title="Signout (8)">
|
<input type="submit" value="signout" class="btn-link nav-link" accesskey="8" title="Signout (8)">
|
||||||
</form>
|
</form>
|
||||||
|
<a class="nav-link" href="/about" accesskey="9" title="About (9)">about</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -11,13 +11,14 @@
|
||||||
{{if .ReadID}}
|
{{if .ReadID}}
|
||||||
<form class="notification-read" action="/notifications/read?max_id={{.ReadID}}" method="post" target="_self">
|
<form class="notification-read" action="/notifications/read?max_id={{.ReadID}}" method="post" target="_self">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="submit" value="read" class="btn-link" accesskey="C" title="Clear unread notifications (C)">
|
<input type="submit" value="read" class="btn-link" accesskey="C" title="Clear unread notifications (C)">
|
||||||
</form>
|
</form>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{range .Notifications}}
|
{{range .Notifications}}
|
||||||
<div class="status-container-container {{if .Pleroma}}{{if not .Pleroma.IsSeen}}unread{{end}}{{end}}">
|
<div class="notification-container {{.Type}} {{if .Pleroma}}{{if not .Pleroma.IsSeen}}unread{{end}}{{end}}">
|
||||||
{{if eq .Type "follow"}}
|
{{if eq .Type "follow"}}
|
||||||
<div class="notification-follow-container">
|
<div class="notification-follow-container">
|
||||||
<div class="status-profile-img-container">
|
<div class="status-profile-img-container">
|
||||||
|
@ -27,7 +28,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="notification-follow">
|
<div class="notification-follow">
|
||||||
<div class="notification-info-text">
|
<div class="notification-info-text">
|
||||||
<span class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </span>
|
<bdi class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </bdi>
|
||||||
<span class="notification-text"> followed you -
|
<span class="notification-text"> followed you -
|
||||||
<time datetime="{{FormatTimeRFC3339 .CreatedAt}}" title="{{FormatTimeRFC822 .CreatedAt}}">{{TimeSince .CreatedAt}}</time>
|
<time datetime="{{FormatTimeRFC3339 .CreatedAt}}" title="{{FormatTimeRFC822 .CreatedAt}}">{{TimeSince .CreatedAt}}</time>
|
||||||
</span>
|
</span>
|
||||||
|
@ -38,6 +39,37 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{else if eq .Type "follow_request"}}
|
||||||
|
<div class="notification-follow-container">
|
||||||
|
<div class="status-profile-img-container">
|
||||||
|
<a class="img-link" href="/user/{{.Account.ID}}">
|
||||||
|
<img class="status-profile-img" src="{{.Account.AvatarStatic}}" title="@{{.Account.Acct}}" alt="profile-avatar" height="48" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="notification-follow">
|
||||||
|
<div class="notification-info-text">
|
||||||
|
<bdi class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </bdi>
|
||||||
|
<span class="notification-text"> wants to follow you -
|
||||||
|
<time datetime="{{FormatTimeRFC3339 .CreatedAt}}" title="{{FormatTimeRFC822 .CreatedAt}}">{{TimeSince .CreatedAt}}</time>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<a href="/user/{{.Account.ID}}"> <span class="status-uname"> @{{.Account.Acct}} </span> </a>
|
||||||
|
</div>
|
||||||
|
<form class="d-inline" action="/accept/{{.Account.ID}}" method="post" target="_self">
|
||||||
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
|
<input type="submit" value="accept" class="btn-link">
|
||||||
|
</form>
|
||||||
|
-
|
||||||
|
<form class="d-inline" action="/reject/{{.Account.ID}}" method="post" target="_self">
|
||||||
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
|
<input type="submit" value="reject" class="btn-link">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{{else if eq .Type "mention"}}
|
{{else if eq .Type "mention"}}
|
||||||
{{template "status" (WithContext .Status $.Ctx)}}
|
{{template "status" (WithContext .Status $.Ctx)}}
|
||||||
|
|
||||||
|
@ -68,6 +100,20 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{{template "status" (WithContext .Status $.Ctx)}}
|
{{template "status" (WithContext .Status $.Ctx)}}
|
||||||
|
|
||||||
|
{{else}}
|
||||||
|
<div class="retweet-info">
|
||||||
|
<a class="img-link" href="/user/{{.Account.ID}}">
|
||||||
|
<img class="status-profile-img" src="{{.Account.AvatarStatic}}" title="@{{.Account.Acct}}" alt="avatar" height="48" />
|
||||||
|
</a>
|
||||||
|
<a href="/user/{{.Account.ID}}">
|
||||||
|
<span class="status-uname"> @{{.Account.Acct}} </span>
|
||||||
|
</a>
|
||||||
|
<span class="notification-text"> {{.Type}} -
|
||||||
|
<time datetime="{{FormatTimeRFC3339 .CreatedAt}}" title="{{FormatTimeRFC822 .CreatedAt}}">{{TimeSince .CreatedAt}}</time>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{{if .Status}}{{template "status" (WithContext .Status $.Ctx)}}{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{{with .Data}}
|
{{with .Data}}
|
||||||
<form class="post-form" action="/post" method="POST" enctype="multipart/form-data" target="_self">
|
<form class="post-form" action="/post" method="POST" enctype="multipart/form-data" target="_self">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
{{if .ReplyContext}}
|
{{if .ReplyContext}}
|
||||||
<input type="hidden" name="reply_to_id" value="{{.ReplyContext.InReplyToID}}" />
|
<input type="hidden" name="reply_to_id" value="{{.ReplyContext.InReplyToID}}" />
|
||||||
<label for="post-content" class="post-form-title"> Reply to {{.ReplyContext.InReplyToName}} </label>
|
<label for="post-content" class="post-form-title"> Reply to {{.ReplyContext.InReplyToName}} </label>
|
||||||
|
@ -43,6 +44,7 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" accesskey="P" title="Post (P)"> Post </button>
|
<button type="submit" accesskey="P" title="Post (P)"> Post </button>
|
||||||
|
<button type="reset" title="Reset"> Reset </button>
|
||||||
</form>
|
</form>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
{{with .Data}}
|
||||||
|
<div>
|
||||||
|
{{range .}}
|
||||||
|
<div class="user-list-item">
|
||||||
|
<div class="user-list-profile-img">
|
||||||
|
<a class="img-link" href="/user/{{.ID}}">
|
||||||
|
<img class="status-profile-img" src="{{.AvatarStatic}}" title="@{{.Acct}}" alt="avatar" height="48" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="user-list-name">
|
||||||
|
<div>
|
||||||
|
<div class="status-dname"> {{EmojiFilter .DisplayName .Emojis}} </div>
|
||||||
|
<a class="img-link" href="/user/{{.ID}}">
|
||||||
|
<div class="status-uname"> @{{.Acct}} </div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<form class="d-inline" action="/accept/{{.ID}}" method="post" target="_self">
|
||||||
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
|
<input type="submit" value="accept" class="btn-link">
|
||||||
|
</form>
|
||||||
|
-
|
||||||
|
<form class="d-inline" action="/reject/{{.ID}}" method="post" target="_self">
|
||||||
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
|
<input type="submit" value="reject" class="btn-link">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
|
<div class="no-data-found">No data found</div>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
|
<div class="no-data-found">No data found</div>
|
||||||
|
{{end}}
|
|
@ -6,7 +6,7 @@
|
||||||
<link rel="icon" type="image/png" href="/static/favicon.png">
|
<link rel="icon" type="image/png" href="/static/favicon.png">
|
||||||
<title>{{.Title}}</title>
|
<title>{{.Title}}</title>
|
||||||
</head>
|
</head>
|
||||||
<frameset cols="420px,*">
|
<frameset cols="424px,*">
|
||||||
<frameset rows="316px,*">
|
<frameset rows="316px,*">
|
||||||
<frame name="nav" src="/nav">
|
<frame name="nav" src="/nav">
|
||||||
<frame name="notification" src="/notifications">
|
<frame name="notification" src="/notifications">
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
<form id="settings-form" action="/settings" method="POST">
|
<form id="settings-form" action="/settings" method="POST">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<div class="settings-form-field">
|
<div class="settings-form-field">
|
||||||
<label for="visibility"> Default format </label>
|
<label for="visibility"> Default format </label>
|
||||||
{{$defFormat := .Settings.DefaultFormat}}
|
{{$defFormat := .Settings.DefaultFormat}}
|
||||||
|
@ -22,6 +23,17 @@
|
||||||
<option value="direct" {{if eq .Settings.DefaultVisibility "direct"}}selected{{end}}>Direct</option>
|
<option value="direct" {{if eq .Settings.DefaultVisibility "direct"}}selected{{end}}>Direct</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="settings-form-field">
|
||||||
|
<label for="notification-interval"> Refresh Notifications </label>
|
||||||
|
<select id="notification-interval" name="notification_interval">
|
||||||
|
<option value="0" {{if eq .Settings.NotificationInterval 0}}selected{{end}}>Disabled</option>
|
||||||
|
<option value="30" {{if eq .Settings.NotificationInterval 30}}selected{{end}}>After 30s</option>
|
||||||
|
<option value="60" {{if eq .Settings.NotificationInterval 60}}selected{{end}}>After 1m</option>
|
||||||
|
<option value="120" {{if eq .Settings.NotificationInterval 120}}selected{{end}}>After 2m</option>
|
||||||
|
<option value="300" {{if eq .Settings.NotificationInterval 300}}selected{{end}}>After 5m</option>
|
||||||
|
<option value="600" {{if eq .Settings.NotificationInterval 600}}selected{{end}}>After 10m</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div class="settings-form-field">
|
<div class="settings-form-field">
|
||||||
<input id="copy-scope" name="copy_scope" type="checkbox" value="true" {{if .Settings.CopyScope}}checked{{end}}>
|
<input id="copy-scope" name="copy_scope" type="checkbox" value="true" {{if .Settings.CopyScope}}checked{{end}}>
|
||||||
<label for="copy-scope"> Copy scope when replying </label>
|
<label for="copy-scope"> Copy scope when replying </label>
|
||||||
|
@ -38,10 +50,6 @@
|
||||||
<input id="mask-nsfw" name="mask_nsfw" type="checkbox" value="true" {{if .Settings.MaskNSFW}}checked{{end}}>
|
<input id="mask-nsfw" name="mask_nsfw" type="checkbox" value="true" {{if .Settings.MaskNSFW}}checked{{end}}>
|
||||||
<label for="mask-nsfw"> Mask NSFW attachments </label>
|
<label for="mask-nsfw"> Mask NSFW attachments </label>
|
||||||
</div>
|
</div>
|
||||||
<div class="settings-form-field">
|
|
||||||
<input id="auto-refresh-notifications" name="auto_refresh_notifications" type="checkbox" value="true" {{if .Settings.AutoRefreshNotifications}}checked{{end}}>
|
|
||||||
<label for="auto-refresh-notifications"> Auto refresh notifications </label>
|
|
||||||
</div>
|
|
||||||
<div class="settings-form-field">
|
<div class="settings-form-field">
|
||||||
<input id="fluoride-mode" name="fluoride_mode" type="checkbox" value="true" {{if .Settings.FluorideMode}}checked{{end}}>
|
<input id="fluoride-mode" name="fluoride_mode" type="checkbox" value="true" {{if .Settings.FluorideMode}}checked{{end}}>
|
||||||
<label for="fluoride-mode"> Enable <abbr title="Enable JavaScript based functionality, e.g., like/retweet without page reload and reply preview on thread page">fluoride mode</abbr> </label>
|
<label for="fluoride-mode"> Enable <abbr title="Enable JavaScript based functionality, e.g., like/retweet without page reload and reply preview on thread page">fluoride mode</abbr> </label>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<a class="img-link" href="/user/{{.Account.ID}}">
|
<a class="img-link" href="/user/{{.Account.ID}}">
|
||||||
<img class="status-profile-img" src="{{.Account.AvatarStatic}}" title="@{{.Account.Acct}}" alt="avatar" height="24" />
|
<img class="status-profile-img" src="{{.Account.AvatarStatic}}" title="@{{.Account.Acct}}" alt="avatar" height="24" />
|
||||||
</a>
|
</a>
|
||||||
<span class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </span>
|
<bdi class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </bdi>
|
||||||
<a href="/user/{{.Account.ID}}">
|
<a href="/user/{{.Account.ID}}">
|
||||||
<span class="status-uname"> @{{.Account.Acct}} </span>
|
<span class="status-uname"> @{{.Account.Acct}} </span>
|
||||||
</a>
|
</a>
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="status">
|
<div class="status">
|
||||||
<div class="status-name">
|
<div class="status-name">
|
||||||
<span class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </span>
|
<bdi class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </bdi>
|
||||||
<a href="/user/{{.Account.ID}}">
|
<a href="/user/{{.Account.ID}}">
|
||||||
<span class="status-uname"> @{{.Account.Acct}} </span>
|
<span class="status-uname"> @{{.Account.Acct}} </span>
|
||||||
</a>
|
</a>
|
||||||
|
@ -38,23 +38,27 @@
|
||||||
{{if .Muted}}
|
{{if .Muted}}
|
||||||
<form action="/unmuteconv/{{.ID}}" method="post" target="_self">
|
<form action="/unmuteconv/{{.ID}}" method="post" target="_self">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="submit" value="unmute" class="btn-link more-link">
|
<input type="submit" value="unmute" class="btn-link more-link">
|
||||||
</form>
|
</form>
|
||||||
{{else}}
|
{{else}}
|
||||||
<form action="/muteconv/{{.ID}}" method="post" target="_self">
|
<form action="/muteconv/{{.ID}}" method="post" target="_self">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="submit" value="mute" class="btn-link more-link">
|
<input type="submit" value="mute" class="btn-link more-link">
|
||||||
</form>
|
</form>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if .Bookmarked}}
|
{{if .Bookmarked}}
|
||||||
<form action="/unbookmark/{{.ID}}" method="post" target="_self">
|
<form action="/unbookmark/{{.ID}}" method="post" target="_self">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}">
|
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}">
|
||||||
<input type="submit" value="unbookmark" class="btn-link more-link">
|
<input type="submit" value="unbookmark" class="btn-link more-link">
|
||||||
</form>
|
</form>
|
||||||
{{else}}
|
{{else}}
|
||||||
<form action="/bookmark/{{.ID}}" method="post" target="_self">
|
<form action="/bookmark/{{.ID}}" method="post" target="_self">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}">
|
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}">
|
||||||
<input type="submit" value="bookmark" class="btn-link more-link">
|
<input type="submit" value="bookmark" class="btn-link more-link">
|
||||||
</form>
|
</form>
|
||||||
|
@ -62,6 +66,7 @@
|
||||||
{{if eq $.Ctx.UserID .Account.ID}}
|
{{if eq $.Ctx.UserID .Account.ID}}
|
||||||
<form action="/delete/{{.ID}}" method="post" target="_self">
|
<form action="/delete/{{.ID}}" method="post" target="_self">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="submit" value="delete" class="btn-link more-link">
|
<input type="submit" value="delete" class="btn-link more-link">
|
||||||
</form>
|
</form>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -91,7 +96,9 @@
|
||||||
|
|
||||||
{{if eq .Type "image"}}
|
{{if eq .Type "image"}}
|
||||||
{{if $.Ctx.HideAttachments}}
|
{{if $.Ctx.HideAttachments}}
|
||||||
<a href="{{.URL}}" target="_blank" title="{{.Description}}"> [image] </a>
|
<a href="{{.URL}}" target="_blank">
|
||||||
|
{{if .Description}}[{{.Description}}]{{else}}[image]{{end}}
|
||||||
|
</a>
|
||||||
{{else}}
|
{{else}}
|
||||||
<a class="img-link" href="{{.URL}}" target="_blank" title="{{.Description}}">
|
<a class="img-link" href="{{.URL}}" target="_blank" title="{{.Description}}">
|
||||||
<img class="status-image" src="{{.URL}}" alt="status-image" height="240" />
|
<img class="status-image" src="{{.URL}}" alt="status-image" height="240" />
|
||||||
|
@ -103,7 +110,9 @@
|
||||||
|
|
||||||
{{else if eq .Type "audio"}}
|
{{else if eq .Type "audio"}}
|
||||||
{{if $.Ctx.HideAttachments}}
|
{{if $.Ctx.HideAttachments}}
|
||||||
<a href="{{.URL}}" target="_blank" title="{{.Description}}"> [audio] </a>
|
<a href="{{.URL}}" target="_blank">
|
||||||
|
{{if .Description}}[{{.Description}}]{{else}}[audio]{{end}}
|
||||||
|
</a>
|
||||||
{{else}}
|
{{else}}
|
||||||
<audio class="status-audio" controls title="{{.Description}}">
|
<audio class="status-audio" controls title="{{.Description}}">
|
||||||
<source src="{{.URL}}">
|
<source src="{{.URL}}">
|
||||||
|
@ -113,7 +122,9 @@
|
||||||
|
|
||||||
{{else if eq .Type "video"}}
|
{{else if eq .Type "video"}}
|
||||||
{{if $.Ctx.HideAttachments}}
|
{{if $.Ctx.HideAttachments}}
|
||||||
<a href="{{.URL}}" target="_blank" title="{{.Description}}"> [video] </a>
|
<a href="{{.URL}}" target="_blank">
|
||||||
|
{{if .Description}}[{{.Description}}]{{else}}[video]{{end}}
|
||||||
|
</a>
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="status-video-container" title="{{.Description}}">
|
<div class="status-video-container" title="{{.Description}}">
|
||||||
<video class="status-video" controls height="240">
|
<video class="status-video" controls height="240">
|
||||||
|
@ -127,7 +138,9 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{else}}
|
{{else}}
|
||||||
<a href="{{.URL}}" target="_blank" title="{{.Description}}"> [attachment] </a>
|
<a href="{{.URL}}" target="_blank">
|
||||||
|
{{if .Description}}[{{.Description}}]{{else}}[attachment]{{end}}
|
||||||
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
@ -135,16 +148,17 @@
|
||||||
{{if .Poll}}
|
{{if .Poll}}
|
||||||
<form class="poll-form" action="/vote/{{.Poll.ID}}" method="POST" target="_self">
|
<form class="poll-form" action="/vote/{{.Poll.ID}}" method="POST" target="_self">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="hidden" name="status_id" value="{{$s.ID}}">
|
<input type="hidden" name="status_id" value="{{$s.ID}}">
|
||||||
{{range $i, $o := .Poll.Options}}
|
{{range $i, $o := .Poll.Options}}
|
||||||
<div class="poll-option">
|
<div class="poll-option">
|
||||||
{{if (or $s.Poll.Expired $s.Poll.Voted)}}
|
{{if (or $s.Poll.Expired $s.Poll.Voted)}}
|
||||||
<div> {{$o.Title}} - {{$o.VotesCount}} votes </div>
|
<div> {{EmojiFilter $o.Title $s.Emojis}} - {{$o.VotesCount}} votes </div>
|
||||||
{{else}}
|
{{else}}
|
||||||
<input type="{{if $s.Poll.Multiple}}checkbox{{else}}radio{{end}}" name="choices"
|
<input type="{{if $s.Poll.Multiple}}checkbox{{else}}radio{{end}}" name="choices"
|
||||||
id="poll-{{$s.ID}}-{{$i}}" value="{{$i}}">
|
id="poll-{{$s.ID}}-{{$i}}" value="{{$i}}">
|
||||||
<label for="poll-{{$s.ID}}-{{$i}}">
|
<label for="poll-{{$s.ID}}-{{$i}}">
|
||||||
{{$o.Title}}
|
{{EmojiFilter $o.Title $s.Emojis}}
|
||||||
</label>
|
</label>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
@ -187,6 +201,7 @@
|
||||||
{{$rt := "retweet"}} {{if .Reblogged}} {{$rt = "unretweet"}} {{end}}
|
{{$rt := "retweet"}} {{if .Reblogged}} {{$rt = "unretweet"}} {{end}}
|
||||||
<form class="status-retweet" data-action="{{$rt}}" action="/{{$rt}}/{{.ID}}" method="post" target="_self">
|
<form class="status-retweet" data-action="{{$rt}}" action="/{{$rt}}/{{.ID}}" method="post" target="_self">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}">
|
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}">
|
||||||
<input type="submit" value="{{$rt}}" class="btn-link">
|
<input type="submit" value="{{$rt}}" class="btn-link">
|
||||||
<a class="status-retweet-count" href="/retweetedby/{{.ID}}" title="click to see the the list">
|
<a class="status-retweet-count" href="/retweetedby/{{.ID}}" title="click to see the the list">
|
||||||
|
@ -201,6 +216,7 @@
|
||||||
{{$like := "like"}} {{if .Favourited}} {{$like = "unlike"}} {{end}}
|
{{$like := "like"}} {{if .Favourited}} {{$like = "unlike"}} {{end}}
|
||||||
<form class="status-like" data-action="{{$like}}" action="/{{$like}}/{{.ID}}" method="post" target="_self">
|
<form class="status-like" data-action="{{$like}}" action="/{{$like}}/{{.ID}}" method="post" target="_self">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}">
|
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}">
|
||||||
<input type="submit" value="{{$like}}" class="btn-link">
|
<input type="submit" value="{{$like}}" class="btn-link">
|
||||||
<a class="status-like-count" href="/likedby/{{.ID}}" title="click to see the the list">
|
<a class="status-like-count" href="/likedby/{{.ID}}" title="click to see the the list">
|
||||||
|
|
|
@ -2,6 +2,16 @@
|
||||||
{{template "header.tmpl" (WithContext .CommonData $.Ctx)}}
|
{{template "header.tmpl" (WithContext .CommonData $.Ctx)}}
|
||||||
<div class="page-title"> {{.Title}} </div>
|
<div class="page-title"> {{.Title}} </div>
|
||||||
|
|
||||||
|
{{if eq .Type "remote"}}
|
||||||
|
<form class="search-form" action="/timeline/remote" method="GET">
|
||||||
|
<span class="post-form-field">
|
||||||
|
<label for="instance"> Instance </label>
|
||||||
|
<input id="instance" name="instance" value="{{.Instance}}">
|
||||||
|
</span>
|
||||||
|
<button type="submit"> Submit </button>
|
||||||
|
</form>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
{{range .Statuses}}
|
{{range .Statuses}}
|
||||||
{{template "status.tmpl" (WithContext . $.Ctx)}}
|
{{template "status.tmpl" (WithContext . $.Ctx)}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="user-profile-details-container">
|
<div class="user-profile-details-container">
|
||||||
<div>
|
<div>
|
||||||
<span class="status-dname"> {{EmojiFilter .User.DisplayName .User.Emojis}} </span>
|
<bdi class="status-dname"> {{EmojiFilter .User.DisplayName .User.Emojis}} </bdi>
|
||||||
<span class="status-uname"> @{{.User.Acct}} </span>
|
<span class="status-uname"> @{{.User.Acct}} </span>
|
||||||
<a class="remote-link" href="{{.User.URL}}" target="_blank" title="remote profile">
|
<a class="remote-link" href="{{.User.URL}}" target="_blank" title="remote profile">
|
||||||
source
|
source
|
||||||
|
@ -23,11 +23,13 @@
|
||||||
{{if .User.Pleroma.Relationship.Following}}
|
{{if .User.Pleroma.Relationship.Following}}
|
||||||
<form class="d-inline" action="/unfollow/{{.User.ID}}" method="post">
|
<form class="d-inline" action="/unfollow/{{.User.ID}}" method="post">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="submit" value="unfollow" class="btn-link">
|
<input type="submit" value="unfollow" class="btn-link">
|
||||||
</form>
|
</form>
|
||||||
{{else}}
|
{{else}}
|
||||||
<form class="d-inline" action="/follow/{{.User.ID}}" method="post">
|
<form class="d-inline" action="/follow/{{.User.ID}}" method="post">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="submit" value="{{if .User.Pleroma.Relationship.Requested}}resend request{{else}}follow{{end}}" class="btn-link">
|
<input type="submit" value="{{if .User.Pleroma.Relationship.Requested}}resend request{{else}}follow{{end}}" class="btn-link">
|
||||||
</form>
|
</form>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -35,6 +37,7 @@
|
||||||
-
|
-
|
||||||
<form class="d-inline" action="/unfollow/{{.User.ID}}" method="post">
|
<form class="d-inline" action="/unfollow/{{.User.ID}}" method="post">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="submit" value="cancel request" class="btn-link">
|
<input type="submit" value="cancel request" class="btn-link">
|
||||||
</form>
|
</form>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -42,11 +45,13 @@
|
||||||
{{if .User.Pleroma.Relationship.Subscribing}}
|
{{if .User.Pleroma.Relationship.Subscribing}}
|
||||||
<form class="d-inline" action="/unsubscribe/{{.User.ID}}" method="post">
|
<form class="d-inline" action="/unsubscribe/{{.User.ID}}" method="post">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="submit" value="unsubscribe" class="btn-link">
|
<input type="submit" value="unsubscribe" class="btn-link">
|
||||||
</form>
|
</form>
|
||||||
{{else}}
|
{{else}}
|
||||||
<form class="d-inline" action="/subscribe/{{.User.ID}}" method="post">
|
<form class="d-inline" action="/subscribe/{{.User.ID}}" method="post">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="submit" value="subscribe" class="btn-link">
|
<input type="submit" value="subscribe" class="btn-link">
|
||||||
</form>
|
</form>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -55,11 +60,13 @@
|
||||||
{{if .User.Pleroma.Relationship.Blocking}}
|
{{if .User.Pleroma.Relationship.Blocking}}
|
||||||
<form class="d-inline" action="/unblock/{{.User.ID}}" method="post">
|
<form class="d-inline" action="/unblock/{{.User.ID}}" method="post">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="submit" value="unblock" class="btn-link">
|
<input type="submit" value="unblock" class="btn-link">
|
||||||
</form>
|
</form>
|
||||||
{{else}}
|
{{else}}
|
||||||
<form class="d-inline" action="/block/{{.User.ID}}" method="post">
|
<form class="d-inline" action="/block/{{.User.ID}}" method="post">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="submit" value="block" class="btn-link">
|
<input type="submit" value="block" class="btn-link">
|
||||||
</form>
|
</form>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -67,11 +74,13 @@
|
||||||
{{if .User.Pleroma.Relationship.Muting}}
|
{{if .User.Pleroma.Relationship.Muting}}
|
||||||
<form class="d-inline" action="/unmute/{{.User.ID}}" method="post">
|
<form class="d-inline" action="/unmute/{{.User.ID}}" method="post">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="submit" value="unmute" class="btn-link">
|
<input type="submit" value="unmute" class="btn-link">
|
||||||
</form>
|
</form>
|
||||||
{{else}}
|
{{else}}
|
||||||
<form class="d-inline" action="/mute/{{.User.ID}}" method="post">
|
<form class="d-inline" action="/mute/{{.User.ID}}" method="post">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="submit" value="mute" class="btn-link">
|
<input type="submit" value="mute" class="btn-link">
|
||||||
</form>
|
</form>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -80,11 +89,13 @@
|
||||||
{{if .User.Pleroma.Relationship.ShowingReblogs}}
|
{{if .User.Pleroma.Relationship.ShowingReblogs}}
|
||||||
<form class="d-inline" action="/follow/{{.User.ID}}?reblogs=false" method="post">
|
<form class="d-inline" action="/follow/{{.User.ID}}?reblogs=false" method="post">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="submit" value="hide retweets" class="btn-link">
|
<input type="submit" value="hide retweets" class="btn-link">
|
||||||
</form>
|
</form>
|
||||||
{{else}}
|
{{else}}
|
||||||
<form class="d-inline" action="/follow/{{.User.ID}}" method="post">
|
<form class="d-inline" action="/follow/{{.User.ID}}" method="post">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||||
<input type="submit" value="show retweets" class="btn-link">
|
<input type="submit" value="show retweets" class="btn-link">
|
||||||
</form>
|
</form>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -99,10 +110,11 @@
|
||||||
</div>
|
</div>
|
||||||
{{if .IsCurrent}}
|
{{if .IsCurrent}}
|
||||||
<div>
|
<div>
|
||||||
<a href="/user/{{.User.ID}}/bookmarks"> bookmarks </a> -
|
<a href="/user/{{.User.ID}}/bookmarks"> bookmarks </a>
|
||||||
<a href="/user/{{.User.ID}}/likes"> likes </a> -
|
- <a href="/user/{{.User.ID}}/likes"> likes </a>
|
||||||
<a href="/user/{{.User.ID}}/mutes"> mutes </a> -
|
- <a href="/user/{{.User.ID}}/mutes"> mutes </a>
|
||||||
<a href="/user/{{.User.ID}}/blocks"> blocks </a>
|
- <a href="/user/{{.User.ID}}/blocks"> blocks </a>
|
||||||
|
{{if .User.Locked}}- <a href="/user/{{.User.ID}}/requests"> requests </a>{{end}}
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
<div>
|
<div>
|
||||||
|
@ -162,6 +174,10 @@
|
||||||
{{else if eq .Type "blocks"}}
|
{{else if eq .Type "blocks"}}
|
||||||
<div class="page-title"> Blocks </div>
|
<div class="page-title"> Blocks </div>
|
||||||
{{template "userlist.tmpl" (WithContext .Users $.Ctx)}}
|
{{template "userlist.tmpl" (WithContext .Users $.Ctx)}}
|
||||||
|
|
||||||
|
{{else if eq .Type "requests"}}
|
||||||
|
<div class="page-title"> Follow requests </div>
|
||||||
|
{{template "requestlist.tmpl" (WithContext .Users $.Ctx)}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
<div class="pagination">
|
<div class="pagination">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package kv
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
Loading…
Reference in New Issue