Update activitypub.extend.php
This commit is contained in:
parent
c2cbea19e7
commit
11b3a3e055
|
@ -4,7 +4,7 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
|
|||
// ActivityPub implementation for GNUBOARD 5
|
||||
// Go Namhyeon <gnh1201@gmail.com>
|
||||
// MIT License
|
||||
// 2022-07-04 (version 0.1.6)
|
||||
// 2022-07-04 (version 0.1.7-dev)
|
||||
|
||||
// References:
|
||||
// * https://www.w3.org/TR/activitypub/
|
||||
|
@ -959,33 +959,59 @@ class _GNUBOARD_ActivityPub {
|
|||
}
|
||||
|
||||
// 훅(Hook) 등록
|
||||
function _activitypub_update_after($board, $wr_id) {
|
||||
global $g5;
|
||||
function _activitypub_hook_write_update($board, $wr_id) {
|
||||
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;
|
||||
|
||||
if (!empty($row['wr_id'])) {
|
||||
$data = activitypub_publish_content(
|
||||
$row['wr_content'],
|
||||
G5_BBS_URL . "/bbs/board.php?bo_table={$board['bo_table']}&wr_id={$row['wr_id']}"
|
||||
);
|
||||
$mb = get_member(ACTIVITYPUB_G5_USERNAME);
|
||||
activitypub_add_activity("outbox", $data, $mb);
|
||||
// 글 전송하기
|
||||
$data = activitypub_publish_content(
|
||||
$row['wr_content'],
|
||||
G5_BBS_URL . "/bbs/board.php?bo_table={$board['bo_table']}&wr_id={$row['wr_id']}"
|
||||
);
|
||||
|
||||
// 현재 로그인되어 있으면, 로그인된 계정의 정보를 따름
|
||||
if (!empty($member['mb_id'])) {
|
||||
activitypub_add_activity("outbox", $data, $member);
|
||||
} else {
|
||||
activitypub_add_activity("outbox", $data, get_member(ACTIVITYPUB_G5_USERNAME));
|
||||
}
|
||||
}
|
||||
|
||||
function _activitypub_memo_form_update_after($member_list, $str_nick_list, $redirect_url, $me_memo) {
|
||||
global $member;
|
||||
|
||||
// 'apstreams' 계정이 있는지 확인
|
||||
if (!in_array(ACTIVITYPUB_G5_USERNAME, $member_list['id'])) return;
|
||||
|
||||
// 글 전송하기
|
||||
$data = activitypub_publish_content(
|
||||
$me_memo,
|
||||
activitypub_get_url("user", array("mb_id" => $member['mb_id']))
|
||||
);
|
||||
|
||||
// 현재 로그인되어 있으면, 로그인된 계정의 정보를 따름
|
||||
if (!empty($member['mb_id'])) {
|
||||
activitypub_add_activity("outbox", $data, $member);
|
||||
} else {
|
||||
activitypub_add_activity("outbox", $data, get_member(ACTIVITYPUB_G5_USERNAME));
|
||||
}
|
||||
}
|
||||
|
||||
function _activitypub_write_update_after($board, $wr_id, $w, $qstr, $redirect_url) {
|
||||
_activitypub_update_after($board, $wr_id);
|
||||
_activitypub_hook_write_update($board, $wr_id);
|
||||
}
|
||||
|
||||
function _activitypub_comment_update_after($board, $wr_id, $w, $qstr, $redirect_url, $comment_id, $reply_array) {
|
||||
_activitypub_update_after($board, $wr_id);
|
||||
_activitypub_hook_write_update($board, $wr_id);
|
||||
}
|
||||
|
||||
add_event("write_update_after", "_activitypub_write_update_after", 0, 5);
|
||||
add_event("comment_update_after", "_activitypub_comment_update_after", 0, 7);
|
||||
add_event("memo_form_update_after", "_activitypub_memo_form_update_after", 0, 4);
|
||||
|
||||
// 모든 준비가 완료되고 작업 시작
|
||||
$route = $_GET['route'];
|
||||
|
|
Loading…
Reference in New Issue
Block a user