forked from swentel/indieweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindieweb.drush.inc
88 lines (81 loc) · 2.27 KB
/
indieweb.drush.inc
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
79
80
81
82
83
84
85
86
87
88
<?php
/**
* @file
* Drush legacy commands.
*/
/**
* Implements hook_drush_command().
*
* @return array
*/
function indieweb_drush_command() {
return [
'indieweb-send-webmentions' => [
'description' => 'Send webmentions',
'aliases' => ['isw'],
],
'indieweb-process-webmentions' => [
'description' => 'Process webmentions',
'aliases' => ['ipw'],
],
'indieweb-fetch-post-contexts' => [
'description' => 'Fetch post contexts',
'aliases' => ['ifpr'],
],
'indieweb-microsub-fetch-items' => [
'description' => 'Microsub fetch new items',
'aliases' => ['imfi'],
],
'indieweb-externalauth-map-account' => [
'description' => 'Maps an existing account with a domain.',
'aliases' => ['iema'],
'required-arguments' => 2,
'arguments' => [
'uid' => 'The uid of the account.',
'domain' => 'The domain to map.'
],
],
];
}
/**
* Send webmentions in queue.
*/
function drush_indieweb_send_webmentions() {
if (\Drupal::config('indieweb_webmention.settings')->get('send_webmention_handler') == 'drush') {
\Drupal::service('indieweb.webmention.client')->handleQueue();
}
}
/**
* Process webmentions.
*/
function drush_indieweb_process_webmentions() {
if (\Drupal::config('indieweb_webmention.settings')->get('webmention_internal_handler') == 'drush') {
\Drupal::service('indieweb.webmention.client')->processWebmentions();
}
}
/**
* Fetch post contexts in queue.
*/
function drush_indieweb_fetch_post_contexts() {
if (\Drupal::config('indieweb_context.settings')->get('handler') == 'drush') {
\Drupal::service('indieweb.post_context.client')->handleQueue();
}
}
/**
* Microsub fetch items.
*/
function drush_indieweb_microsub_fetch_items() {
if (\Drupal::config('indieweb_microsub.settings')->get('microsub_internal') &&
\Drupal::config('indieweb_microsub.settings')->get('microsub_internal_handler') == 'drush') {
\Drupal::service('indieweb.microsub.client')->fetchItems();
}
}
/**
* Maps a domain to an existing account.
*
* @param int $uid
* @param string $domain
*/
function drush_indieweb_externalauth_map_account($uid = 0, $domain = '') {
\Drupal::service('indieweb.indieauth.client')->externalauthMapAccount($uid, $domain, TRUE);
}