-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
78 lines (71 loc) · 1.77 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
'use strict';
const os = require('os');
const path = require('path');
const Fanfou = require('./fanfou');
const action = async context => {
const filePath = await context.filePath();
let token = {};
if (context.config.get('useNofanConfig')) {
const user = require(path.join(os.homedir(), '.nofan/config')).USER;
const account = require(path.join(os.homedir(), '.nofan/account'))[user];
token = {
consumerKey: account.CONSUMER_KEY,
consumerSecret: account.CONSUMER_SECRET,
oauthToken: account.OAUTH_TOKEN,
oauthTokenSecret: account.OAUTH_TOKEN_SECRET
};
} else {
token = {
consumerKey: context.config.get('consumerKey'),
consumerSecret: context.config.get('consumerSecret'),
oauthToken: context.config.get('oauthToken'),
oauthTokenSecret: context.config.get('oauthTokenSecret')
};
}
context.setProgress('Uploading…');
const result = await Fanfou.upload(token, filePath);
context.notify(result);
};
const fanfou = {
title: 'Share to Fanfou',
formats: ['gif'],
action,
config: {
consumerKey: {
title: 'Consumer Key',
type: 'string',
minLength: 32,
description: 'Your consumer key',
required: true
},
consumerSecret: {
title: 'Consumer Secret',
type: 'string',
minLength: 32,
description: 'Your consumer secret',
required: true
},
oauthToken: {
title: 'OAuth Token',
type: 'string',
minLength: 32,
description: 'Your oauth token',
required: true
},
oauthTokenSecret: {
title: 'OAuth Token Secret',
type: 'string',
minLength: 32,
description: 'Your oauth token secret',
required: true
},
useNofanConfig: {
title: 'Use nofan config',
type: 'boolean',
default: false,
description: 'Use the local nofan config',
required: true
}
}
};
exports.shareServices = [fanfou];