diff options
| author | 2022-09-23 21:27:35 +0200 | |
|---|---|---|
| committer | 2022-09-23 20:27:35 +0100 | |
| commit | 69a193dae543641a2db6823fa6493c02f56fafbd (patch) | |
| tree | c1a0c71d64642db12a17c6770642c3e0af859960 /internal/db/bundb | |
| parent | [docs] NLnet follow up questions (#846) (diff) | |
| download | gotosocial-69a193dae543641a2db6823fa6493c02f56fafbd.tar.xz | |
[feature] Allow delivery to sharedInboxes where possible (#847)
* update Activity
* add instance-deliver-to-shared-inboxes setting
* update activity version again
* add SharedInboxURI field to accounts
* serdes for endpoints/sharedInbox
* deliver to sharedInbox if one is available
* update tests
* only assign shared inbox if shared domain
* look for shared inbox if currently nil
* go fmt
* finger to get params.RemoteAccountID if necessary
* make comments clearer
* compare dns more consistently
Diffstat (limited to 'internal/db/bundb')
| -rw-r--r-- | internal/db/bundb/migrations/20220922142408_shared_inbox_delivery.go | 46 | 
1 files changed, 46 insertions, 0 deletions
| diff --git a/internal/db/bundb/migrations/20220922142408_shared_inbox_delivery.go b/internal/db/bundb/migrations/20220922142408_shared_inbox_delivery.go new file mode 100644 index 000000000..d0449af86 --- /dev/null +++ b/internal/db/bundb/migrations/20220922142408_shared_inbox_delivery.go @@ -0,0 +1,46 @@ +/* +   GoToSocial +   Copyright (C) 2021-2022 GoToSocial Authors admin@gotosocial.org + +   This program is free software: you can redistribute it and/or modify +   it under the terms of the GNU Affero General Public License as published by +   the Free Software Foundation, either version 3 of the License, or +   (at your option) any later version. + +   This program is distributed in the hope that it will be useful, +   but WITHOUT ANY WARRANTY; without even the implied warranty of +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +   GNU Affero General Public License for more details. + +   You should have received a copy of the GNU Affero General Public License +   along with this program.  If not, see <http://www.gnu.org/licenses/>. +*/ + +package migrations + +import ( +	"context" +	"strings" + +	"github.com/uptrace/bun" +) + +func init() { +	up := func(ctx context.Context, db *bun.DB) error { +		_, err := db.ExecContext(ctx, "ALTER TABLE ? ADD COLUMN ? TEXT", bun.Ident("accounts"), bun.Ident("shared_inbox_uri")) +		if err != nil && !(strings.Contains(err.Error(), "already exists") || strings.Contains(err.Error(), "duplicate column name") || strings.Contains(err.Error(), "SQLSTATE 42701")) { +			return err +		} +		return nil +	} + +	down := func(ctx context.Context, db *bun.DB) error { +		return db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error { +			return nil +		}) +	} + +	if err := Migrations.Register(up, down); err != nil { +		panic(err) +	} +} | 
