251 lines
6.6 KiB
Markdown
251 lines
6.6 KiB
Markdown
# Webhooks & Upload Service Configuration
|
|
|
|
This page explains all configuration options for Discord webhooks and media upload services in codem-phone.
|
|
|
|
---
|
|
|
|
## Discord Webhooks
|
|
|
|
Discord webhooks are used to log various activities to your Discord server channels.
|
|
|
|
```lua
|
|
Webhooks = {
|
|
selly = 'https://discord.com/api/webhooks/YOUR_WEBHOOK_ID/YOUR_WEBHOOK_TOKEN',
|
|
chater = 'https://discord.com/api/webhooks/YOUR_WEBHOOK_ID/YOUR_WEBHOOK_TOKEN',
|
|
media = 'https://discord.com/api/webhooks/YOUR_WEBHOOK_ID/YOUR_WEBHOOK_TOKEN'
|
|
}
|
|
```
|
|
|
|
| Webhook | Description |
|
|
|---------|-------------|
|
|
| `selly` | Logs marketplace listings and transactions from Selly app |
|
|
| `chater` | Logs chat messages and conversations |
|
|
| `media` | Logs uploaded media (photos, videos, audio) |
|
|
|
|
### How to Create a Discord Webhook
|
|
|
|
1. Go to your Discord server
|
|
2. Navigate to **Server Settings** → **Integrations** → **Webhooks**
|
|
3. Click **New Webhook**
|
|
4. Name your webhook and select the channel
|
|
5. Click **Copy Webhook URL**
|
|
6. Paste the URL in the config
|
|
|
|
---
|
|
|
|
## Upload Service
|
|
|
|
The upload service handles all media uploads (images, videos, audio) from the phone.
|
|
|
|
### Active Provider
|
|
|
|
```lua
|
|
UploadService = {
|
|
activeProvider = 'FivemanageNew',
|
|
presignedEndpoint = 'https://fmapi.net/api/v2/presigned-url',
|
|
apiKeys = {
|
|
audio = 'YOUR_AUDIO_API_KEY',
|
|
video = 'YOUR_VIDEO_API_KEY',
|
|
image = 'YOUR_IMAGE_API_KEY'
|
|
}
|
|
}
|
|
```
|
|
|
|
| Parameter | Type | Description |
|
|
|-----------|------|-------------|
|
|
| `activeProvider` | string | Selected upload provider |
|
|
| `presignedEndpoint` | string | Fivemanage presigned URL endpoint |
|
|
| `apiKeys` | table | API keys for each media type |
|
|
|
|
### Available Providers
|
|
|
|
| Provider | Description |
|
|
|----------|-------------|
|
|
| `FivemanageNew` | Fivemanage v2 with presigned URLs (Recommended) |
|
|
| `FivemanageLegacy` | Fivemanage legacy API |
|
|
| `CustomProvider` | Your own custom upload endpoint |
|
|
|
|
---
|
|
|
|
## Media Upload Providers
|
|
|
|
### Fivemanage New (Recommended)
|
|
|
|
The newest and most efficient method using presigned URLs.
|
|
|
|
```lua
|
|
FivemanageNew = {
|
|
All = {
|
|
endpoint = "PRESIGNED_URL",
|
|
formField = "file",
|
|
successResponse = {
|
|
key = "data.url"
|
|
},
|
|
includeMetadata = "metadata"
|
|
},
|
|
}
|
|
```
|
|
|
|
**Setup:**
|
|
1. Go to [fivemanage.com](https://fivemanage.com)
|
|
2. Create an account and get your API keys
|
|
3. Add your API keys to `UploadService.apiKeys`
|
|
|
|
---
|
|
|
|
### Fivemanage Legacy
|
|
|
|
The older Fivemanage API method with direct uploads.
|
|
|
|
```lua
|
|
FivemanageLegacy = {
|
|
VideoUpload = {
|
|
endpoint = "https://fmapi.net/api/v2/video",
|
|
formField = "file",
|
|
requestHeaders = {
|
|
["Authorization"] = "API_KEY"
|
|
},
|
|
successResponse = {
|
|
key = "data.url"
|
|
},
|
|
},
|
|
ImageUpload = {
|
|
endpoint = "https://fmapi.net/api/v2/image",
|
|
formField = "file",
|
|
requestHeaders = {
|
|
["Authorization"] = "API_KEY"
|
|
},
|
|
successResponse = {
|
|
key = "data.url"
|
|
}
|
|
},
|
|
AudioUpload = {
|
|
endpoint = "https://fmapi.net/api/v2/audio",
|
|
formField = "file",
|
|
requestHeaders = {
|
|
["Authorization"] = "API_KEY"
|
|
},
|
|
successResponse = {
|
|
key = "data.url"
|
|
}
|
|
},
|
|
}
|
|
```
|
|
|
|
| Media Type | Endpoint |
|
|
|------------|----------|
|
|
| Video | `https://fmapi.net/api/v2/video` |
|
|
| Image | `https://fmapi.net/api/v2/image` |
|
|
| Audio | `https://fmapi.net/api/v2/audio` |
|
|
|
|
---
|
|
|
|
### Custom Provider
|
|
|
|
Configure your own upload service with full customization.
|
|
|
|
```lua
|
|
CustomProvider = {
|
|
VideoUpload = {
|
|
endpoint = "https://your-api-endpoint.com/media/upload?key=API_KEY",
|
|
formField = "media",
|
|
requestHeaders = {
|
|
["Authorization"] = "Bearer API_KEY",
|
|
["Content-Type"] = "multipart/form-data"
|
|
},
|
|
errorResponse = {
|
|
key = "error",
|
|
errorValue = true
|
|
},
|
|
successResponse = {
|
|
key = "data.mediaUrl"
|
|
},
|
|
fileExtension = "webm",
|
|
},
|
|
ImageUpload = {
|
|
endpoint = "https://your-api-endpoint.com/media/upload?key=API_KEY",
|
|
formField = "media",
|
|
requestHeaders = {
|
|
["Authorization"] = "Bearer API_KEY",
|
|
["Content-Type"] = "multipart/form-data"
|
|
},
|
|
errorResponse = {
|
|
key = "error",
|
|
errorValue = true
|
|
},
|
|
successResponse = {
|
|
key = "data.mediaUrl"
|
|
},
|
|
fileExtension = "png",
|
|
},
|
|
AudioUpload = {
|
|
endpoint = "https://your-api-endpoint.com/media/upload?key=API_KEY",
|
|
formField = "media",
|
|
requestHeaders = {
|
|
["Authorization"] = "Bearer API_KEY",
|
|
["Content-Type"] = "multipart/form-data"
|
|
},
|
|
errorResponse = {
|
|
key = "error",
|
|
errorValue = true
|
|
},
|
|
successResponse = {
|
|
key = "data.mediaUrl"
|
|
},
|
|
fileExtension = "mp3",
|
|
},
|
|
}
|
|
```
|
|
|
|
### Custom Provider Parameters
|
|
|
|
| Parameter | Type | Description |
|
|
|-----------|------|-------------|
|
|
| `endpoint` | string | Your API upload endpoint URL |
|
|
| `formField` | string | Form field name for the file |
|
|
| `requestHeaders` | table | HTTP headers to send with request |
|
|
| `errorResponse.key` | string | JSON path to error indicator |
|
|
| `errorResponse.errorValue` | any | Value that indicates an error |
|
|
| `successResponse.key` | string | JSON path to the returned media URL |
|
|
| `fileExtension` | string | File extension for uploads |
|
|
|
|
### File Extensions by Media Type
|
|
|
|
| Media Type | Default Extension |
|
|
|------------|-------------------|
|
|
| Video | `webm` |
|
|
| Image | `png` |
|
|
| Audio | `mp3` |
|
|
|
|
---
|
|
|
|
## Switching Providers
|
|
|
|
To switch between providers, change the `activeProvider` value:
|
|
|
|
```lua
|
|
-- Use Fivemanage New (Recommended)
|
|
activeProvider = 'FivemanageNew'
|
|
|
|
-- Use Fivemanage Legacy
|
|
activeProvider = 'FivemanageLegacy'
|
|
|
|
-- Use Custom Provider
|
|
activeProvider = 'CustomProvider'
|
|
```
|
|
|
|
---
|
|
|
|
## Getting Fivemanage API Keys
|
|
|
|
1. Visit [fivemanage.com](https://fivemanage.com)
|
|
2. Create an account or log in
|
|
3. Navigate to **Dashboard** → **API Keys**
|
|
4. Generate separate keys for:
|
|
- Image uploads
|
|
- Video uploads
|
|
- Audio uploads
|
|
5. Copy each key to the corresponding field in `UploadService.apiKeys`
|
|
|
|
> **Note:** Keep your API keys private. Never share them publicly or commit them to public repositories.
|