Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions apps/api/modules/like/actions/actions.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,30 @@ public function executePost(sfWebRequest $request)
$this->forward400If($alreadyLike, 'It has already been registered');

$fromMember = $this->getUser()->getMember();
$baseUrl = $request->getRelativeUrlRoot();
switch ($foreignTable)
{
case 'A':
$this->forward400Unless($activity = Doctrine::getTable('ActivityData')->find($foreignId));
$timelineId = $activity->in_reply_to_activity_id ? $activity->in_reply_to_activity_id : $activity->id;
$url = $baseUrl.'/timeline/show/id/'.$timelineId;
$url = '/timeline/show/id/'.$timelineId;
break;
case 'D':
$url = $baseUrl.'/diary/'.$foreignId;
$url = '/diary/'.$foreignId;
break;
case 'd':
$diaryComment = Doctrine::getTable('DiaryComment')->findOneById($foreignId);
$this->forward400Unless($diaryComment, 'diary comment does not exist.');
$url = $baseUrl.'/diary/'.$diaryComment->getDiaryId();
$url = '/diary/'.$diaryComment->getDiaryId();
break;
case 'e':
$eventComment = Doctrine::getTable('CommunityEventComment')->findOneById($foreignId);
$this->forward400Unless($eventComment, 'event comment does not exist.');
$url = $baseUrl.'/communityEvent/'.$eventComment->getCommunityEventId();
$url = '/communityEvent/'.$eventComment->getCommunityEventId();
break;
case 't':
$topicComment = Doctrine::getTable('CommunityTopicComment')->findOneById($foreignId);
$this->forward400Unless($topicComment, 'topic comment does not exist.');
$url = $baseUrl.'/communityTopic/'.$topicComment->getCommunityTopicId();
$url = '/communityTopic/'.$topicComment->getCommunityTopicId();
break;
default :
$url = '#';
Expand Down
2 changes: 1 addition & 1 deletion data/fixtures/000_revision.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SnsConfig:
op_like_plugin_current_revision:
name: "opLikePlugin_revision"
value: 3
value: 4
48 changes: 48 additions & 0 deletions data/migrations/004_change_notification_url.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* @package opLikePlugin
* @subpackage migration
* @author Kaoru Nishizoe <nishizoe@tejimaya.com>
*/
class opLikePluginMigrationVersion4 extends opMigration
{
/*
* 下記の条件に一致する通知URLを一括で変更:
* * url に '/timeline/', '/diary/', '/communityEvent/', '/communityTopic/' が含まれ、

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

メッセージ機能の通知 (/message/read/:id) は対応不要でしょうか?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

メッセージ機能の通知 (/message/read/:id) は、opLikePlugin 経由で通知されているものではないので、今回の問題には当たりませんのでここでの対応は不要です。

* 且つ、これらの前に'/'で始まる何らかの文字列が含まれているもの
*/
public function postUp()
{
$notificationObject = Doctrine::getTable('MemberConfig')
->findByName('notification_center');

if ($notificationObject)
{
foreach ($notificationObject as $object)
{
$notifications = unserialize($object->getValue());

$newNotifications = array();
foreach ($notifications as $notificationItem)
{
$url = $notificationItem['url'];
if ($url)
{
if (preg_match('/(\/timeline\/show\/id|\/diary|\/communityEvent|\/communityTopic)\/[0-9]+/', $url, $m))
{
$url = $m[0];
$notificationItem['url'] = $url;
}
}
array_push($newNotifications, $notificationItem);
}

$object->setValue(serialize($newNotifications));
$object->save();
$object->free(true);
}
}

}
}