Merge pull request #112 from NicolasConstant/develop

0.18.0 PR
This commit is contained in:
Nicolas Constant 2021-07-19 18:31:04 -04:00 committed by GitHub
commit 22b0d6da84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 6 deletions

View file

@ -47,6 +47,7 @@ If both whitelisting and blacklisting are set, only the whitelisting will be act
* `Instance:ResolveMentionsInProfiles` (default: true) to enable or disable mentions parsing in profile's description. Resolving it will consume more User's API calls since newly discovered account can also contain references to others accounts as well. On a big instance it is recommended to disable it.
* `Instance:PublishReplies` (default: false) to enable or disable replies publishing.
* `Instance:UnlistedTwitterAccounts` (default: null) to enable unlisted publication for selected twitter accounts, separated by `;` (please limit this to brands and other public profiles).
* `Instance:SensitiveTwitterAccounts` (default: null) mark all media from given accounts as sensitive by default, separated by `;`.
# Docker Compose full example
@ -78,6 +79,7 @@ services:
+ - Instance:ResolveMentionsInProfiles=false
+ - Instance:PublishReplies=true
+ - Instance:UnlistedTwitterAccounts=cocacola;twitter
+ - Instance:SensitiveTwitterAccounts=archillect
networks:
[...]

View file

@ -10,5 +10,6 @@
public int MaxUsersCapacity { get; set; }
public string UnlistedTwitterAccounts { get; set; }
public string SensitiveTwitterAccounts { get; set; }
}
}
}

View file

@ -7,16 +7,19 @@ namespace BirdsiteLive.Domain.Repository
public interface IPublicationRepository
{
bool IsUnlisted(string twitterAcct);
bool IsSensitive(string twitterAcct);
}
public class PublicationRepository : IPublicationRepository
{
private readonly string[] _unlistedAccounts;
private readonly string[] _sensitiveAccounts;
#region Ctor
public PublicationRepository(InstanceSettings settings)
{
_unlistedAccounts = PatternsParser.Parse(settings.UnlistedTwitterAccounts);
_sensitiveAccounts = PatternsParser.Parse(settings.SensitiveTwitterAccounts);
}
#endregion
@ -26,5 +29,12 @@ namespace BirdsiteLive.Domain.Repository
return _unlistedAccounts.Contains(twitterAcct.ToLowerInvariant());
}
public bool IsSensitive(string twitterAcct)
{
if (_sensitiveAccounts == null || !_sensitiveAccounts.Any()) return false;
return _sensitiveAccounts.Contains(twitterAcct.ToLowerInvariant());
}
}
}
}

View file

@ -50,6 +50,11 @@ namespace BirdsiteLive.Domain
if (isUnlisted)
cc = new[] {"https://www.w3.org/ns/activitystreams#Public"};
string summary = null;
var sensitive = _publicationRepository.IsSensitive(username);
if (sensitive)
summary = "Potential Content Warning";
var extractedTags = _statusExtractor.Extract(tweet.MessageContent);
_statisticsHandler.ExtractedStatus(extractedTags.tags.Count(x => x.type == "Mention"));
@ -81,7 +86,8 @@ namespace BirdsiteLive.Domain
to = new[] { to },
cc = cc,
sensitive = false,
sensitive = sensitive,
summary = summary,
content = $"<p>{content}</p>",
attachment = Convert(tweet.Media),
tag = extractedTags.tags
@ -104,4 +110,4 @@ namespace BirdsiteLive.Domain
}).ToArray();
}
}
}
}

View file

@ -4,7 +4,7 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<UserSecretsId>d21486de-a812-47eb-a419-05682bb68856</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<Version>0.17.0</Version>
<Version>0.18.0</Version>
</PropertyGroup>
<ItemGroup>

View file

@ -21,7 +21,8 @@
"ResolveMentionsInProfiles": true,
"PublishReplies": false,
"MaxUsersCapacity": 1500,
"UnlistedTwitterAccounts": null
"UnlistedTwitterAccounts": null,
"SensitiveTwitterAccounts": null
},
"Db": {
"Type": "postgres",