Compare commits

..

19 Commits
0.1.15 ... main

2 changed files with 182 additions and 155 deletions

View File

@ -1,5 +1,8 @@
# gnuboard5-activitypub
ActivityPub implementation for GNUBOARD 5
GNUBOARD5-ActivityPub: ActivityPub (Fediverse) implementation for GNUBOARD5
* https://sir.kr/g5_plugin/10381
* https://codeberg.org/fediverse/delightful-activitypub-development
## 사용 전 설정
* `apstreams` 게시판 추가
@ -13,12 +16,12 @@ ActivityPub implementation for GNUBOARD 5
- [x] Followers
- [x] Following
- [x] Liked
- [ ] Shares (개선 진행 중)
- [x] Geolocation (IP2Location, Naver Cloud)
- [ ] ~~Shares~~ (Altered to inbound/outbound)
- [x] Geolocation
- [x] File attachment
- [ ] File attachment - Automatically download a file to the local server
- [x] Digest/Signature
- [ ] Digest/Signature - Verification
- [ ] File attachment - Automatically download a remote file to the local server
- [x] Digest/Signature - Outbound
- [ ] ~~Digest/Signature - Inbound~~ (No required)
- [x] w3id.org (e.g. the `publicKey` field of an actor)
- [ ] OAuth 2.0
- [ ] Message Queue Compatible (e.g. Redis, RebbitMQ, Kafka)
@ -27,9 +30,10 @@ ActivityPub implementation for GNUBOARD 5
- [x] 아바타 (gravatar.com)
- [x] 날씨 (openweathermap.org)
- [x] 환율 (koreaexim.go.kr)
- [x] 국내 Geolocation (Naver Cloud)
- [x] 국외 Geolocation (IP2Location)
## 전문 예시
## 전문(메시지) 예시
```json
{
@ -119,6 +123,9 @@ ActivityPub implementation for GNUBOARD 5
* https://github.com/autogestion/pubgate-telegram
* https://docs.joinmastodon.org/spec/security/
* https://chat.openai.com/share/4fda7974-cc0b-439a-b0f2-dc828f8acfef
* https://codeberg.org/mro/activitypub/src/commit/4b1319d5363f4a836f23c784ef780b81bc674013/like.sh#L101
* https://socialhub.activitypub.rocks/t/problems-posting-to-mastodon-inbox/801/10
## 문의
* abuse@catswords.net
* ActivityPub [@gnh1201@catswords.social](https://catswords.social/@gnh1201)

View File

@ -1,11 +1,12 @@
<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
// ActivityPub implementation for GNUBOARD 5
// Go Namhyeon <abuse@catswords.net>
// MIT License
// 2023-07-26 (version 0.1.15)
// Description: ActivityPub implementation for GNUBOARD 5
// Author: Go Namhyeon (Catswords Research) <abuse@catswords.net>
// ActivityPub: @gnh1201@catswords.social
// License: MIT
// Date: 2023-08-08
// Version: 0.1.18
// References:
// * https://www.w3.org/TR/activitypub/
// * https://www.w3.org/TR/activitystreams-core/
@ -17,9 +18,12 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
// * https://github.com/broidHQ/integrations/tree/master/broid-schemas#readme
// * https://github.com/autogestion/pubgate-telegram
// * https://blog.joinmastodon.org/2018/06/how-to-implement-a-basic-activitypub-server/
// * https://chat.openai.com/share/4fda7974-cc0b-439a-b0f2-dc828f8acfef
// * https://codeberg.org/mro/activitypub/src/commit/4b1319d5363f4a836f23c784ef780b81bc674013/like.sh#L101
// * https://socialhub.activitypub.rocks/t/problems-posting-to-mastodon-inbox/801/10
define("ACTIVITYPUB_INSTANCE_ID", md5_file(G5_DATA_PATH . "/dbconfig.php"));
define("ACTIVITYPUB_INSTANCE_VERSION", "0.1.14-dev");
define("ACTIVITYPUB_INSTANCE_VERSION", "0.1.18");
define("ACTIVITYPUB_DEFAULT_SCHEME", "https"); // 외부 통신용 스킴 (SSL 사용이 기본)
define("ACTIVITYPUB_INSECURE_SCHEME", "http"); // 그누보드5 ActivityPub 통신용 스킴 (SSL 사용을 하지 않을 수도 있음을 고려)
define("ACTIVITYPUB_HOST", (empty(G5_DOMAIN) ? $_SERVER['HTTP_HOST'] : G5_DOMAIN));
@ -70,6 +74,17 @@ function activitypub_load_library($name, $callback) {
));
}
// ActivityPub 표준 문서에서는 단수형, 실제 어플리케이션에선 복수형으로 표현되는 것을 모두 대응함
function activitypub_cast_to_array($s) {
$d = array();
if (is_array($s)) {
$d = $s;
} else if (isset($s)) {
$d[] = $s;
}
return $d;
}
function activitypub_create_keypair() {
$keypair = array('', '');
@ -161,8 +176,8 @@ function activitypub_json_encode($arr) {
return json_encode($arr);
}
function activitypub_json_decode($arr) {
return json_decode($arr, true);
function activitypub_json_decode($str) {
return json_decode($str, true);
}
function activitypub_parse_stored_data($s) {
@ -337,7 +352,7 @@ function activitypub_build_http_headers($headers) {
function activitypub_build_datetime($s='now') {
// e.g. 18 Dec 2019 10:08:46 GMT
$format = "d M Y H:i:s e";
$format = "D, d M Y H:i:s e";
$dt = ($s == "now" ? new DateTime('now', new DateTimeZone("GMT")) : DateTime::createFromFormat($format, $s));
return $dt->format($format);
}
@ -349,7 +364,7 @@ function activitypub_build_digest($body) {
return $digest;
}
function activitypub_build_signature($url, $date, $digest, $mb, $method="POST") {
function activitypub_build_signature($url, $date, $digest, $mb, $method="post") {
// get a certificate
list($private_key, $public_key) = activitypub_get_stored_keypair($mb);
@ -361,13 +376,24 @@ function activitypub_build_signature($url, $date, $digest, $mb, $method="POST")
$keyId = $activitypub_user_id . "#main-key";
// build a target data to get signature
/*
$signature = $method . ' ' . $path . "\n" .
'HOST: ' . $host . "\n" .
'Date: ' . $date . "\n" .
'Digest: ' . $digest;
*/
// Ref: https://codeberg.org/mro/activitypub/src/commit/4b1319d5363f4a836f23c784ef780b81bc674013/like.sh#L101
$signature = sprintf(
"%s: %s\n%s: %s\n%s: %s\n%s: %s",
"(request-target)",
"{$method} {$path}",
"host", $host,
"date", $date,
"digest", $digest
);
// create a signature
openssl_sign($signature, $signature, $privateKey, OPENSSL_ALGO_SHA256);
openssl_sign($signature, $signature, $private_key, OPENSSL_ALGO_SHA256);
$signature = base64_encode($signature);
// create a signature header
@ -378,7 +404,7 @@ function activitypub_http_get($url, $access_token = '') {
// build the header
$headers = array(
"Date" => activitypub_build_datetime('now'),
"Accept" => "application/ld+json; profile=\"" . NAMESPACE_ACTIVITYSTREAMS . "\""
"Accept" => "application/activity+json; profile=\"" . NAMESPACE_ACTIVITYSTREAMS . "\""
);
// set access token
@ -419,20 +445,20 @@ function activitypub_get_attachments($bo_table, $wr_id) {
return $attachments;
}
function activitypub_http_post($url, $raw_data, $mb, $access_token = '') {
function activitypub_http_post($url, $rawdata, $mb, $access_token = '') {
// get digest
$date = activitypub_build_datetime('now');
$digest = activitypub_build_digest($raw_data);
$digest = activitypub_build_digest($rawdata);
// build the headers
$headers = array(
"Date" => $date,
"Digest" => $digest,
"Content-Type" => "application/ld+json; profile=\"" . NAMESPACE_ACTIVITYSTREAMS . "\"",
"Content-Type" => "application/activity+json; profile=\"" . NAMESPACE_ACTIVITYSTREAMS . "\"",
);
// build the signature
$signature = activitypub_build_signature($url, $date, $digest, $mb, "POST");
$signature = activitypub_build_signature($url, $date, $digest, $mb);
$headers["Signature"] = $signature;
// set access token
@ -448,12 +474,18 @@ function activitypub_http_post($url, $raw_data, $mb, $access_token = '') {
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $raw_data,
CURLOPT_POSTFIELDS => $rawdata,
CURLOPT_POST => true
));
$response = curl_exec($ch);
$errno = curl_errno($ch);
curl_close($ch);
// 전송 오류가 있었을 시 쪽지로 알림
if ($errno) {
activitypub_add_memo(ACTIVITYPUB_G5_USERNAME, $mb['mb_id'], "[경고] 메시지 전송 중 오류가 발생함. 오류 번호: " . $errno);
}
return activitypub_json_decode($response, true);
}
@ -549,6 +581,9 @@ function koreaexim_get_exchange_data() {
}
function activitypub_publish_content($content, $object_id, $mb, $_added_object = array(), $_added_to = array()) {
// 액티비티 관리용 계정의 글 전송 차단
if ($mb['mb_id'] == ACTIVITYPUB_G5_USERNAME) return;
// 위치정보를 사용하는 경우 모듈 로드
$location_ctx = array();
if (ACTIVITYPUB_ENABLED_GEOLOCATION) {
@ -636,7 +671,10 @@ function activitypub_publish_content($content, $object_id, $mb, $_added_object =
$terms = activitypub_parse_content($content);
// 수신자/내용 생성
$to = array_merge(array(NAMESPACE_ACTIVITYSTREAMS_PUBLIC), $_added_to);
$to = array_merge(activitypub_cast_to_array(NAMESPACE_ACTIVITYSTREAMS_PUBLIC), $_added_to);
$cc = array(); // 참조자
$tag = array(); // 태그
$endpoints = array();
$content = "";
foreach($terms as $term_ctx) {
switch ($term_ctx['type']) {
@ -666,14 +704,24 @@ function activitypub_publish_content($content, $object_id, $mb, $_added_object =
$counter--; // 시도 횟수 차감
}
// WebFinger 정보 수신을 못한 경우 아무 작업도 하지 않음
if ($counter < 0) break;
// WebFinger 정보 수신을 못한 경우, 쪽지로 알리고 아무 작업도 하지 않음
if (empty($webfigner_ctx['subject'])) {
activitypub_add_memo(ACTIVITYPUB_G5_USERNAME, $mb['mb_id'], "[발송실패] 수신자를 찾을 수 없음: @" . $account);
break;
}
// 받은 요청으로 처리
$webfigner_links = $webfigner_ctx['links'];
foreach($webfigner_links as $link) {
if ($link['rel'] == "self" && $link['type'] == "application/activity+json") {
array_push($to, $link['href']); // 수신자에 반영
// 태그 목록에 추가
array_push($tag, array(
"type" => "Mention",
"href" => $link['href'],
"name" => '@' . $account
));
array_push($cc, $link['href']); // 참조자 목록에 추가
array_push($endpoints, $link['href']); // 글을 전송할 엔드포인트(URL)에 반영
}
}
}
@ -687,48 +735,57 @@ function activitypub_publish_content($content, $object_id, $mb, $_added_object =
// 위치정보가 활성화되어 있으면
if (ACTIVITYPUB_ENABLED_GEOLOCATION) {
$object = array_merge($_added_object, array(
$_added_object = array_merge($_added_object, array(
"location" => $location_ctx
));
}
// 태그 추가
$_added_object = array_merge($_added_object, array(
"tag" => $tag
));
// 전문 생성
$object = activitypub_build_note($content, $object_id, $mb, $_added_object);
// 외부로 보낼 전문 생성
$data = array(
"@context" => NAMESPACE_ACTIVITYSTREAMS,
"@context" => activitypub_cast_to_array(NAMESPACE_ACTIVITYSTREAMS),
"type" => "Create",
"id" => G5_BBS_URL . "/board.php?bo_table=" . ACTIVITYPUB_G5_BOARDNAME . "#Draft",
"to" => $to,
"cc" => $cc,
"actor" => $object['attributedTo'],
"object" => $object
);
// 초안(Draft) 작성
$activity_wr_id = activitypub_update_activity("outbox", $data, $mb, "draft");
$data['id'] = G5_BBS_URL . "/board.php?bo_table=" . ACTIVITYPUB_G5_BOARDNAME . "&wr_id=" . $activity_wr_id;
$activity_id = activitypub_update_activity("outbox", $data, $mb, "draft");
$data['object']['id'] = G5_BBS_URL . "/board.php?bo_table=" . ACTIVITYPUB_G5_BOARDNAME . "&wr_id=" . $activity_id;
$data['id'] = activitypub_get_url("activity", array("id" => $activity_id));
// 현재 시간 반영
$now_utc_tz = str_replace('+00:00', 'Z', gmdate('c'));
$data['published'] = $now_utc_tz;
$data['updated'] = $now_utc_tz;
// 보낼 전문을 인코딩
$rawdata = activitypub_json_encode($data);
// 수신자 작업
foreach($to as $_to) {
// 공개 네임스페이스인 경우 건너뛰기
if ($_to == NAMESPACE_ACTIVITYSTREAMS_PUBLIC) continue;
// 수신자 엔드포인트(URL) 작업
foreach($endpoints as $endpoint) {
// 수신자 정보 조회
$remote_user_ctx = activitypub_http_get($_to);
$remote_account_ctx = activitypub_http_get($endpoint);
// inbox 주소 찾기
$remote_inbox_url = $remote_user_ctx['inbox'];
$remote_inbox_url = $remote_account_ctx['inbox'];
if (empty($remote_inbox_url)) {
$remote_inbox_url = $remote_user_ctx['endpoints']['sharedInbox'];
$remote_inbox_url = $remote_account_ctx['endpoints']['sharedInbox'];
}
// inbox 주소가 없으면 건너뛰기
if (empty($remote_inbox_url)) {
activitypub_add_memo(ACTIVITYPUB_G5_USERNAME, $mb['mb_id'], "Could not find the inbox of " . $_to);
activitypub_add_memo(ACTIVITYPUB_G5_USERNAME, $mb['mb_id'], "이 사용자 또는 서버는 메시지를 수신할 수 없는 상태임: " . $_to);
continue;
}
@ -743,7 +800,7 @@ function activitypub_publish_content($content, $object_id, $mb, $_added_object =
}
// inbox로 데이터 전송
$response = activitypub_http_post($remote_inbox_url, $rawdata, $mb, $access_token);
activitypub_http_post($remote_inbox_url, $rawdata, $mb, $access_token);
}
// 발행됨(Published)으로 상태 업데이트
@ -758,12 +815,13 @@ function activitypub_parse_content($content) {
$pos = -1;
$get_next_position = function ($pos) use ($content) {
try {
return min(array_filter(array(
$positions = array_filter(array(
strpos($content, '@', $pos + 1),
strpos($content, '#', $pos + 1),
strpos($content, 'http://', $pos + 1),
strpos($content, 'https://', $pos + 1)
), "is_numeric"));
), "is_numeric");
return (count($positions) > 0 ? min($positions) : false);
} catch (ValueError $e) {
return false;
}
@ -820,9 +878,9 @@ function activitypub_update_activity($inbox = "inbox", $data, $mb = array("mb_id
$wr_num = get_next_num($write_table);
$wr_reply = '';
$ca_name = $inbox; // Inbox/Outbox
$wr_subject = mb_substr($content, 0, 50);
$wr_seo_title = $content;
$wr_content = $content . "\r\n\r\n[외부에서 전송된 글입니다.]";
$wr_subject = mb_substr(strip_tags($content), 0, 50);
$wr_seo_title = strip_tags($content);
$wr_content = strip_tags($content) . "\r\n\r\n[외부에서 전송된 글입니다.]";
$wr_link1 = $data['actor'];
$wr_link2 = '';
$wr_homepage = $data['actor'];
@ -893,8 +951,8 @@ function activitypub_update_activity($inbox = "inbox", $data, $mb = array("mb_id
if ($status == "published") {
// 저장 전 데이터 처리
$now_utc_tz = str_replace('+00:00', 'Z', gmdate('c'));
$data['published'] = $now_utc_tz;
$data['updated'] = $now_utc_tz;
$data['published'] = empty($data['published']) ? $now_utc_tz : $data['published'];
$data['updated'] = empty($data['updated']) ? $now_utc_tz : $data['updated'];
// 요청 전문은 파일로 저장
$raw_context = activitypub_json_encode($data);
@ -936,43 +994,30 @@ function activitypub_update_activity($inbox = "inbox", $data, $mb = array("mb_id
return $wr_id;
}
function activitypub_get_objects($mb, $inbox = "inbox") {
function activitypub_get_activity_by_id($activity_id) {
global $g5;
$items = array();
// 액티비티 전문
$activity_ctx = array();
// 정보 불러오기
$sql = "";
if(!$mb['mb_id']) {
$sql = "select wr_id from " . ACTIVITYPUB_G5_TABLENAME . "
where ca_name = '$inbox'
and DATE(wr_datetime) BETWEEN CURDATE() - INTERVAL " . ACTIVITYPUB_G5_OUTDATED_DAYS . " DAY AND CURDATE()
";
} else {
$sql = "select wr_id from " . ACTIVITYPUB_G5_TABLENAME . "
where ca_name = '$inbox'
and FIND_IN_SET('$mb_id', wr_7) > 0
and DATE(wr_datetime) BETWEEN CURDATE() - INTERVAL " . ACTIVITYPUB_G5_OUTDATED_DAYS . " DAY AND CURDATE()
";
}
// 해당 액티비티 찾고 없으면 빈 정보 반환
$write_table = $g5['write_prefix'] . ACTIVITYPUB_G5_BOARDNAME;
$wr = get_write($write_table, $activity_id);
if (empty($wr['wr_id'])) return $activity_ctx;
// 액티비티 조회
$sql = "select * from {$g5['board_file_table']}
where bo_table = '" . ACTIVITYPUB_G5_BOARDNAME . "' and wr_id = '{$wr['wr_id']}' and bf_content = 'application/activity+json'";
$result = sql_query($sql);
// 정보 조회 후 처리
while ($row = sql_fetch_array($result)) {
$sql2 = "select * from {$g5['board_file_table']}
where bo_table = '" . ACTIVITYPUB_G5_BOARDNAME . "' and wr_id = '{$row['wr_id']}' and bf_content = 'application/activity+json'";
$result2 = sql_query($sql2);
while ($row2 = sql_fetch_array($result2)) {
$filename = $row2['bf_file'];
$filepath = G5_DATA_PATH . "/file/" . ACTIVITYPUB_G5_BOARDNAME . "/" . $filename;
if(file_exists($filepath)) {
array_push($items, activitypub_json_decode(file_get_contents($filepath))['object']);
}
$filename = $row['bf_file'];
$filepath = G5_DATA_PATH . "/file/" . ACTIVITYPUB_G5_BOARDNAME . "/" . $filename;
if (file_exists($filepath)) {
$activity_ctx = activitypub_json_decode(@file_get_contents($filepath))['object'];
}
}
// 전문 만들기
return activitypub_build_collection($items);
return $activity_ctx;
}
// Object type: Note
@ -1121,6 +1166,17 @@ class _GNUBOARD_ActivityPub {
return activitypub_json_encode($context);
}
public static function activity() {
// HTTP 요청 유형에 따라 작업
switch ($_SERVER['REQUEST_METHOD']) {
case "POST":
return activitypub_json_encode(array("message" => "Disallowed method"));
case "GET":
return activitypub_get_activity_by_id($_GET['id']);
}
}
public static function inbox() {
// HTTP 요청 유형에 따라 작업
@ -1130,14 +1186,14 @@ class _GNUBOARD_ActivityPub {
// 공개(Public) 설정한 메시지는 ACTIVITYPUB_G5_TABLENAME에 저장
$data = activitypub_json_decode(file_get_contents("php://input"), true);
if (empty($data['@context'])) {
return activitypub_json_encode(array("message" => "This is a broken context"));
}
if ($data['@context'] != NAMESPACE_ACTIVITYSTREAMS) {
// @context의 네임스페이스는 단수형(string으로 표현) 또는 복수형(array로 표현)될 수 있음
$namespaces = activitypub_cast_to_array($data['@context']);
// ActivityStream 네임스페이스가 존재하지 않는 경우 요청 거절
if (!in_array(NAMESPACE_ACTIVITYSTREAMS, $namespaces)) {
return activitypub_json_encode(array("message" => "This is not an ActivityStreams request"));
}
// 컨텐츠 변수 정의
$content = '';
@ -1146,8 +1202,11 @@ class _GNUBOARD_ActivityPub {
// 정보 불러오기
$mb = get_member(ACTIVITYPUB_G5_USERNAME);
// 수신자 확인
$to = $data['to'];
// 수신자 (참조자 포함) 확인
$to = array_merge(
activitypub_cast_to_array($data['to']),
activitypub_cast_to_array($data['cc'])
);
// 원글 정보 확인
$object = $data['object'];
@ -1168,7 +1227,12 @@ class _GNUBOARD_ActivityPub {
// 컨텐츠 설정
$bo = get_board_db(ACTIVITYPUB_G5_BOARDNAME, true);
$content = sprintf("%s\r\n\r\n[외부에서 전송된 글입니다. 자세한 내용은 %s#%s 글을 확인하세요.]", $object['content'], $bo['bo_subject'], $activity_wr_id);
$content = sprintf(
"%s\r\n\r\n[외부에서 전송된 글입니다. 자세한 내용은 %s#%s 글을 확인하세요.]",
strip_tags($object['content']),
$bo['bo_subject'],
$activity_wr_id
);
// 답글인지 확인
if (!empty($object['inReplyTo'])) {
@ -1357,8 +1421,7 @@ class _GNUBOARD_ActivityPub {
return activitypub_json_encode(array("message" => "Success"));
case "GET":
$mb = get_member($_GET['mb_id']);
return activitypub_json_encode(activitypub_get_objects($mb, "inbox"));
return activitypub_json_encode(array("message" => "Disallowed method"));
default:
return activitypub_json_encode(array("message" => "Not supported method"));
@ -1400,56 +1463,6 @@ class _GNUBOARD_ActivityPub {
$items = array(); // 항목을 담을 배열
/* // TODO: Remove (Security Reason)
// 게시판인 경우
if (array_key_exists("bo_table", $_GET)) {
$bo = get_board_db($_GET['bo_table'], true);
if (!empty($bo['bo_table'])) {
switch($bo['bo_table']) {
case ACTIVITYPUB_G5_BOARDNAME:
return self::inbox(); // 액티비티를 저장하는 테이블인 경우 inbox와 동일하게 취급
default:
// 조회할 페이지 수 불러오기
$page = intval($_GET['page']);
if ($page < 1) {
$page = 1;
}
// 페이지 당 표시할 게시물 수 불러오기
$page_rows = 0;
if (!empty($bo['bo_mobile_page_rows'])) {
$page_rows = intval($bo['bo_mobile_page_rows']);
} else if (!empty($bo['bo_page_rows'])) {
$page_rows = intval($bo['bo_page_rows']);
}
// 페이지 당 표시할 게시물 수가 1보다 작으면 기본값(15)로 설정
if ($pages_rows < 1) {
$page_rows = 15;
}
// SQL 작성
$write_table = $g5['write_prefix'] . $bo['bo_table'];
$offset = ($page - 1) * $page_rows;
$sql = "select wr_id, mb_id, wr_content, wr_datetime from {$write_table} where FIND_IN_SET('secret', wr_option) = 0 order by wr_datetime desc limit {$offset}, {$page_rows} ";
// SQL 실행
$result = sql_query($sql);
while ($row = sql_fetch_array($result)) {
$object_id = G5_BBS_URL . "/board.php?bo_table={$bo['bo_table']}&wr_id={$row['wr_id']}";
$mb = get_member($row['mb_id']);
$content = $row['wr_content'];
array_push($items, activitypub_build_note($content, $object_id, $mb));
}
}
}
}
*/
// 최근 활동에서 추출
$sql = "select * from " . $g5['board_new_table'];
$result = sql_query($sql);
@ -1474,15 +1487,15 @@ class _GNUBOARD_ActivityPub {
switch ($grant_type) {
case "authorization_code":
return activitypub_json_encode(array("message" => "Sorry. This grant type does not supported yet"));
return activitypub_json_encode(array("message" => "Not implemented"));
break;
case "password":
return activitypub_json_encode(array("message" => "Sorry. This grant type does not supported yet"));
return activitypub_json_encode(array("message" => "Not implemented"));
break;
case "client_credentials":
return activitypub_json_encode(array("message" => "Sorry. This grant type does not supported yet"));
return activitypub_json_encode(array("message" => "Not implemented"));
break;
}
}
@ -1499,13 +1512,13 @@ function _activitypub_memo_form_update_after($member_list, $str_nick_list, $redi
// 'apstreams' 계정이 있는지 확인
if (!in_array(ACTIVITYPUB_G5_USERNAME, $member_list['id'])) return;
// 현재 로그인되어 있으면, 로그인된 계정의 정보를 따름
// 글을 생성한 회원 정보
$mb = (isset($member['mb_id']) ? $member : get_member(ACTIVITYPUB_G5_USERNAME));
// 글 전송하기
if (!empty($mb['mb_id'])) {
// 글 전송하기
$data = activitypub_publish_content(
activitypub_publish_content(
$me_memo,
activitypub_get_url("user", array("mb_id" => $mb['mb_id'])),
$mb
@ -1516,12 +1529,12 @@ function _activitypub_memo_form_update_after($member_list, $str_nick_list, $redi
function _activitypub_write_update_after($board, $wr_id, $w, $qstr, $redirect_url) {
global $g5, $member;
// 본문 가져오기
// 본문 가져오기 (본문이 없는 경우 중단)
$sql = "select wr_id, wr_content from {$g5['write_prefix']}{$board['bo_table']} where wr_id = '{$wr_id}'";
$row = sql_fetch($sql);
if (empty($row['wr_id'])) return;
// 현재 로그인되어 있으면, 로그인된 계정의 정보를 따름
// 글을 생성한 회원 정보
$mb = (isset($member['mb_id']) ? $member : get_member(ACTIVITYPUB_G5_USERNAME));
// 추가할 오브젝트 속성
@ -1535,7 +1548,7 @@ function _activitypub_write_update_after($board, $wr_id, $w, $qstr, $redirect_ur
// 글 전송하기
if (!empty($mb['mb_id'])) {
$data = activitypub_publish_content(
activitypub_publish_content(
$row['wr_content'],
G5_BBS_URL . "/board.php?bo_table={$board['bo_table']}&wr_id={$row['wr_id']}",
$mb,
@ -1547,12 +1560,12 @@ function _activitypub_write_update_after($board, $wr_id, $w, $qstr, $redirect_ur
function _activitypub_comment_update_after($board, $wr_id, $w, $qstr, $redirect_url, $comment_id, $reply_array) {
global $g5, $member;
// 본문(댓글) 가져오기
// 본문(댓글) 가져오기 (본문이 없는 경우 중단)
$sql = "select wr_id, wr_content from {$g5['write_prefix']}{$board['bo_table']} where wr_id = '{$wr_id}'";
$row = sql_fetch($sql);
if (empty($row['wr_id'])) return;
// 현재 로그인되어 있으면, 로그인된 계정의 정보를 따름
// 글을 생성한 회원 정보
$mb = (isset($member['mb_id']) ? $member : get_member(ACTIVITYPUB_G5_USERNAME));
// 추가할 오브젝트 속성
@ -1568,7 +1581,7 @@ function _activitypub_comment_update_after($board, $wr_id, $w, $qstr, $redirect_
// 글 전송하기
if (!empty($mb['mb_id'])) {
$data = activitypub_publish_content(
activitypub_publish_content(
$row['wr_content'],
G5_BBS_URL . "/board.php?bo_table={$board['bo_table']}&wr_id={$row['wr_parent']}&c_id=" . $comment_id,
$mb,
@ -1614,6 +1627,12 @@ switch ($route) {
_GNUBOARD_ActivityPub::close();
break;
case "activitypub.activity":
_GNUBOARD_ActivityPub::open();
echo _GNUBOARD_ActivityPub::activity();
_GNUBOARD_ActivityPub::close();
break;
case "activitypub.inbox":
_GNUBOARD_ActivityPub::open();
echo _GNUBOARD_ActivityPub::inbox();
@ -1650,9 +1669,10 @@ switch ($route) {
_GNUBOARD_ActivityPub::close();
break;
case "oauth2.authorize": // TODO
case "oauth2.authorize": // Not implemented
_GNUBOARD_ActivityPub::open();
echo _GNUBOARD_ActivityPub::authorize();
_GNUBOARD_ActivityPub::close();
break;
}