-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support /api/v1/admin/domain_allows (#744)
* adding a new v4 andpoint allow-domain * adding a new v4 andpoint allow-domain - fixing some of implementations * change CreateDomainAllowParams to CreateDomainAllowParamss
- Loading branch information
1 parent
c59c6d7
commit dbdf59f
Showing
5 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export interface DomainAllow { | ||
/** The ID of the domain allow in the database. */ | ||
id: string; | ||
/** The domain of the domain allow in the database. */ | ||
domain: string; | ||
/** The create date of the domain allow in the database. */ | ||
createdAt: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export type { AccountRole, Account } from './account'; | ||
export type { Report } from './report'; | ||
export type { DomainBlock, DomainBlockSeverity } from './domain-block'; | ||
export type { DomainAllow } from './domain-allow'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import type { MastoConfig } from '../../config'; | ||
import { version } from '../../decorators'; | ||
import type { Admin } from '../../entities'; | ||
import type { Http } from '../../http'; | ||
import type { Repository } from '../repository'; | ||
|
||
export type FetchAllDomainAllowsParams = { | ||
readonly limit?: number; | ||
}; | ||
|
||
export interface CreateDomainAllowParams { | ||
readonly domain: string; | ||
} | ||
|
||
export class DomainAllowRepository | ||
implements | ||
Repository< | ||
Admin.DomainAllow, | ||
CreateDomainAllowParams, | ||
never, | ||
never, | ||
FetchAllDomainAllowsParams | ||
> | ||
{ | ||
constructor( | ||
private readonly http: Http, | ||
readonly version: string, | ||
readonly config: MastoConfig, | ||
) {} | ||
|
||
/** | ||
* Show information about all allowed domains | ||
* @param params Parameters | ||
* @return Array of DomainAllow | ||
* @see https://docs.joinmastodon.org/methods/admin/ | ||
*/ | ||
@version({ since: '4.0.0' }) | ||
fetchAll(params?: FetchAllDomainAllowsParams): Promise<Admin.DomainAllow[]> { | ||
return this.http.get('/api/v1/admin/domain_allows', params); | ||
} | ||
|
||
/** | ||
* Show information about a single allowed domain | ||
* @param id id of the domain | ||
* @return DomainAllow | ||
* @see https://docs.joinmastodon.org/methods/admin/ | ||
*/ | ||
@version({ since: '4.0.0' }) | ||
fetch(id: string): Promise<Admin.DomainAllow> { | ||
return this.http.get(`/api/v1/admin/domain_allows/${id}`); | ||
} | ||
|
||
/** | ||
* Add a domain to the list of domains allowed to federate, | ||
* to be used when the instance is in allow-list federation mode. | ||
* @param params parameters | ||
* @return DomainAllow | ||
* @see https://docs.joinmastodon.org/methods/admin/ | ||
*/ | ||
@version({ since: '4.0.0' }) | ||
create(params: CreateDomainAllowParams): Promise<Admin.DomainAllow> { | ||
return this.http.post('/api/v1/admin/domain_allows', params); | ||
} | ||
|
||
/** | ||
* Delete a domain from the allowed domains list. | ||
* @param id id of domain | ||
* @return DomainAllow | ||
* @see https://docs.joinmastodon.org/methods/admin/ | ||
*/ | ||
@version({ since: '4.0.0' }) | ||
remove(id: string): Promise<Admin.DomainAllow> { | ||
return this.http.delete(`/api/v1/admin/domain_allows/${id}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './report-repository'; | ||
export * from './account-repository'; | ||
export * from './domain-block-repository'; | ||
export * from './domain-allow-repository'; |