mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-02 13:12:25 -06:00
[feature] Email notifications for new / closed moderation reports (#1628)
* start fiddling about with email sending to allow multiple recipients * do some fiddling * notifs working * notify on closed report * finishing up * envparsing * use strings.ContainsAny
This commit is contained in:
parent
9c55c07be9
commit
7db81cde44
35 changed files with 773 additions and 420 deletions
|
|
@ -24,6 +24,8 @@ import (
|
|||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/testrig"
|
||||
)
|
||||
|
||||
type InstanceTestSuite struct {
|
||||
|
|
@ -90,6 +92,42 @@ func (suite *InstanceTestSuite) TestGetInstanceAccounts() {
|
|||
suite.Len(accounts, 1)
|
||||
}
|
||||
|
||||
func (suite *InstanceTestSuite) TestGetInstanceModeratorAddressesOK() {
|
||||
// We have one admin user by default.
|
||||
addresses, err := suite.db.GetInstanceModeratorAddresses(context.Background())
|
||||
suite.NoError(err)
|
||||
suite.EqualValues([]string{"admin@example.org"}, addresses)
|
||||
}
|
||||
|
||||
func (suite *InstanceTestSuite) TestGetInstanceModeratorAddressesZorkAsModerator() {
|
||||
// Promote zork to moderator role.
|
||||
testUser := >smodel.User{}
|
||||
*testUser = *suite.testUsers["local_account_1"]
|
||||
testUser.Moderator = testrig.TrueBool()
|
||||
if err := suite.db.UpdateUser(context.Background(), testUser, "moderator"); err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
addresses, err := suite.db.GetInstanceModeratorAddresses(context.Background())
|
||||
suite.NoError(err)
|
||||
suite.EqualValues([]string{"admin@example.org", "zork@example.org"}, addresses)
|
||||
}
|
||||
|
||||
func (suite *InstanceTestSuite) TestGetInstanceModeratorAddressesNoAdmin() {
|
||||
// Demote admin from admin + moderator roles.
|
||||
testUser := >smodel.User{}
|
||||
*testUser = *suite.testUsers["admin_account"]
|
||||
testUser.Admin = testrig.FalseBool()
|
||||
testUser.Moderator = testrig.FalseBool()
|
||||
if err := suite.db.UpdateUser(context.Background(), testUser, "admin", "moderator"); err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
addresses, err := suite.db.GetInstanceModeratorAddresses(context.Background())
|
||||
suite.ErrorIs(err, db.ErrNoEntries)
|
||||
suite.Empty(addresses)
|
||||
}
|
||||
|
||||
func TestInstanceTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(InstanceTestSuite))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue