Sign inSign up

wizjin/chanify

By wizjin

Updated over 3 years ago

Chanify is a safe and simple notification tools.

Image
10

500K+

wizjin/chanify repository overview

Chanify

Docker iTunes App Store WebStore Workflow CodeQL Codecov Total alerts Go Report Card GitHub

English | 简体中文

Chanify is a safe and simple notification tools. For developers, system administrators, and everyone can push notifications with API.

Features

Chanify is include these features:

  • Customize channel for notifications.
  • Deploy your own node server.
  • Distributed architecture design.
  • Design for privacy protection.

Getting Started

  1. Install iOS App(1.0.0 version and above).
  2. Get send token, more detail.
  3. Send message.

Installation

$ docker pull wizjin/chanify:latest

Usage

As Sender Client

Use chanify to send message.

# Text message
$ docker run -it --rm wizjin/chanify:latest send --token=<token> --text=<message>

# Image message
$ docker run -it --rm wizjin/chanify:latest send --token=<token> --image=<image file path>

# URL message
$ docker run -it --rm wizjin/chanify:latest send --token=<token> --link=<web url>

# Action  message
$ docker run -it --rm wizjin/chanify:latest send --endpoint=http://<address>:<port> --token=<token> --text=<message> --title=<title> --action="<action name>|<action url>"
As Serverless node

Chanify run in stateless mode, no device token will be stored in node.

All device token will be stored in api.chanify.net.

Message will send to apple apns server by api.chanify.net.

Send message workflow:

Start => node server => api.chanify.net => Apple server => iOS client
$ docker run -it wizjin/chanify:latest serve --secret=<secret key> --name=<node name> --endpoint=http://<address>:<port>
As Serverful node

Chanify run in stateful mode, device token will be stored in node.

Message will send to apple apns server direct.

Send message workflow:

Start => node server => Apple server => iOS client

Start server

$ docker run -it -v /my/data:/root/.chanify wizjin/chanify:latest serve --name=<node name> --endpoint=http://<address>:<port>
Add New Node
  • Start node server
  • iOS client can scan QRCode(http://<address>:<port>/) to add node.
Send message
Command Line
# Text message
$ curl --form-string "text=hello" "http://<address>:<port>/v1/sender/<token>"

# Text file
$ cat message.txt | curl -H "Content-Type: text/plain" --data-binary @- "http://<address>:<port>/v1/sender/<token>"
Python 3
from urllib import request, parse

data = parse.urlencode({ 'text': 'hello' }).encode()
req = request.Request("http://<address>:<port>/v1/sender/<token>", data=data)
request.urlopen(req)
Ruby
require 'net/http'

uri = URI('http://<address>:<port>/v1/sender/<token>')
res = Net::HTTP.post_form(uri, 'text' => 'hello')
puts res.body
NodeJS
const https = require('https')
const querystring = require('querystring');

const data = querystring.stringify({ text: 'hello' })
const options = {
    hostname: '<address>:<port>',
    port: 80,
    path: '/v1/sender/<token>',
    method: 'POST',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Content-Length': data.length
        }
    }
    var req = https.request(options, (res) => {
    res.on('data', (d) => {
        process.stdout.write(d);
    });
});  
req.write(data);
req.end();
PHP
$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL           => 'http://<address>:<port>/v1/sender/<token>',
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS    => [ 'text' => 'hello' ],
]);

$response = curl_exec($curl);

curl_close($curl);
echo $response;

HTTP API

Send Text
  • GET
http://<address>:<port>/v1/sender/<token>/<message>
  • POST
http://<address>:<port>/v1/sender/<token>

Content-Type:

  • text/plain: Body is text message
  • multipart/form-data: The block of data("text") is text message
  • application/x-www-form-urlencoded: text=<url encoded text message>
  • application/json; charset=utf-8: The fields are optional
{
    "token": "<token>",
    "title": "<message title>",
    "text": "<text message content>",
    "copy": "<copy text for text message>",
    "autocopy": 1,
    "sound": 1,
    "priority": 10,
    "actions": [
        "ActionName1|http://<action host>/<action1>",
        "ActionName2|http://<action host>/<action2>",
    ]
}

Additional params

KeyDefaultDescription
titleNoneThe title for notification message.
copyNoneThe copy text for text notification.
autocopy0Enable autocopy text for text notification.
sound01 enable sound, otherwise disable sound.
priority1010 normal, 5 lower level.
actionsNoneActions list.

E.g.

http://<address>:<port>/v1/sender/<token>?sound=1&priority=10&title=hello
$ curl --form "link=@<web url>" "http://<address>:<port>/v1/sender/<token>"
{
    "link": "<web url>",
    "sound": 1,
    "priority": 10,
}
Send Image

Send image only support POST method used serverful node.

  • Content-Type: image/png OR image/jpeg
cat <jpeg image path> | curl -H "Content-Type: image/jpeg" --data-binary @- "http://<address>:<port>/v1/sender/<token>"
  • Content-Type: multipart/form-data
$ curl --form "image=@<jpeg image path>" "http://<address>:<port>/v1/sender/<token>"
Send Actions

Send Actions (Up to 4 actions).

  • Content-Type: multipart/form-data
$ curl --form "action=ActionName1|http://<action host>/<action1>" "http://<address>:<port>/v1/sender/<token>"

Configuration

Chanify can be configured with a yml format file, and the default path is /root/.chanify.yml.

$ docker run -it -v /my/config.yml:/root/.chanify.yml -v /my/data:/root/.chanify -p 8080:8080 wizjin/chanify:latest
server:
    host: 0.0.0.0   # Listen ip address
    port: 8080      # Listen port
    endpoint: http://my.server/path # Endpoint URL
    name: Node name # Name for node server
    secret: <secret code> # key for serverless node server
    datapath: <data path> # data storage path for serverful node server
    dburl: mysql://root:test@tcp(127.0.0.1:3306)/chanify?charset=utf8mb4&parseTime=true&loc=Local # database dsn for serverful node server
    register:
        enable: false # Disable user register
        whitelist: # whitelist for user register
            - <user id 1>
            - <user id 2>

client: # configuration for sender client
    sound: 1    # enable sound
    endpoint: <default node server endpoint>
    token: <default token>

Security

Node server can be disabled user registration and become a private server.

chanify serve --registerable=false --whitelist=<user1 id>,<user2 id>
  • --registerable=false: used to disable user registration
  • whitelist: list users can be add into node server

Chrome Extension

Download the extension for Chrome web store.

Extension features:

  • Send select text/image/url message to Chanify
  • Send page url to Chanify

License

Distributed under the MIT License. See LICENSE for more information.

Tag summary

Content type

Image

Digest

sha256:845fcf851

Size

17.5 MB

Last updated

over 3 years ago

docker pull wizjin/chanify