Compare commits
10 Commits
995717afb3
...
6992c64179
Author | SHA1 | Date | |
---|---|---|---|
6992c64179 | |||
![]() |
6d51f5ae61 | ||
![]() |
25692b6b92 | ||
![]() |
68198cd300 | ||
![]() |
3472e4d7c7 | ||
![]() |
be0dc39042 | ||
![]() |
33b8bcd180 | ||
![]() |
3cf77300b6 | ||
![]() |
fcd48a36a1 | ||
![]() |
a69ad24a45 |
135
docs/content/endpoints/badges.md
Normal file
135
docs/content/endpoints/badges.md
Normal file
@ -0,0 +1,135 @@
|
||||
---
|
||||
title: Badges
|
||||
anchor: badges-ep
|
||||
weight: 19
|
||||
---
|
||||
|
||||
### `/badge/new`
|
||||
|
||||
It should be noted that while alpha values are technically valid it is up to
|
||||
individual clients to decide what to do with that value. Personally I suggest not
|
||||
doing anything with the alpha value so that it doesn't matter but that is up to
|
||||
the client developer.
|
||||
|
||||
* Required query string parameters:
|
||||
|
||||
* badge\_name: String
|
||||
* Name to assign to the new badge
|
||||
* badge\_perms: u64
|
||||
* Permissions mask which apply to the badge
|
||||
|
||||
* Semi optional query string parameter:
|
||||
|
||||
* badge\_color: u32
|
||||
* If not included the color will default to `0xffffffff`
|
||||
|
||||
* Required permissions
|
||||
|
||||
* NEW\_BADGE
|
||||
|
||||
* Returns
|
||||
* A new [badge](#badges) behind the JSON key `badge`.
|
||||
|
||||
|
||||
### `/badge/delete`
|
||||
|
||||
* Required query string parameters:
|
||||
|
||||
* id: u64
|
||||
* ID of the target badge to delete
|
||||
|
||||
* Required permissions
|
||||
|
||||
* DELETE\_BADGE
|
||||
|
||||
* Returns
|
||||
|
||||
* HTTP 200 on success
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
> POST /badge/new
|
||||
|
||||
< {
|
||||
< "badge": {
|
||||
< "id": 1,
|
||||
< "name": "badge-name-here",
|
||||
< "color": 1234,
|
||||
< "perms": 1234,
|
||||
< }
|
||||
< }
|
||||
```
|
||||
|
||||
### `/badge/list`
|
||||
|
||||
* No query string required.
|
||||
|
||||
* No required permissions, only that the client have a valid JWT.
|
||||
|
||||
* Returns
|
||||
* Array of [Badges](#badges) behind the JSON key `badges`.
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
> GET /badge/list
|
||||
|
||||
< {
|
||||
< "badges": [
|
||||
< {
|
||||
< "id": 1,
|
||||
< "name": "badge-name-here",
|
||||
< "color": 1234,
|
||||
< "perms": 1234,
|
||||
< },
|
||||
< ...
|
||||
< ]
|
||||
< }
|
||||
```
|
||||
|
||||
### `/badge/update/color`
|
||||
|
||||
* Required query string parameters:
|
||||
|
||||
* badge\_id: u64
|
||||
* ID of the target badge to update.
|
||||
|
||||
* badge\_color: u32
|
||||
* The new color to update to
|
||||
|
||||
* Required permissions:
|
||||
|
||||
* UPDATE\_COLOR\_BADGE
|
||||
|
||||
* Returns:
|
||||
|
||||
* HTTP 200
|
||||
|
||||
### `/badge/update/name`
|
||||
|
||||
* Required query string parameters:
|
||||
|
||||
* badge\_id: u64
|
||||
* ID of the target badge toupdate.
|
||||
|
||||
* badge\_name: String
|
||||
* The new badge name to assign.
|
||||
|
||||
* Required permissions:
|
||||
|
||||
* UPDATE\_NAME\_BADGE
|
||||
|
||||
### `/badge/update/perms`
|
||||
|
||||
* Required query string parameters:
|
||||
|
||||
* badge\_id: u64
|
||||
* ID of the target badge toupdate.
|
||||
|
||||
* badge\_perms: u64
|
||||
* Represented as a regular integer this is the bitmap of permissions which apply to the badge
|
||||
|
||||
* Required permissions:
|
||||
|
||||
* UPDATE\_PERMS\_BADGE
|
@ -4,6 +4,40 @@ anchor: overview
|
||||
weight: 5
|
||||
---
|
||||
|
||||
For the source code refer to the official [Gitlab Repository](https://gitlab.com/shockrah/freechat/)
|
||||
_For the source code refer to the official [Gitlab repository here](https://gitlab.com/shockrah/freechat/)_.
|
||||
|
||||
## What is Freechat
|
||||
|
||||
A platform for free and open chatting.
|
||||
The code is free, the protocol is simple and its all for free, like free beer _and_ free as in freedom, now and always.
|
||||
|
||||
## Features
|
||||
|
||||
* Text channels - to keep discussion organized
|
||||
|
||||
* Simple invite system - just a simple invite link will do.
|
||||
|
||||
* Powerful configuration options
|
||||
|
||||
For server owners: Don't like a feature? Turn it off.
|
||||
For users: connections over TLS/TOR/SOCK5 or whatever other standard you want to use is allowed.
|
||||
|
||||
|
||||
## Upcoming Features
|
||||
|
||||
* **Voice channels** - Currently the only thing being waited on is catching up the official client to the REST API standard(like 1 week) if you're reading this.
|
||||
|
||||
* **Video channels** - This one is admittedly far off but will be coming after voice channels are done
|
||||
|
||||
## What Tech is Freechat built on?
|
||||
|
||||
Freechat and its standard is built on HTTP for the most part.
|
||||
Application message payloads are most typically found in the HTTP body as JSON data however, some HTTP endpoints do return any kind of JSON data as there is no real need to.
|
||||
For this reason developers should familiarize themselves with the standard to avoid errors.
|
||||
|
||||
There is also a Websocket portion to the standard which allows for real time communications such as voice chat and live chat updates.
|
||||
|
||||
## About this page
|
||||
|
||||
This page basically outlines what data is sent to and from each HTTP endpoint as well as what common patterns can be found in the standard.
|
||||
There is also section
|
||||
|
14
docs/content/structures/badges.md
Normal file
14
docs/content/structures/badges.md
Normal file
@ -0,0 +1,14 @@
|
||||
---
|
||||
title: Badges
|
||||
anchor: badges
|
||||
weight: 55
|
||||
---
|
||||
|
||||
|
||||
Name | Type
|
||||
:--------:|:-------:
|
||||
`name` | `String`
|
||||
`id` | `u64`
|
||||
`color` | `u32`
|
||||
`perms` | `u64`
|
||||
|
@ -13,6 +13,7 @@ Channels are made up of the following components
|
||||
name | `String`
|
||||
kind | `i32`
|
||||
description| `String`
|
||||
badge\_ids| `Array<u32>`
|
||||
|
||||
|
||||
Channels have two valid types or (more semantically) `kind` values:
|
||||
|
@ -9,7 +9,7 @@ weight: 40
|
||||
id | `u64`
|
||||
time | `i64`
|
||||
content | `String`
|
||||
type | `String`
|
||||
content_type | `String`
|
||||
author_id | `u64`
|
||||
channel_id | `u64`
|
||||
|
||||
|
@ -14,10 +14,11 @@ Name | Type
|
||||
secret | `String`
|
||||
status | `i32`
|
||||
permissions| `u64`
|
||||
badge\_ids | `Array<u32>`
|
||||
|
||||
### JWT
|
||||
|
||||
This data is retrieved after a sucessful `/login` hit.
|
||||
This data is retrieved after a successful `/login` hit.
|
||||
|
||||
Name | Type
|
||||
:-----:|:------:
|
||||
@ -31,6 +32,7 @@ This data is retrieved after a sucessful `/login` hit.
|
||||
name | `String`
|
||||
status | `i32`
|
||||
permissions| `u64`
|
||||
badge\_ids | `Array<u32>`
|
||||
|
||||
For users _without_ the `USER_FETCH` permission the only two fields with actual data is `id` and `name`. The other fields will be set to 0.
|
||||
|
||||
|
11
docs/readme.md
Normal file
11
docs/readme.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Freechat Wiki Source Code
|
||||
|
||||
This directory basically contains all the required code to build the wiki page
|
||||
which is found at https://freechat.shockrah.xyz
|
||||
|
||||
## Printing/PDF Format
|
||||
|
||||
While I don't provide a pdf format of the documentation at the moment the main
|
||||
API reference is somewhat printer friendly.
|
||||
If anyone wants to provide a script to provide the website in other formats
|
||||
it would be greatly appreciated.
|
17
freechat-client/package-lock.json
generated
17
freechat-client/package-lock.json
generated
@ -763,9 +763,9 @@
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
|
||||
},
|
||||
"normalize-url": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz",
|
||||
"integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ=="
|
||||
"version": "4.5.1",
|
||||
"resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.1.tgz",
|
||||
"integrity": "sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA=="
|
||||
},
|
||||
"npm-conf": {
|
||||
"version": "1.1.3",
|
||||
@ -989,6 +989,11 @@
|
||||
"integrity": "sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q==",
|
||||
"dev": true
|
||||
},
|
||||
"tslib": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
|
||||
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
|
||||
},
|
||||
"tunnel": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
|
||||
@ -1041,9 +1046,9 @@
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||
},
|
||||
"ws": {
|
||||
"version": "7.4.4",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.4.tgz",
|
||||
"integrity": "sha512-Qm8k8ojNQIMx7S+Zp8u/uHOx7Qazv3Yv4q68MiWWWOJhiwG5W3x7iqmRtJo8xxrciZUY4vRxUTJCKuRnF28ZZw=="
|
||||
"version": "7.5.5",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.5.tgz",
|
||||
"integrity": "sha512-BAkMFcAzl8as1G/hArkxOxq3G7pjUqQ3gzYbLL0/5zNkph70e+lCoxBGnm6AW1+/aiNeV4fnKqZ8m4GZewmH2w=="
|
||||
},
|
||||
"yallist": {
|
||||
"version": "4.0.0",
|
||||
|
@ -15,8 +15,9 @@
|
||||
"json-bigint": "^1.0.0",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"popper.js": "^1.16.1",
|
||||
"tslib": "^2.3.1",
|
||||
"typescript": "^4.2.3",
|
||||
"ws": "^7.4.4"
|
||||
"ws": "^7.5.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "^7.3.3"
|
||||
|
@ -1,4 +1,5 @@
|
||||
import * as EventEmitter from 'events'; // unused for now but maybe useful later
|
||||
import { EventEmitter } from 'events';
|
||||
//import * as EventEmitter from 'events'; // unused for now but maybe useful later
|
||||
import { ServerConfig, Message, Channel } from './types';
|
||||
import { Event } from './events';
|
||||
|
||||
@ -46,7 +47,7 @@ class ServerCache {
|
||||
export class Cache extends EventEmitter {
|
||||
// hostname -> Cache
|
||||
private servers: Map<String, ServerCache>
|
||||
public active_host: String
|
||||
public active_host: String|null
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
@ -61,7 +62,8 @@ export class Cache extends EventEmitter {
|
||||
}
|
||||
|
||||
update_channels(hostname: String, channels: Array<Channel>) : void {
|
||||
this.servers.get(hostname).channels = channels
|
||||
let ref = this.servers.get(hostname)
|
||||
if(ref != undefined) { ref.channels = channels }
|
||||
}
|
||||
|
||||
last_id(hostname: String, channel_id: BigInt) : BigInt|null {
|
||||
|
@ -1,14 +1,12 @@
|
||||
const { ArgumentParser } = require('argparse')
|
||||
const fs = require('fs').promises
|
||||
const syncFs = require('fs')
|
||||
|
||||
// required because freechat by default uses i64/u64 in json payloads
|
||||
// timestamps will get especially rekt'd if we don't parse things correctly
|
||||
const JSONBig = require('json-bigint')
|
||||
const JSONBig = require('json-bigint')({storeAsString: true})
|
||||
|
||||
class Config {
|
||||
/**
|
||||
*
|
||||
* TODO: change .data out for something not stupid
|
||||
* @param {String} path path to config on startup
|
||||
* @param {Object} data Contains actual config data
|
||||
*/
|
||||
@ -39,12 +37,13 @@ exports.from_cli_parser = function(parser) {
|
||||
let ret = new Config(path, {})
|
||||
|
||||
// Allow errors from here to bubble up instead of handling them
|
||||
|
||||
fs.readFile(path).then(file => {
|
||||
const json = JSONBig.parse(file)
|
||||
ret.data['servers'] = []
|
||||
|
||||
for(const key of Object.keys(json)) {
|
||||
ret.data[key] = json[key]
|
||||
// TODO: redo this so its let 'yolo'
|
||||
for(const serv of json['servers']) {
|
||||
ret.data['servers'].push(serv)
|
||||
}
|
||||
})
|
||||
.catch(err => console.error(err))
|
||||
@ -52,26 +51,3 @@ exports.from_cli_parser = function(parser) {
|
||||
return ret
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the config with the new object data
|
||||
* Called from node's main process
|
||||
*
|
||||
* @param {Config} config new config data to write
|
||||
* @param {String} path | set to 'default' if we're using $HOME/.config/freechat/config.json
|
||||
* Set this to anything else to write changes to that specified path
|
||||
*/
|
||||
exports.update_file = function(config, path='default') {
|
||||
if (path == 'default') {
|
||||
path = `${process.env.HOME || process.env.USERPROFILE}/.config/freechat/config.json`
|
||||
} else {
|
||||
path = path
|
||||
}
|
||||
|
||||
const data = JSON.stringify(config, null, 2)
|
||||
fs.writeFile(path, data, function(err) {
|
||||
if(err) { console.error(err) }
|
||||
else { console.log('fine') }
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,10 +54,4 @@ export class Event {
|
||||
|
||||
return new Message(mid, time, content, content_type, uid, uname, cid)
|
||||
}
|
||||
|
||||
// Sets up the inner channel data
|
||||
private _channel(obj: Object) : Channel|null {
|
||||
// todo: still require some testing to verify event data is appropriate
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
@ -61,15 +61,15 @@ export class ServerConfig {
|
||||
}
|
||||
|
||||
export class UserConfig {
|
||||
id: Number
|
||||
id: String
|
||||
jwt: String|null
|
||||
permissions: Number
|
||||
permissions: String
|
||||
secret: String
|
||||
|
||||
constructor(json: Object) {
|
||||
this.id = json['id']
|
||||
this.id = `${json['id']}`
|
||||
this.jwt = json['jwt']
|
||||
this.permissions = json['permissions']
|
||||
this.permissions = `${json['permissions']}`
|
||||
this.secret = json['secret']
|
||||
}
|
||||
}
|
||||
|
28
freechat-client/tsconfig.json
Normal file
28
freechat-client/tsconfig.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"rootDir": "./src/",
|
||||
"importHelpers": true,
|
||||
/* Strict Type-Checking Options */
|
||||
/* "strict": true, */
|
||||
/* "strictNullChecks": true, */
|
||||
"strictFunctionTypes": true,
|
||||
"noImplicitThis": true,
|
||||
/* "alwaysStrict": true, */
|
||||
|
||||
/* Additional Checks */
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
/*"noUncheckedIndexedAccess": true, */
|
||||
/*"noPropertyAccessFromIndexSignature": true, */
|
||||
|
||||
/* Module Resolution Options */
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true
|
||||
}
|
||||
}
|
@ -13,7 +13,12 @@ pub async fn listed(p: &Pool, id: u64, given_rng_value: &str) -> Result<bool> {
|
||||
|
||||
pub async fn insert(p: &Pool, id: u64, given_rng_value: &str) -> Result<()> {
|
||||
let mut conn = p.get_conn().await?;
|
||||
let q = "INSERT INTO jwt (id, rng) VALUES (:id, :rng)";
|
||||
conn.exec_drop(q, params!{"id" => id, "rng" => given_rng_value}).await?;
|
||||
let q = "INSERT INTO jwt (id, rng) VALUES(:id, :rng)
|
||||
ON DUPLICATE KEY UPDATE rng = :rng";
|
||||
let p = params!{
|
||||
"id" => id,
|
||||
"rng" => given_rng_value,
|
||||
};
|
||||
conn.exec_drop(q, p).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
BIN
misc/banner.png
Normal file
BIN
misc/banner.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 116 KiB |
BIN
misc/banner.xcf
Normal file
BIN
misc/banner.xcf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user