mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-10-01 01:05:53 -04:00
Add some documentation for custom stickers and support disabling them
This commit is contained in:
parent
147ef2104e
commit
0405d76ebf
@ -23,10 +23,10 @@ homeserver:
|
||||
# stickers. If not supplied or left empty Dimension will use the clientServerUrl.
|
||||
#mediaUrl: "https://t2bot.io"
|
||||
|
||||
# The access token Dimension should use for miscellaneous access to the homeserver. This
|
||||
# should be for a user on the configured homeserver: any user will do, however it is
|
||||
# recommended to use a dedicated user (such as @dimension:t2bot.io). For information on
|
||||
# how to acquire an access token, visit https://t2bot.io/docs/access_tokens
|
||||
# The access token Dimension should use for miscellaneous access to the homeserver, and
|
||||
# for tracking custom sticker pack updates. This should be a user configured on the homeserver
|
||||
# and be dedicated to Dimension (create a user named "dimension" on your homeserver). For
|
||||
# information on how to acquire an access token, visit https://t2bot.io/docs/access_tokens
|
||||
accessToken: "something"
|
||||
|
||||
# These users can modify the integrations this Dimension supports.
|
||||
@ -73,6 +73,19 @@ telegram:
|
||||
# Talk to @BotFather on Telegram to get a token
|
||||
botToken: "YourTokenHere"
|
||||
|
||||
# Custom sticker pack options.
|
||||
# Largely based on https://github.com/turt2live/matrix-sticker-manager
|
||||
stickers:
|
||||
# Whether or not to allow people to add custom sticker packs
|
||||
enabled: true
|
||||
|
||||
# The sticker manager bot to promote
|
||||
stickerBot: "@stickers:t2bot.io"
|
||||
|
||||
# The sticker manager URL to promote
|
||||
managerUrl: "https://stickers.t2bot.io"
|
||||
|
||||
|
||||
# Settings for controlling how logging works
|
||||
logging:
|
||||
file: logs/dimension.log
|
||||
|
41
docs/custom_stickerpacks.md
Normal file
41
docs/custom_stickerpacks.md
Normal file
@ -0,0 +1,41 @@
|
||||
## Custom Stickerpacks
|
||||
|
||||
Share stickers and customize your experience with custom sticker packs, supported by Dimension.
|
||||
|
||||
### Creating a sticker pack
|
||||
|
||||
1. Start a conversation with [@stickers:t2bot.io](https://matrix.to/#/@stickers:t2bot.io)
|
||||
2. Say `!stickers newpack` and follow the instructions.
|
||||
3. Share the URL with your friends.
|
||||
|
||||
### Adding custom sticker packs to your sticker picker
|
||||
|
||||
1. Make sure you're using Dimension as an integration manager.
|
||||
2. Open the sticker picker (smiley icon next to where you type messages).
|
||||
3. Click the Edit button in the top right.
|
||||
4. Paste the URL to the sticker pack you want to add into the box and click "Add Stickerpack".
|
||||
5. Close Dimension and start using the stickers.
|
||||
|
||||
### Admin/Operator guide: Enabling custom sticker packs / using your own sticker manager
|
||||
|
||||
In Dimension's configuration, make sure the following section exists:
|
||||
|
||||
```yaml
|
||||
# Custom sticker pack options.
|
||||
# Largely based on https://github.com/turt2live/matrix-sticker-manager
|
||||
stickers:
|
||||
# Whether or not to allow people to add custom sticker packs
|
||||
enabled: true
|
||||
|
||||
# The sticker manager bot to promote
|
||||
stickerBot: "@stickers:t2bot.io"
|
||||
|
||||
# The sticker manager URL to promote
|
||||
managerUrl: "https://stickers.t2bot.io"
|
||||
```
|
||||
|
||||
Provided the `enabled` flag is `true`, users will be able to add custom sticker packs to their pickers. Custom
|
||||
stickers may require federation to work, and so it suggested that non-federated or closed environments use a
|
||||
dedicated instance of [turt2live/matrix-sticker-manager](https://github.com/turt2live/matrix-sticker-manager) -
|
||||
the project which makes `@stickers:t2bot.io` work. The `stickerBot` should be whichever user account is used by
|
||||
the sticker manager, and the `managerUrl` should be the base URL of the manager.
|
@ -7,6 +7,7 @@ import UserStickerPack from "../../db/models/UserStickerPack";
|
||||
import { ApiError } from "../ApiError";
|
||||
import { StickerpackMetadataDownloader } from "../../utils/StickerpackMetadataDownloader";
|
||||
import { MatrixStickerBot } from "../../matrix/MatrixStickerBot";
|
||||
import config from "../../config";
|
||||
|
||||
export interface MemoryStickerPack {
|
||||
id: number;
|
||||
@ -52,6 +53,12 @@ interface ImportPackRequest {
|
||||
packUrl: string;
|
||||
}
|
||||
|
||||
interface StickerConfig {
|
||||
enabled: boolean;
|
||||
stickerBot: string;
|
||||
managerUrl: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* API for stickers
|
||||
*/
|
||||
@ -76,6 +83,18 @@ export class DimensionStickerService {
|
||||
return packs;
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("config")
|
||||
public async getConfig(@QueryParam("scalar_token") scalarToken: string): Promise<StickerConfig> {
|
||||
await ScalarService.getTokenOwner(scalarToken);
|
||||
|
||||
return {
|
||||
enabled: config.stickers.enabled,
|
||||
stickerBot: config.stickers.stickerBot,
|
||||
managerUrl: config.stickers.managerUrl,
|
||||
};
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("packs")
|
||||
public async getStickerPacks(@QueryParam("scalar_token") scalarToken: string): Promise<MemoryStickerPack[]> {
|
||||
@ -132,6 +151,10 @@ export class DimensionStickerService {
|
||||
public async importPack(@QueryParam("scalar_token") scalarToken: string, request: ImportPackRequest): Promise<MemoryUserStickerPack> {
|
||||
await ScalarService.getTokenOwner(scalarToken);
|
||||
|
||||
if (!config.stickers.enabled) {
|
||||
throw new ApiError(400, "Custom stickerpacks are disabled on this homeserver");
|
||||
}
|
||||
|
||||
const packUrl = request.packUrl.endsWith(".json") ? request.packUrl : `${request.packUrl}.json`;
|
||||
const metadata = await StickerpackMetadataDownloader.getMetadata(packUrl);
|
||||
await MatrixStickerBot.trackStickerpack(metadata.roomAlias);
|
||||
|
@ -27,6 +27,11 @@ export interface DimensionConfig {
|
||||
telegram: {
|
||||
botToken: string;
|
||||
};
|
||||
stickers: {
|
||||
enabled: boolean;
|
||||
stickerBot: string;
|
||||
managerUrl: string;
|
||||
};
|
||||
logging: LogConfig;
|
||||
}
|
||||
|
||||
|
@ -7,13 +7,14 @@
|
||||
<h5 style="text-align: center;">Sticker packs are not enabled on this Dimension instance.</h5>
|
||||
</div>
|
||||
</my-ibox>
|
||||
<my-ibox title="Add Sticker Packs" *ngIf="packs.length > 0">
|
||||
<my-ibox title="Add Sticker Packs" *ngIf="packs.length > 0 && customEnabled">
|
||||
<div class="my-ibox-content">
|
||||
<form (submit)="importPack()" novalidate name="importForm">
|
||||
<label class="label-block">
|
||||
Stickerpack URL
|
||||
<span class="text-muted">Start a conversation with {{stickerBot}} to create your own stickerpack.</span>
|
||||
<input type="text" class="form-control" name="packUrl"
|
||||
placeholder="https://packs.t2bot.io/pack/..."
|
||||
placeholder="{{managerUrl}}/pack/..."
|
||||
[(ngModel)]="packUrl" [disabled]="isImporting"/>
|
||||
</label>
|
||||
<div style="margin-top: 25px">
|
||||
|
@ -19,6 +19,9 @@ export class StickerpickerComponent implements OnInit {
|
||||
// Import stuff
|
||||
public packUrl = "";
|
||||
public isImporting = false;
|
||||
public customEnabled = false;
|
||||
public managerUrl: string;
|
||||
public stickerBot: string;
|
||||
|
||||
constructor(private stickerApi: StickerApiService,
|
||||
private media: MediaService,
|
||||
@ -37,6 +40,12 @@ export class StickerpickerComponent implements OnInit {
|
||||
console.error(e);
|
||||
this.toaster.pop("error", "Failed to load sticker packs");
|
||||
}
|
||||
|
||||
this.stickerApi.getConfig().then(config => {
|
||||
this.customEnabled = config.enabled;
|
||||
this.managerUrl = config.managerUrl;
|
||||
this.stickerBot = config.stickerBot;
|
||||
}).catch(err => console.error(err));
|
||||
}
|
||||
|
||||
public importPack() {
|
||||
|
@ -63,6 +63,12 @@ export interface FE_Sticker {
|
||||
};
|
||||
}
|
||||
|
||||
export interface FE_StickerConfig {
|
||||
enabled: boolean;
|
||||
stickerBot: string;
|
||||
managerUrl: string;
|
||||
}
|
||||
|
||||
export interface FE_Widget extends FE_Integration {
|
||||
options: any;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { Http } from "@angular/http";
|
||||
import { AuthedApi } from "../authed-api";
|
||||
import { FE_UserStickerPack } from "../../models/integration";
|
||||
import { FE_StickerConfig, FE_UserStickerPack } from "../../models/integration";
|
||||
|
||||
@Injectable()
|
||||
export class StickerApiService extends AuthedApi {
|
||||
@ -9,6 +9,10 @@ export class StickerApiService extends AuthedApi {
|
||||
super(http);
|
||||
}
|
||||
|
||||
public getConfig(): Promise<FE_StickerConfig> {
|
||||
return this.authedGet("/api/v1/dimension/stickers/config").map(r => r.json()).toPromise();
|
||||
}
|
||||
|
||||
public getPacks(): Promise<FE_UserStickerPack[]> {
|
||||
return this.authedGet("/api/v1/dimension/stickers/packs").map(r => r.json()).toPromise();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user