forked from GNUsocial/gnu-social
Refactor and centralize notice source link calculation
This commit is contained in:
@@ -703,7 +703,7 @@ class Notice extends Memcached_DataObject
|
||||
|
||||
/**
|
||||
* Is this notice part of an active conversation?
|
||||
*
|
||||
*
|
||||
* @return boolean true if other messages exist in the same
|
||||
* conversation, false if this is the only one
|
||||
*/
|
||||
@@ -1809,4 +1809,41 @@ class Notice extends Memcached_DataObject
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the source of the notice
|
||||
*
|
||||
* @return Notice_source $ns A notice source object. 'code' is the only attribute
|
||||
* guaranteed to be populated.
|
||||
*/
|
||||
function getSource()
|
||||
{
|
||||
$ns = new Notice_source();
|
||||
if (!empty($this->source)) {
|
||||
switch ($this->source) {
|
||||
case 'web':
|
||||
case 'xmpp':
|
||||
case 'mail':
|
||||
case 'omb':
|
||||
case 'system':
|
||||
case 'api':
|
||||
$ns->code = $this->source;
|
||||
break;
|
||||
default:
|
||||
$ns = Notice_source::staticGet($this->source);
|
||||
if (!$ns) {
|
||||
$ns = new Notice_source();
|
||||
$ns->code = $this->source;
|
||||
$app = Oauth_application::staticGet('name', $this->source);
|
||||
if ($app) {
|
||||
$ns->name = $app->name;
|
||||
$ns->url = $app->source_url;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $ns;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user