Update activitypub.extend.php

This commit is contained in:
Namhyeon Go 2022-09-28 19:27:32 +09:00 committed by GitHub
parent 4c980beb90
commit 86b3fc8029
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1208,6 +1208,8 @@ class _GNUBOARD_ActivityPub {
public static function shares() {
global $g5;
// 게시판인 경우
if (array_key_exists("bo_table", $_GET)) {
$bo = get_board_db($_GET['bo_table'], true);
if (!empty($bo['bo_table'])) {
@ -1240,8 +1242,7 @@ class _GNUBOARD_ActivityPub {
// 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 = "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);
@ -1251,12 +1252,28 @@ class _GNUBOARD_ActivityPub {
$content = $row['wr_content'];
array_push($items, activitypub_build_note($content, $object_id, $mb));
}
}
}
} else { // 게시판이 아닌 경우
// 최근 활동에서 추출
$sql = "select * from " . $g5['board_new_table'];
$result = sql_query($sql);
while ($row = sql_fetch_array($result)) {
$write_table = $g5['write_prefix'] . $row['bo_table'];
$sql2 = "select wr_id, mb_id, wr_content, wr_datetime from {$write_table} where wr_id = '{$row['wr_id']}' and FIND_IN_SET('secret', wr_option) = 0 ";
$row2 = sql_fetch($sql2);
if ($row2['wr_id']) {
$object_id = G5_BBS_URL . "/board.php?bo_table={$row['bo_table']}&wr_id={$row2['wr_id']}";
$mb = get_member($row2['mb_id']);
$content = $row2['wr_content'];
array_push($items, activitypub_build_note($content, $object_id, $mb));
}
}
}
// 결과 반환
return activitypub_json_encode(activitypub_build_collection($items, "Latest shares"));
}
}
}
public static function close() {
exit();
@ -1423,3 +1440,4 @@ switch ($route) {
_GNUBOARD_ActivityPub::close();
break;
}