Change LTL to FTL for iMast and Official Apps
This commit is contained in:
parent
df80317365
commit
b7c90ae1e8
3 changed files with 69 additions and 4 deletions
|
@ -40,7 +40,8 @@ class Api::V1::Timelines::PublicController < Api::BaseController
|
|||
local: truthy_param?(:local),
|
||||
remote: truthy_param?(:remote),
|
||||
domain: params[:domain],
|
||||
only_media: truthy_param?(:only_media)
|
||||
only_media: truthy_param?(:only_media),
|
||||
application: doorkeeper_token&.application
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -19,11 +19,12 @@ class PublicFeed
|
|||
# @param [Integer] min_id
|
||||
# @return [Array<Status>]
|
||||
def get(limit, max_id = nil, since_id = nil, min_id = nil)
|
||||
return Status.none if local_only? && !imast? && !mastodon_for_ios? && !mastodon_for_android?
|
||||
|
||||
scope = public_scope
|
||||
|
||||
scope.merge!(without_replies_scope) unless with_replies?
|
||||
scope.merge!(without_reblogs_scope) unless with_reblogs?
|
||||
scope.merge!(local_only_scope) if local_only?
|
||||
scope.merge!(remote_only_scope) if remote_only?
|
||||
scope.merge!(domain_only_scope) if domain_only?
|
||||
scope.merge!(account_filters_scope) if account?
|
||||
|
@ -45,7 +46,19 @@ class PublicFeed
|
|||
end
|
||||
|
||||
def local_only?
|
||||
false
|
||||
@options[:local]
|
||||
end
|
||||
|
||||
def imast?
|
||||
@options[:application]&.website == 'https://cinderella-project.github.io/iMast/'
|
||||
end
|
||||
|
||||
def mastodon_for_ios?
|
||||
@options[:application]&.name == 'Mastodon for iOS'
|
||||
end
|
||||
|
||||
def mastodon_for_android?
|
||||
@options[:application]&.name == 'Mastodon for Android'
|
||||
end
|
||||
|
||||
def remote_only?
|
||||
|
|
|
@ -294,7 +294,7 @@ const startWorker = (workerId) => {
|
|||
return;
|
||||
}
|
||||
|
||||
client.query('SELECT oauth_access_tokens.id, oauth_access_tokens.resource_owner_id, users.account_id, users.chosen_languages, oauth_access_tokens.scopes, devices.device_id, oauth_applications.name FROM oauth_access_tokens INNER JOIN oauth_applications ON oauth_access_tokens.application_id = oauth_applications.id INNER JOIN users ON oauth_access_tokens.resource_owner_id = users.id LEFT OUTER JOIN devices ON oauth_access_tokens.id = devices.access_token_id WHERE oauth_access_tokens.token = $1 AND oauth_access_tokens.revoked_at IS NULL LIMIT 1', [token], (err, result) => {
|
||||
client.query('SELECT oauth_access_tokens.id, oauth_access_tokens.resource_owner_id, users.account_id, users.chosen_languages, oauth_access_tokens.scopes, devices.device_id, oauth_applications.name, oauth_applications.website FROM oauth_access_tokens INNER JOIN oauth_applications ON oauth_access_tokens.application_id = oauth_applications.id INNER JOIN users ON oauth_access_tokens.resource_owner_id = users.id LEFT OUTER JOIN devices ON oauth_access_tokens.id = devices.access_token_id WHERE oauth_access_tokens.token = $1 AND oauth_access_tokens.revoked_at IS NULL LIMIT 1', [token], (err, result) => {
|
||||
done();
|
||||
|
||||
if (err) {
|
||||
|
@ -317,6 +317,7 @@ const startWorker = (workerId) => {
|
|||
req.allowNotifications = req.scopes.some(scope => ['read', 'read:notifications'].includes(scope));
|
||||
req.deviceId = result.rows[0].device_id;
|
||||
req.applicationName = result.rows[0].name;
|
||||
req.website = result.rows[0].website;
|
||||
|
||||
resolve();
|
||||
});
|
||||
|
@ -366,6 +367,8 @@ const startWorker = (workerId) => {
|
|||
return 'user:notification';
|
||||
case '/api/v1/streaming/public':
|
||||
return onlyMedia ? 'public:media' : 'public';
|
||||
case '/api/v1/streaming/public/local':
|
||||
return onlyMedia ? 'public:local:media' : 'public:local';
|
||||
case '/api/v1/streaming/public/remote':
|
||||
return onlyMedia ? 'public:remote:media' : 'public:remote';
|
||||
case '/api/v1/streaming/public/domain':
|
||||
|
@ -384,6 +387,8 @@ const startWorker = (workerId) => {
|
|||
const PUBLIC_CHANNELS = [
|
||||
'public',
|
||||
'public:media',
|
||||
'public:local',
|
||||
'public:local:media',
|
||||
'public:remote',
|
||||
'public:remote:media',
|
||||
'public:domain',
|
||||
|
@ -802,6 +807,17 @@ const startWorker = (workerId) => {
|
|||
options: { needsFiltering: true, notificationOnly: false },
|
||||
});
|
||||
|
||||
break;
|
||||
case 'public:local':
|
||||
if (!isImast(req) && !isMastodonForiOS(req) && !isMastodonForAndroid(req)) {
|
||||
reject('No local stream provided');
|
||||
}
|
||||
|
||||
resolve({
|
||||
channelIds: ['timeline:public'],
|
||||
options: { needsFiltering: true, notificationOnly: false },
|
||||
});
|
||||
|
||||
break;
|
||||
case 'public:remote':
|
||||
resolve({
|
||||
|
@ -827,6 +843,17 @@ const startWorker = (workerId) => {
|
|||
options: { needsFiltering: true, notificationOnly: false },
|
||||
});
|
||||
|
||||
break;
|
||||
case 'public:local:media':
|
||||
if (!isImast(req) && !isMastodonForiOS(req) && !isMastodonForAndroid(req)) {
|
||||
reject('No local media stream provided');
|
||||
}
|
||||
|
||||
resolve({
|
||||
channelIds: ['timeline:public:media'],
|
||||
options: { needsFiltering: true, notificationOnly: false },
|
||||
});
|
||||
|
||||
break;
|
||||
case 'public:remote:media':
|
||||
resolve({
|
||||
|
@ -1086,6 +1113,30 @@ const startWorker = (workerId) => {
|
|||
process.on('uncaughtException', onError);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {any} req
|
||||
* @return {boolean}
|
||||
*/
|
||||
const isImast = (req) => {
|
||||
return req.website == 'https://cinderella-project.github.io/iMast/';
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {any} req
|
||||
* @return {boolean}
|
||||
*/
|
||||
const isMastodonForiOS = (req) => {
|
||||
return req.applicationName == 'Mastodon for iOS';
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {any} req
|
||||
* @return {boolean}
|
||||
*/
|
||||
const isMastodonForAndroid = (req) => {
|
||||
return req.applicationName == 'Mastodon for Android';
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {any} server
|
||||
* @param {function(string): void} [onSuccess]
|
||||
|
|
Loading…
Reference in a new issue