mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 09:22:25 -05:00 
			
		
		
		
	[feature] User muting (#2960)
* User muting * Address review feedback * Rename uniqueness constraint on user_mutes to match convention * Remove unused account_id from where clause * Add UserMute to NewTestDB * Update test/envparsing.sh with new and fixed cache stuff * Address tobi's review comments * Make compiledUserMuteListEntry.expired consistent with UserMute.Expired * Make sure mute_expires_at is serialized as an explicit null for indefinite mutes --------- Co-authored-by: tobi <tobi.smethurst@protonmail.com>
This commit is contained in:
		
					parent
					
						
							
								b371c2db47
							
						
					
				
			
			
				commit
				
					
						5e2d4fdb19
					
				
			
		
					 47 changed files with 2346 additions and 53 deletions
				
			
		
							
								
								
									
										98
									
								
								internal/api/client/accounts/unmute.go
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								internal/api/client/accounts/unmute.go
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,98 @@ | |||
| // GoToSocial | ||||
| // Copyright (C) GoToSocial Authors admin@gotosocial.org | ||||
| // SPDX-License-Identifier: AGPL-3.0-or-later | ||||
| // | ||||
| // 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 accounts | ||||
| 
 | ||||
| import ( | ||||
| 	"errors" | ||||
| 	"net/http" | ||||
| 
 | ||||
| 	"github.com/gin-gonic/gin" | ||||
| 	apiutil "github.com/superseriousbusiness/gotosocial/internal/api/util" | ||||
| 	"github.com/superseriousbusiness/gotosocial/internal/gtserror" | ||||
| 	"github.com/superseriousbusiness/gotosocial/internal/oauth" | ||||
| ) | ||||
| 
 | ||||
| // AccountUnmutePOSTHandler swagger:operation POST /api/v1/accounts/{id}/unmute accountUnmute | ||||
| // | ||||
| // Unmute account by ID. | ||||
| // | ||||
| // If account was already unmuted (or has never been muted), succeeds anyway. | ||||
| // | ||||
| //	--- | ||||
| //	tags: | ||||
| //	- accounts | ||||
| // | ||||
| //	produces: | ||||
| //	- application/json | ||||
| // | ||||
| //	parameters: | ||||
| //	- | ||||
| //		name: id | ||||
| //		type: string | ||||
| //		description: The ID of the account to unmute. | ||||
| //		in: path | ||||
| //		required: true | ||||
| // | ||||
| //	security: | ||||
| //	- OAuth2 Bearer: | ||||
| //		- write:mutes | ||||
| // | ||||
| //	responses: | ||||
| //		'200': | ||||
| //			name: account relationship | ||||
| //			description: Your relationship to this account. | ||||
| //			schema: | ||||
| //				"$ref": "#/definitions/accountRelationship" | ||||
| //		'400': | ||||
| //			description: bad request | ||||
| //		'401': | ||||
| //			description: unauthorized | ||||
| //		'404': | ||||
| //			description: not found | ||||
| //		'406': | ||||
| //			description: not acceptable | ||||
| //		'500': | ||||
| //			description: internal server error | ||||
| func (m *Module) AccountUnmutePOSTHandler(c *gin.Context) { | ||||
| 	authed, err := oauth.Authed(c, true, true, true, true) | ||||
| 	if err != nil { | ||||
| 		apiutil.ErrorHandler(c, gtserror.NewErrorUnauthorized(err, err.Error()), m.processor.InstanceGetV1) | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil { | ||||
| 		apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1) | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	targetAcctID := c.Param(IDKey) | ||||
| 	if targetAcctID == "" { | ||||
| 		err := errors.New("no account id specified") | ||||
| 		apiutil.ErrorHandler(c, gtserror.NewErrorBadRequest(err, err.Error()), m.processor.InstanceGetV1) | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	relationship, errWithCode := m.processor.Account().MuteRemove(c.Request.Context(), authed.Account, targetAcctID) | ||||
| 	if errWithCode != nil { | ||||
| 		apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1) | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	apiutil.JSON(c, http.StatusOK, relationship) | ||||
| 
 | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue