Skip to content

Commit

Permalink
Merge pull request #112 from NicolasConstant/develop
Browse files Browse the repository at this point in the history
0.18.0 PR
  • Loading branch information
NicolasConstant authored Jul 19, 2021
2 parents 07dc912 + 4eb2909 commit 22b0d6d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
2 changes: 2 additions & 0 deletions VARIABLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -78,6 +79,7 @@ services:
+ - Instance:ResolveMentionsInProfiles=false
+ - Instance:PublishReplies=true
+ - Instance:UnlistedTwitterAccounts=cocacola;twitter
+ - Instance:SensitiveTwitterAccounts=archillect
networks:
[...]

Expand Down
3 changes: 2 additions & 1 deletion src/BirdsiteLive.Common/Settings/InstanceSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public class InstanceSettings
public int MaxUsersCapacity { get; set; }

public string UnlistedTwitterAccounts { get; set; }
public string SensitiveTwitterAccounts { get; set; }
}
}
}
12 changes: 11 additions & 1 deletion src/BirdsiteLive.Domain/Repository/PublicationRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -26,5 +29,12 @@ public bool IsUnlisted(string twitterAcct)

return _unlistedAccounts.Contains(twitterAcct.ToLowerInvariant());
}

public bool IsSensitive(string twitterAcct)
{
if (_sensitiveAccounts == null || !_sensitiveAccounts.Any()) return false;

return _sensitiveAccounts.Contains(twitterAcct.ToLowerInvariant());
}
}
}
}
10 changes: 8 additions & 2 deletions src/BirdsiteLive.Domain/StatusService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public Note GetStatus(string username, ExtractedTweet tweet)
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"));

Expand Down Expand Up @@ -81,7 +86,8 @@ public Note GetStatus(string username, ExtractedTweet tweet)
to = new[] { to },
cc = cc,

sensitive = false,
sensitive = sensitive,
summary = summary,
content = $"<p>{content}</p>",
attachment = Convert(tweet.Media),
tag = extractedTags.tags
Expand All @@ -104,4 +110,4 @@ private Attachment[] Convert(ExtractedMedia[] media)
}).ToArray();
}
}
}
}
2 changes: 1 addition & 1 deletion src/BirdsiteLive/BirdsiteLive.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
3 changes: 2 additions & 1 deletion src/BirdsiteLive/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"ResolveMentionsInProfiles": true,
"PublishReplies": false,
"MaxUsersCapacity": 1500,
"UnlistedTwitterAccounts": null
"UnlistedTwitterAccounts": null,
"SensitiveTwitterAccounts": null
},
"Db": {
"Type": "postgres",
Expand Down

0 comments on commit 22b0d6d

Please sign in to comment.